nemoguardrails.library.ai_defense.actions

View as Markdown

Prompt/Response protection using Cisco AI Defense.

Module Contents

Functions

NameDescription
ai_defense_inspect-
is_ai_defense_text_blockedMapping for inspect API response.

Data

DEFAULT_TIMEOUT

log

API

nemoguardrails.library.ai_defense.actions.ai_defense_inspect(
config: nemoguardrails.RailsConfig,
user_prompt: typing.Optional[str] = None,
bot_response: typing.Optional[str] = None,
kwargs = {}
)
async
nemoguardrails.library.ai_defense.actions.is_ai_defense_text_blocked(
result: typing.Dict[str, typing.Any]
) -> bool

Mapping for inspect API response. Expects result to be a dict with:

  • “is_blocked”: a boolean indicating if the prompt or response sent to AI Defense should be blocked.

Returns: bool

True if the text should be blocked, False otherwise.

nemoguardrails.library.ai_defense.actions.DEFAULT_TIMEOUT = 30.0
nemoguardrails.library.ai_defense.actions.log = logging.getLogger(__name__)