Skip to content

Conversation

christinaexyou
Copy link

@christinaexyou christinaexyou commented Aug 18, 2025

Description

This PR modifies the existing /v1/chat/completions and adds a /v1/models endpoint to be OpenAI compatible.

Changes:

  • nemoguardrails/server/api.py - Introduces new classes that correspond to OpenAI's standard chat completion and models API
  • tests/test_api.py, tests/test_server_calls_with_state.py & tests/test_threads - Updates the message content path according to new ResponseBody class and adds new tests for the /v1/models API

Related Issue(s)

Checklist

  • I've read the CONTRIBUTING guidelines.
  • I've updated the documentation if applicable.
  • I've added tests if applicable.
  • @mentions of the person or team responsible for reviewing proposed changes.

@christinaexyou
Copy link
Author

Updated nemoguardrails/colang/v2_x/runtime/runtime.py and tests/test_server_calls_with_state.py because tests were failing due to Colang 2.x not supporting assistant messages as input. Fixed by adding logic to convert State object to dict and passing in state instead of assistant cc: @Pouyanpi @tgasser-nv

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 81.42857% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.70%. Comparing base (eb29437) to head (f494cf2).

Files with missing lines Patch % Lines
nemoguardrails/server/api.py 84.84% 10 Missing ⚠️
nemoguardrails/colang/v2_x/runtime/runtime.py 25.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1340      +/-   ##
===========================================
+ Coverage    71.66%   71.70%   +0.04%     
===========================================
  Files          171      171              
  Lines        17015    17071      +56     
===========================================
+ Hits         12193    12240      +47     
- Misses        4822     4831       +9     
Flag Coverage Δ
python 71.70% <81.42%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
nemoguardrails/colang/v2_x/runtime/runtime.py 73.84% <25.00%> (-0.41%) ⬇️
nemoguardrails/server/api.py 64.58% <84.84%> (+5.00%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants