Skip to content

feat(guardrails): add NeMo Provider#285

Open
christinaexyou wants to merge 2 commits into
praxis-proxy:mainfrom
christinaexyou:add-nemo-provider
Open

feat(guardrails): add NeMo Provider#285
christinaexyou wants to merge 2 commits into
praxis-proxy:mainfrom
christinaexyou:add-nemo-provider

Conversation

@christinaexyou

Copy link
Copy Markdown
Contributor

Refactor of praxis-proxy/praxis#700

Implements the NeMo provider for the ai_guardrails filter, completing request-side evaluation against NeMo Guardrails. Addresses #48.

The following changes were made:
providers/nemo.rs

  • Implements NemoProvider which sends a POST to the configured /v1/guardrail/checks endpoint and maps the NeMo response to a GuardResult

filter.rs

  • on_request_body which checks phase.request (default true), waits for end_of_stream, parses the body, calls extract_messages, invokes the provider, and acts on the verdict:

    Pass → Continue
    Block → Reject 403 with the blocked rail name(s) in the body
    Redact → Continue (body replacement placeholder for ai_guardrails: NeMo mask / redact action #49)

  • extract_messages: parses OpenAI Chat Completions API formats, returns FilterError for unsupported formats

@christinaexyou christinaexyou requested review from a team and alexsnaps July 6, 2026 17:14
@christinaexyou christinaexyou requested a review from shaneutt as a code owner July 6, 2026 17:14
@praxis-bot-app

praxis-bot-app Bot commented Jul 6, 2026

Copy link
Copy Markdown

Missing Signed-off-by: 25b82fc. All commits require sign-off (via git commit --signoff).

@praxis-bot-app

praxis-bot-app Bot commented Jul 6, 2026

Copy link
Copy Markdown

Unsigned commits: 3803297. Please sign your commits.

@christinaexyou christinaexyou force-pushed the add-nemo-provider branch 8 times, most recently from 05bb6a1 to 97f4123 Compare July 6, 2026 18:58
Comment thread filters/src/guardrails/filter.rs
Comment thread filters/src/guardrails/providers/nemo.rs Outdated
Comment thread tests/integration/tests/suite/examples/guardrails.rs Outdated
Comment thread filters/Cargo.toml Outdated
Comment thread filters/src/guardrails/providers/mod.rs

@praxis-bot praxis-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NeMo Provider Review

Solid implementation of the NeMo guardrails provider with correct request-side integration, good error handling structure, and functional integration tests covering all three verdict paths plus provider-down scenarios.

Findings

# Severity File Summary
1 Large nemo.rs Content-Length size check bypassed for chunked responses
2 Large nemo.rs No unit tests for map_nemo_response or blocked_rail_names
3 Large filter.rs No unit tests for extract_messages
4 Large tests.rs Only happy-path on_request_body test; no block/redact/error path tests
5 Medium nemo.rs Short-form separator comment
6 Medium filter.rs Short-form separator comment

Non-inline findings

[Medium] filters/src/guardrails/filter.rs and examples/configs/nemo-guardrails.yaml are both missing POSIX trailing newlines (\ No newline at end of file in the diff). Add a final newline to each.

Comment thread filters/src/guardrails/providers/nemo.rs Outdated
Comment thread filters/src/guardrails/providers/nemo.rs
///
/// Returns [`FilterError`] if the body is not valid JSON or does not
/// contain a recognizable messages field.
fn extract_messages(body: &Bytes) -> Result<Vec<serde_json::Value>, FilterError> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Large] extract_messages has no unit tests. Add tests for:

  • Valid body with "messages" array (happy path)
  • Invalid JSON (verify error message)
  • Valid JSON without a "messages" key
  • "messages" present but not an array (e.g. a string)
  • Empty "messages" array (should succeed, returns empty vec)

Comment thread filters/src/guardrails/tests.rs Outdated
Comment thread filters/src/guardrails/providers/nemo.rs Outdated
Comment thread filters/src/guardrails/filter.rs Outdated
Signed-off-by: Christina Xu <chrxu@redhat.com>
@christinaexyou christinaexyou force-pushed the add-nemo-provider branch 2 times, most recently from 1509095 to 55c5f0b Compare July 9, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants