The AI NVIDIA NeMo Guardrail Policy can be applied to:
- Input data (requests)
- Output data (responses)
- Both input and output data
Here’s how it works if you apply it to both requests and responses:
- The AI Policy intercepts the request and sends the extracted text to the NeMo Guardrails microservice.
- NeMo runs the configured input rails and returns a pass or block status.
- If NeMo allows the content, AI Gateway forwards the request to the upstream model.
- The Policy intercepts the response from the upstream provider and sends the extracted text to NeMo Guardrails.
- NeMo runs the configured output rails and returns a pass or block status.
- If NeMo allows the content, AI Gateway forwards the response to the client.
sequenceDiagram
autonumber
participant Client
participant Policy as AI NVIDIA NeMo Guardrail
participant NeMo as NeMo Guardrails
participant AI as Upstream AI Service
Client->>Policy: Send request
Policy->>NeMo: Intercept & send extracted request text
NeMo->>NeMo: Run configured input rails
NeMo->>Policy: Return pass or block status
Policy->>AI Gateway: Forward allowed request
AI Gateway->>AI: Process allowed request
AI->>AI Gateway: Return AI response
AI Gateway->>Policy: Forward response
Policy->>NeMo: Intercept & send extracted response text
NeMo->>NeMo: Run configured output rails
NeMo->>Policy: Return pass or block status
Policy->>Client: Return allowed response
Figure 1: Diagram showing the request and response flow with the AI NVIDIA NeMo Guardrail Policy.
By default, the Policy checks requests only. Use config.guarding_mode to change which phases it inspects:
|
Value
|
Description
|
INPUT
|
Checks requests only. This is the default.
|
OUTPUT
|
Checks responses only.
|
BOTH
|
Checks both requests and responses.
|
To control which parts of the conversation the Policy sends for evaluation, use config.text_source. Set it to concatenate_user_content to check only user input, or concatenate_all_content to include the full exchange, including system and assistant messages.
Match the rails defined in your NeMo guardrail configuration to the phases named in config.guarding_mode. A configuration used with guarding_mode: INPUT should define only an input rail; a configuration used with guarding_mode: OUTPUT should define only an output rail. NeMo evaluates whichever rails a configuration defines every time it’s called, regardless of guarding_mode, so an output rail included in an input-only check runs against an empty response.