Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/filters/ai_guardrails.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Calls an external AI guardrail provider to evaluate request and response bodies.
filter: ai_guardrails
provider:
type: nemo
endpoint: "http://nemo:8000/v1/guardrail/checks"
endpoint: "http://nemo:8000/v1/checks"
allow_private_endpoint: true
timeout_ms: 5000
phase:
Expand Down
8 changes: 5 additions & 3 deletions examples/configs/nemo-guardrails-response.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Guardrails (NeMo) - Response Phase Only
#
# Evaluates upstream responses against a NeMo Guardrails service.
# Requires NeMo Guardrails >= 0.24 (the /v1/checks endpoint).
# Request-side guardrails are disabled so the request always reaches
# the upstream. This config is used by integration tests to verify
# response-phase behavior in isolation.
#
# Response phase:
# success - response forwarded to the client unchanged
# passed - response forwarded to the client unchanged
# blocked - response body replaced with a JSON error payload
# (status remains 200 because headers are already committed)
# error - response body replaced with a JSON error payload
# modified - forwarded unchanged until redaction support lands
# provider HTTP error - response body replaced with a JSON error payload
# (same as blocked; headers are already committed)

listeners:
Expand All @@ -24,7 +26,7 @@ filter_chains:
- filter: ai_guardrails
provider:
type: nemo
endpoint: "http://127.0.0.1:3001/v1/guardrail/checks"
endpoint: "http://127.0.0.1:3001/v1/checks"
allow_private_endpoint: true
timeout_ms: 5000
phase:
Expand Down
14 changes: 10 additions & 4 deletions examples/configs/nemo-guardrails.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# Guardrails (NeMo) - Request Phase
#
# Evaluates incoming requests against a NeMo Guardrails service.
# Requires NeMo Guardrails >= 0.24 (the /v1/checks endpoint).
# For response-phase guardrails, see nemo-guardrails-response.yaml.
#
# Request phase:
# success - request forwarded to the upstream unchanged
# blocked - 403 returned to the client (triggered rail names in body)
# error - 500 returned to the client
# passed - request forwarded to the upstream unchanged
# blocked - 403 returned to the client (triggered rail name in body)
# modified - forwarded unchanged until redaction support lands (#49)
# provider HTTP error - 500 returned to the client
#
# Each user message triggers one /v1/checks call (cumulative slices).
# max_message_checks (default 32) caps the number of calls per request;
# conversations exceeding the limit are rejected (fail-closed).
#
# Start a local NeMo Guardrails instance before running this config.
#
Expand Down Expand Up @@ -36,7 +42,7 @@ filter_chains:
type: nemo
# NeMo callouts are anonymous; no downstream authentication
# headers are forwarded to this endpoint.
endpoint: "http://127.0.0.1:3001/v1/guardrail/checks"
endpoint: "http://127.0.0.1:3001/v1/checks"
allow_private_endpoint: true
timeout_ms: 5000
phase:
Expand Down
4 changes: 2 additions & 2 deletions filters/src/guardrails/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde::Deserialize;
/// filter: ai_guardrails
/// provider:
/// type: nemo
/// endpoint: "http://nemo:8000/v1/guardrail/checks"
/// endpoint: "http://nemo:8000/v1/checks"
/// timeout_ms: 5000
/// phase:
/// request: true
Expand All @@ -32,7 +32,7 @@ pub(super) struct AiGuardrailsConfig {
#[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub(super) enum ProviderType {
/// NVIDIA `NeMo` Guardrails via `/v1/guardrail/checks`.
/// NVIDIA `NeMo` Guardrails via `/v1/checks`.
Nemo,
}

Expand Down
6 changes: 3 additions & 3 deletions filters/src/guardrails/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const DEFAULT_MAX_BODY_BYTES: usize = 1_048_576;
/// filter: ai_guardrails
/// provider:
/// type: nemo
/// endpoint: "http://nemo:8000/v1/guardrail/checks"
/// endpoint: "http://nemo:8000/v1/checks"
/// allow_private_endpoint: true
/// timeout_ms: 5000
/// phase:
Expand All @@ -49,7 +49,7 @@ const DEFAULT_MAX_BODY_BYTES: usize = 1_048_576;
/// r#"
/// provider:
/// type: nemo
/// endpoint: "http://nemo:8000/v1/guardrail/checks"
/// endpoint: "http://nemo:8000/v1/checks"
/// allow_private_endpoint: true
/// "#,
/// )
Expand Down Expand Up @@ -270,7 +270,7 @@ fn record_verdict(
},
GuardResult::Block { reason } => Ok(enforce_block(body, reason, phase, phase_label, verdict)),
GuardResult::Redact { reason, .. } => {
tracing::warn!(verdict, phase = phase_label, %reason, "ai_guardrails: verdict; forwarding unchanged until #579");
tracing::warn!(verdict, phase = phase_label, %reason, "ai_guardrails: verdict; forwarding unchanged until #49");
Ok(FilterAction::Continue)
},
}
Expand Down
7 changes: 3 additions & 4 deletions filters/src/guardrails/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ pub enum GuardResult {
reason: String,
},
/// Content contains sensitive data — forward with masked text.
#[cfg_attr(
Comment thread
leseb marked this conversation as resolved.
not(test),
expect(dead_code, reason = "used once /v1/checks migration adds redaction support")
)]
///
/// `modified_text` is populated from `NeMo` but not applied to the request
/// or response body until redaction support lands in `#49`.
Redact {
/// Provider-rewritten text with sensitive data masked.
modified_text: String,
Expand Down
Loading
Loading