nemoguardrails.actions.output_mapping

View as Markdown

Module Contents

Functions

NameDescription
default_output_mappingA fallback output mapping if an action does not provide one.
is_output_blockedDetermines if an action result is not allowed using its attached mapping.

API

nemoguardrails.actions.output_mapping.default_output_mapping(
result: typing.Any
) -> bool

A fallback output mapping if an action does not provide one.

  • For a boolean result: assume True means allowed (so block if False).
  • For a numeric result: use 0.5 as a threshold (block if the value is less).
  • Otherwise, assume the result is allowed.
nemoguardrails.actions.output_mapping.is_output_blocked(
result: typing.Any,
action_func: typing.Any
) -> bool

Determines if an action result is not allowed using its attached mapping.

Parameters:

result
Any

The value returned by the action.

action_func
Any

The action function (whose metadata contains the mapping).

Returns: bool

True if the mapping indicates that the output should be blocked, False otherwise.