Skip to content

fix(go): implement ListModels and CheckConnection in NVIDIA driver - #14636

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
pandadev66:fix/go-nvidia-list-and-check
May 8, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
pandadev66:fix/go-nvidia-list-and-check

Conversation

@pandadev66

@pandadev66 pandadev66 commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • 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

  • 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 #14635

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
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 7, 2026
@pandadev66

Copy link
Copy Markdown
Contributor Author

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!

@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 66d2bf9a-8020-43a0-9dfe-564708b835ce

📥 Commits

Reviewing files that changed from the base of the PR and between 94324af and 510bea0.

📒 Files selected for processing (1)
  • internal/entity/models/nvidia.go

📝 Walkthrough

Walkthrough

The NVIDIA Go driver now implements ListModels to fetch available model IDs from the NVIDIA NIM /models endpoint using the configured API key and base URL, and updates CheckConnection to validate connectivity by invoking ListModels instead of returning a hardcoded "no such method" error.

Changes

NVIDIA Model Provider Methods

Layer / File(s) Summary
ListModels Implementation
internal/entity/models/nvidia.go
Implements ListModels(apiConfig *APIConfig) to select region/base URL with fallbacks, issue HTTP GET to NVIDIA models endpoint with Bearer token, validate response status and OpenAI-compatible {"data":[{"id":...},...]} structure, extract model IDs, and return slice or structured errors on validation/status/URL failures.
CheckConnection Validation
internal/entity/models/nvidia.go
Updates CheckConnection(apiConfig *APIConfig) to call ListModels and return its error for lightweight connectivity validation instead of returning hardcoded "no such method".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • infiniflow/ragflow#14623: Initial NVIDIA Go driver implementation that introduced the stubbed ListModels and CheckConnection methods now being implemented in this PR.

Suggested labels

size:L

Poem

A rabbit hops through NVIDIA's door 🐰
Where models once were out of reach,
Now ListModels and CheckConnection sing,
The stubbed methods finally teach—
No more "no such method" here! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: implementing ListModels and CheckConnection in the NVIDIA driver.
Description check ✅ Passed The description includes all required template sections with detailed context about the problem, type of change, and implementation details.
Linked Issues check ✅ Passed The PR fully addresses issue #14635 by implementing ListModels to call the models endpoint and returning parsed model ids, and CheckConnection to call ListModels, matching the expected behavior described in the issue.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing the two stubbed methods in the NVIDIA driver with no unrelated modifications to configuration, factory, or interface code.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JinHai-CN JinHai-CN added the ci Continue Integration label May 7, 2026
@JinHai-CN
JinHai-CN marked this pull request as draft May 7, 2026 12:56
@JinHai-CN
JinHai-CN marked this pull request as ready for review May 7, 2026 12:57
@dosubot dosubot Bot added the 🐞 bug Something isn't working, pull request that fix bug. label May 7, 2026
@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.16%. Comparing base (94324af) to head (510bea0).
⚠️ Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 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.

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @pandadev66, LGTM
Thank you for your contribution

@JinHai-CN
JinHai-CN merged commit c7ddc8c into infiniflow:main May 8, 2026
1 check passed
pekar9781 pushed a commit to pekar9781/ragflow that referenced this pull request May 8, 2026
…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
Ricardo-M-L pushed a commit to Ricardo-M-L/ragflow that referenced this pull request Aug 17, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: NVIDIA Go driver has ListModels and CheckConnection stubbed

3 participants