feat: Add NVIDIA provider support with OpenAI-compatible API#2847
Open
rohithmahesh3 wants to merge 3 commits intoantinomyhq:mainfrom
Open
feat: Add NVIDIA provider support with OpenAI-compatible API#2847rohithmahesh3 wants to merge 3 commits intoantinomyhq:mainfrom
rohithmahesh3 wants to merge 3 commits intoantinomyhq:mainfrom
Conversation
- Add NVIDIA provider constant and configuration - Add reasoning_content field to handle NVIDIA's response format - Implement MergeSystemMessages transformer for NVIDIA's system message requirements - Add comprehensive test coverage for NVIDIA deserialization
…st.rs Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add NVIDIA as a supported provider using their OpenAI-compatible API, with handling for NVIDIA-specific response and request format requirements.
Context
NVIDIA's API endpoint (
integrate.api.nvidia.com) follows the OpenAI chat completions format but has two key differences:reasoning_contentinstead ofreasoning, and sometimes sends both fields simultaneously. The previous#[serde(alias)]approach caused deserialization failures when both fields appeared in the same response (serde's "duplicate value" error).Changes
Provider Registration
NVIDIAprovider constant with string mappings inProviderIdprovider.jsonwith API URL andNVIDIA_API_KEYenvironment variableResponse Handling (Serde Fix)
#[serde(alias = "reasoning_content")]with a dedicatedreasoning_contentfield onResponseMessagemerged_reasoning()helper that prefersreasoningoverreasoning_contentwhen both are presentmerged_reasoning()Request Transformer
MergeSystemMessagestransformer that consolidates all system messages into a single leading system messageTesting
MergeSystemMessagestransformer tests (multiple system messages, single system message, no system messages, empty messages)forge_app, 282 inforge_domain/forge_repo)Testing
cargo test -p forge_app -p forge_domain -p forge_repo --libAll 832 tests pass.