nemoguardrails.library.prompt_security.actions
nemoguardrails.library.prompt_security.actions
Prompt/Response protection using Prompt Security.
Module Contents
Functions
Data
API
Protects the given user_prompt or bot_response.
Provider results may allow, block, or transform the selected message. Provider failures fail open. A bot response takes precedence when both content arguments are provided.
Returns: RailOutcome.block(), RailOutcome.transform(), or RailOutcome.allow(). Raises: ValueError is returned in one of the following cases:
- If PS_PROTECT_URL env variable is not set.
- If PS_APP_ID env variable is not set.
- If no user_prompt and no bot_response is provided.
Parameters:
The user message to protect.
The bot message to protect.
Optional caller-owned HTTP client.
Calls Prompt Security Protect API asynchronously.
Provider failures are logged and fail open with the default log
action.
Parameters:
the URL of the protect endpoint given by Prompt Security.
//[REGION].prompt.security/api/protect where REGION is eu, useast or apac
the application ID given by Prompt Security (similar to an API key).
//[REGION].prompt.security/ where REGION is eu, useast or apac
the user message to protect.
the system message for context.
the bot message to protect.
the user ID or username for context.
Optional caller-owned HTTP client.
Returns:
A dictionary with the following items: