Repository navigation
fix(go): implement ListModels and CheckConnection in NVIDIA driver - #14636
Conversation
The NVIDIA Go driver landed in infiniflow#14623 with a real chat path but ListModels and CheckConnection were left as stubs that always returned "no such method". So the model picker could not auto- populate available NVIDIA NIM model ids and the "Check connection" button always failed, even with a valid API key and reachable base URL. NVIDIA NIM is OpenAI-compatible. /v1/models works with the same Bearer token used for chat. The conf/models/nvidia.json file already wires the "models" url_suffix, so no config change is needed. Changes: - ListModels now calls GET ${BaseURL}/${URLSuffix.Models}, parses response.data[*].id, and returns the list of model ids. Same shape as the moonshot, xai, and openai drivers. Region resolution falls back to "default" when an unknown region is supplied. The Authorization header is only set when apiConfig and ApiKey are non-nil and non-empty, which avoids a nil-pointer dereference and lets local NIM deployments without a key still work. - CheckConnection now calls ListModels and returns its error, the same way xai, moonshot, deepseek, aliyun, and gitee do. - Balance and Encode and Rerank are still stubs in this PR. They can be added in follow-ups. Closes infiniflow#14635
|
Hi @Magicbook1108, gentle ping for review. Same pattern as the recently merged xAI / moonshot / openai ListModels and the CheckConnection wiring used by xai / moonshot / deepseek / aliyun / gitee. Scope is one file, and it closes #14635. Thanks! |
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe NVIDIA Go driver now implements ChangesNVIDIA Model Provider Methods
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14636 +/- ##
=======================================
Coverage 94.16% 94.16%
=======================================
Files 10 10
Lines 703 703
Branches 112 112
=======================================
Hits 662 662
Misses 25 25
Partials 16 16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Haruko386
left a comment
There was a problem hiding this comment.
Hi @pandadev66, LGTM
Thank you for your contribution
…nfiniflow#14636) ### What problem does this PR solve? The NVIDIA Go driver added in infiniflow#14623 has a real chat path, but \`ListModels\` and \`CheckConnection\` are stubs that always return \`no such method\`. So: - The model picker cannot auto-populate available NVIDIA NIM model ids. Users have to type the full id by hand (e.g. \`abacusai/dracarys-llama-3.1-70b-instruct\`). - The "Check connection" button always fails for NVIDIA, even when the base URL is reachable and the API key is accepted. NVIDIA NIM is OpenAI-compatible. \`/v1/models\` works with the same Bearer token used for chat. The \`conf/models/nvidia.json\` file already wires the \`models\` url_suffix, so no config change is needed. ### What this PR includes - \`internal/entity/models/nvidia.go\`: - \`ListModels\` now calls \`GET ${BaseURL}/${URLSuffix.Models}\`, parses \`response.data[*].id\`, and returns the list. Same shape as the moonshot, xai, and openai drivers. - \`CheckConnection\` now calls \`ListModels\` and returns its error. Same pattern xai, moonshot, deepseek, aliyun, and gitee already use. \`Balance\`, \`Encode\`, and \`Rerank\` are still stubs in this PR and can be added in follow-ups. No JSON change. No factory change. No interface change. ### How the implementation works - Region resolution falls back to \`default\` when the supplied region is unknown, so a stray region value does not break a valid request. - The Authorization header is only set when \`apiConfig\` and \`ApiKey\` are non-nil and non-empty. This avoids a nil-pointer dereference and lets self-hosted NIM deployments without a key still work. - Non-200 responses propagate the upstream status line and body so the user sees a real error message. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) ### How was this tested? - \`go build ./internal/entity/models/...\` in a clean go 1.25 image (the go.mod minimum) returns exit 0. - The full method set on \`NvidiaModel\` still matches the \`ModelDriver\` interface. - Pattern parity with the existing xai, moonshot, deepseek, aliyun, gitee, and openai drivers. Closes infiniflow#14635
…nfiniflow#14636) ### What problem does this PR solve? The NVIDIA Go driver added in infiniflow#14623 has a real chat path, but \`ListModels\` and \`CheckConnection\` are stubs that always return \`no such method\`. So: - The model picker cannot auto-populate available NVIDIA NIM model ids. Users have to type the full id by hand (e.g. \`abacusai/dracarys-llama-3.1-70b-instruct\`). - The "Check connection" button always fails for NVIDIA, even when the base URL is reachable and the API key is accepted. NVIDIA NIM is OpenAI-compatible. \`/v1/models\` works with the same Bearer token used for chat. The \`conf/models/nvidia.json\` file already wires the \`models\` url_suffix, so no config change is needed. ### What this PR includes - \`internal/entity/models/nvidia.go\`: - \`ListModels\` now calls \`GET ${BaseURL}/${URLSuffix.Models}\`, parses \`response.data[*].id\`, and returns the list. Same shape as the moonshot, xai, and openai drivers. - \`CheckConnection\` now calls \`ListModels\` and returns its error. Same pattern xai, moonshot, deepseek, aliyun, and gitee already use. \`Balance\`, \`Encode\`, and \`Rerank\` are still stubs in this PR and can be added in follow-ups. No JSON change. No factory change. No interface change. ### How the implementation works - Region resolution falls back to \`default\` when the supplied region is unknown, so a stray region value does not break a valid request. - The Authorization header is only set when \`apiConfig\` and \`ApiKey\` are non-nil and non-empty. This avoids a nil-pointer dereference and lets self-hosted NIM deployments without a key still work. - Non-200 responses propagate the upstream status line and body so the user sees a real error message. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) ### How was this tested? - \`go build ./internal/entity/models/...\` in a clean go 1.25 image (the go.mod minimum) returns exit 0. - The full method set on \`NvidiaModel\` still matches the \`ModelDriver\` interface. - Pattern parity with the existing xai, moonshot, deepseek, aliyun, gitee, and openai drivers. Closes infiniflow#14635
What problem does this PR solve?
The NVIDIA Go driver added in #14623 has a real chat path, but `ListModels` and `CheckConnection` are stubs that always return `no such method`. So:
`abacusai/dracarys-llama-3.1-70b-instruct`).
NVIDIA NIM is OpenAI-compatible. `/v1/models` works with the same Bearer token used for chat. The
`conf/models/nvidia.json` file already wires the `models` url_suffix, so no config change is needed.
What this PR includes
`GET ${BaseURL}/${URLSuffix.Models}`, parses
`response.data[*].id`, and returns the list. Same shape
as the moonshot, xai, and openai drivers.
error. Same pattern xai, moonshot, deepseek, aliyun, and
gitee already use.
`Balance`, `Encode`, and `Rerank` are still stubs in this PR and can be added in follow-ups.
No JSON change. No factory change. No interface change.
How the implementation works
Type of change
How was this tested?
Closes #14635