> This page is for version v0.24.0.
> For other versions, use one of these documentation indexes:
> - Latest (default): https://docs.nvidia.com/nemo/guardrails/latest/llms.txt
> - v0.24.1: https://docs.nvidia.com/nemo/guardrails/v0.24.1/llms.txt
> - v0.24.0: https://docs.nvidia.com/nemo/guardrails/v0.24.0/llms.txt
> - v0.23.0: https://docs.nvidia.com/nemo/guardrails/v0.23.0/llms.txt
> - v0.22.0: https://docs.nvidia.com/nemo/guardrails/v0.22.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# nemoguardrails.library.patronusai.actions

## Module Contents

### Functions

| Name                                                                                                                              | Description                                                                           |
| --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| [`_get_patronus_lynx_model`](#nemoguardrails-library-patronusai-actions-_get_patronus_lynx_model)                                 | -                                                                                     |
| [`_patronus_lynx_outcome`](#nemoguardrails-library-patronusai-actions-_patronus_lynx_outcome)                                     | -                                                                                     |
| [`check_guardrail_pass`](#nemoguardrails-library-patronusai-actions-check_guardrail_pass)                                         | Check if evaluations in the Patronus API response pass based on the success strategy. |
| [`parse_patronus_lynx_response`](#nemoguardrails-library-patronusai-actions-parse_patronus_lynx_response)                         | Parses the response from the Patronus Lynx LLM and returns a tuple of:                |
| [`patronus_api_check_output`](#nemoguardrails-library-patronusai-actions-patronus_api_check_output)                               | Check the user message, bot response, and/or provided context                         |
| [`patronus_evaluate_request`](#nemoguardrails-library-patronusai-actions-patronus_evaluate_request)                               | Make a call to the Patronus Evaluate API.                                             |
| [`patronus_lynx_check_output_hallucination`](#nemoguardrails-library-patronusai-actions-patronus_lynx_check_output_hallucination) | Check the bot response for hallucinations based on the given chunks                   |

### Data

[`log`](#nemoguardrails-library-patronusai-actions-log)

### API

```python
nemoguardrails.library.patronusai.actions._get_patronus_lynx_model(
    llms: collections.abc.Mapping[str, nemoguardrails.types.LLMModel],
    model_name: str
) -> nemoguardrails.types.LLMModel
```

```python
nemoguardrails.library.patronusai.actions._patronus_lynx_outcome(
    hallucination: bool,
    reasoning: typing.Union[typing.List[str], None]
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

```python
nemoguardrails.library.patronusai.actions.check_guardrail_pass(
    response: typing.Optional[dict],
    success_strategy: typing.Literal['all_pass', 'any_pass']
) -> bool
```

Check if evaluations in the Patronus API response pass based on the success strategy.
"all\_pass" requires all evaluators to pass for success.
"any\_pass" requires only one evaluator to pass for success.

```python
nemoguardrails.library.patronusai.actions.parse_patronus_lynx_response(
    response: str
) -> typing.Tuple[bool, typing.Union[typing.List[str], None]]
```

Parses the response from the Patronus Lynx LLM and returns a tuple of:

* Whether the response is hallucinated or not.
* A reasoning trace explaining the decision.

```python
nemoguardrails.library.patronusai.actions.patronus_api_check_output(
    llm_task_manager: nemoguardrails.llm.taskmanager.LLMTaskManager,
    context: typing.Optional[dict] = None,
    user_message: typing.Optional[str] = None,
    bot_message: typing.Optional[str] = None,
    relevant_chunks: typing.Optional[typing.Union[str, typing.List[str]]] = None,
    http_client: typing.Optional[nemoguardrails.http.HTTPClient] = None
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

async

Check the user message, bot response, and/or provided context
for issues based on the Patronus Evaluate API

```python
nemoguardrails.library.patronusai.actions.patronus_evaluate_request(
    api_params: dict,
    user_input: typing.Optional[str] = None,
    bot_response: typing.Optional[str] = None,
    provided_context: typing.Optional[typing.Union[str, typing.List[str]]] = None,
    http_client: typing.Optional[nemoguardrails.http.HTTPClient] = None
) -> typing.Optional[dict]
```

async

Make a call to the Patronus Evaluate API.

Returns a dictionary of the API response JSON if successful, or None if a server error occurs.

* Server errors will cause the guardrail to block the bot response

Raises a ValueError for client errors (400-499), as these indicate invalid requests.

```python
nemoguardrails.library.patronusai.actions.patronus_lynx_check_output_hallucination(
    llm_task_manager: nemoguardrails.llm.taskmanager.LLMTaskManager,
    llms: collections.abc.Mapping[str, nemoguardrails.types.LLMModel],
    model_name: str,
    context: typing.Optional[dict] = None,
    user_message: typing.Optional[str] = None,
    bot_message: typing.Optional[str] = None,
    relevant_chunks: typing.Optional[str] = None,
    kwargs = {}
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

async

Check the bot response for hallucinations based on the given chunks
using the configured Patronus Lynx model.

```python
nemoguardrails.library.patronusai.actions.log = logging.getLogger(__name__)
```