nemoguardrails.library.fiddler.actions

View as Markdown

Module Contents

Functions

NameDescription
_fiddler_outcome-
call_fiddler_faithfulnessCheck the bot message with the Fiddler faithfulness guardrail.
call_fiddler_guardrailEvaluate content with a Fiddler guardrail endpoint.
call_fiddler_safety_botCheck the bot message with the Fiddler safety guardrail.
call_fiddler_safety_userCheck the user message with the Fiddler safety guardrail.

Data

log

API

nemoguardrails.library.fiddler.actions._fiddler_outcome(
blocked: bool
) -> nemoguardrails.actions.rail_outcome.RailOutcome
nemoguardrails.library.fiddler.actions.call_fiddler_faithfulness(
config: nemoguardrails.RailsConfig,
context: typing.Optional[dict] = None,
bot_message: typing.Optional[str] = None,
relevant_chunks: typing.Optional[str] = None,
http_client: typing.Optional[nemoguardrails.http.HTTPClient] = None
) -> nemoguardrails.actions.rail_outcome.RailOutcome
async

Check the bot message with the Fiddler faithfulness guardrail.

Scores at or below the configured threshold block. Missing content, missing endpoint configuration, and handled provider failures fail open.

Parameters:

config
RailsConfig

Rails configuration containing the Fiddler settings.

context
Optional[dict]Defaults to None

Runtime context containing the bot message and relevant chunks.

http_client
Optional[HTTPClient]Defaults to None

Optional caller-owned HTTP client.

Returns: RailOutcome

An allow or block outcome.

Raises:

  • ValueError: If FIDDLER_API_KEY is not set.
nemoguardrails.library.fiddler.actions.call_fiddler_guardrail(
endpoint: str,
data: dict,
guardrail_name: str,
score_key: str,
threshold: float,
compare: typing.Callable[[float, float], bool],
default_score: float,
http_client: typing.Optional[nemoguardrails.http.HTTPClient] = None
) -> bool
async

Evaluate content with a Fiddler guardrail endpoint.

Non-success responses, HTTP client failures, and expected score-processing failures are logged and fail open.

Parameters:

endpoint
str

Fiddler guardrail endpoint.

data
dict

Guardrail-specific request data.

guardrail_name
str

Name used in diagnostic messages.

score_key
str

Response score used for the decision.

threshold
float

Configured decision threshold.

compare
Callable[[float, float], bool]

Comparison used to determine whether content is blocked.

default_score
float

Score used when the response omits score_key.

http_client
Optional[HTTPClient]Defaults to None

Optional caller-owned HTTP client.

Returns: bool

True when the guardrail blocks the content, otherwise False.

Raises:

  • ValueError: If FIDDLER_API_KEY is not set.
nemoguardrails.library.fiddler.actions.call_fiddler_safety_bot(
config: nemoguardrails.RailsConfig,
context: typing.Optional[dict] = None,
bot_message: typing.Optional[str] = None,
http_client: typing.Optional[nemoguardrails.http.HTTPClient] = None
) -> nemoguardrails.actions.rail_outcome.RailOutcome
async

Check the bot message with the Fiddler safety guardrail.

Scores at or above the configured threshold block. Missing content, missing endpoint configuration, and handled provider failures fail open.

Parameters:

config
RailsConfig

Rails configuration containing the Fiddler settings.

context
Optional[dict]Defaults to None

Runtime context containing the bot message.

http_client
Optional[HTTPClient]Defaults to None

Optional caller-owned HTTP client.

Returns: RailOutcome

An allow or block outcome.

Raises:

  • ValueError: If FIDDLER_API_KEY is not set.
nemoguardrails.library.fiddler.actions.call_fiddler_safety_user(
config: nemoguardrails.RailsConfig,
context: typing.Optional[dict] = None,
user_message: typing.Optional[str] = None,
http_client: typing.Optional[nemoguardrails.http.HTTPClient] = None
) -> nemoguardrails.actions.rail_outcome.RailOutcome
async

Check the user message with the Fiddler safety guardrail.

Scores at or above the configured threshold block. Missing content, missing endpoint configuration, and handled provider failures fail open.

Parameters:

config
RailsConfig

Rails configuration containing the Fiddler settings.

context
Optional[dict]Defaults to None

Runtime context containing the user message.

http_client
Optional[HTTPClient]Defaults to None

Optional caller-owned HTTP client.

Returns: RailOutcome

An allow or block outcome.

Raises:

  • ValueError: If FIDDLER_API_KEY is not set.
nemoguardrails.library.fiddler.actions.log = logging.getLogger(__name__)