Skip to content

feat(go-models): harden ListModels for FishAudio (#15853) - #15957

Merged
JinHai-CN merged 5 commits into
infiniflow:mainfrom
hunnyboy1217:feat/go-listmodels-voyage-fishaudio-15853
Jun 17, 2026
Merged

JinHai-CN merged 5 commits into
infiniflow:mainfrom
hunnyboy1217:feat/go-listmodels-voyage-fishaudio-15853

Conversation

@hunnyboy1217

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Part of #15853 (provider model-list refactor). Final two providers.

  • voyage: Voyage AI exposes no live model-list endpoint — its public API only has /v1/embeddings and /v1/rerank — so the previous ListModels was a no such method stub. Replace it with a static-catalog listing sourced from the loaded provider definition, carrying each model's max_tokens, model_types, and embedding dimensions. list models from voyage now returns the 13-model catalog instead of erroring.
  • fishaudio: route the existing /model voice listing through the shared ParseListModel helper for consistency; keep the human-readable title as the model name and fall back to _id when a title is blank.

Drive-by fix

Shared gitee_test.go DSModelList -> ModelList compile fix (renamed in #15900); auto-resolves against the sibling #15853 PRs.

Type of change

  • New Feature (non-breaking change which adds functionality)
  • Refactoring

How has this been tested?

  • go build ./internal/entity/models/... — clean
  • go vet ./internal/entity/models/... — clean
  • TestVoyageListModelsReturnsStaticCatalog passes locally (asserts the catalog and per-model metadata).
  • FishAudio httptest unit tests cover the happy path, the title->_id fallback, the missing-API-key guard, and HTTP errors.

…iflow#15853)

- voyage: Voyage AI exposes no live model-list endpoint (only /v1/embeddings and
  /v1/rerank), so replace the "no such method" stub with a static-catalog
  listing sourced from the loaded provider definition, carrying each model's
  max_tokens, model_types, and embedding dimensions. "list models from voyage"
  now returns the 13-model catalog instead of erroring.
- fishaudio: route the existing /model voice listing through the shared
  ParseListModel helper for consistency, keep the human-readable title as the
  model name, and fall back to _id when a title is blank.

Also includes the shared gitee_test.go DSModelList->ModelList compile fix
(infiniflow#15900 rename); it auto-resolves against the sibling infiniflow#15853 PRs.

Tests: voyage static-catalog test asserts the catalog + metadata; fishaudio
httptest covers the happy path, title->_id fallback, missing key, and HTTP
errors. go build and go vet are clean.
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. ☯️ refactor Pull request that refactor/refine code 💞 feature Feature request, pull request that fullfill a new feature. labels Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 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: 20596a70-c5a9-40a3-94bc-353dffa2ef12

📥 Commits

Reviewing files that changed from the base of the PR and between a722d5a and 94f2ddd.

📒 Files selected for processing (1)
  • internal/entity/models/fishaudio.go
💤 Files with no reviewable changes (1)
  • internal/entity/models/fishaudio.go

📝 Walkthrough

Walkthrough

FishAudioModel.ListModels is refactored to build a ModelList of DSModel entries, applying trimmed title with _id fallback and skipping blank entries, then delegating to ParseListModel. Three unit tests are added for FishAudioModel.ListModels. The Gitee test mock is updated to use ModelList instead of DSModelList.

FishAudio ListModels Refactor and Test Updates

Layer / File(s) Summary
FishAudio ListModels refactoring and tests
internal/entity/models/fishaudio.go, internal/entity/models/fishaudio_test.go
ListModels now builds a ModelList with trimmed title and _id fallback, skips blank entries, and returns via ParseListModel. Tests validate request method, path, Bearer auth, title/_id fallback behavior, missing API key error, and HTTP 401 error.
Gitee test mock alignment
internal/entity/models/gitee_test.go
The mocked /models response in TestGiteeListModelsMapsAllDeepSeekAliasesToModelMetadata is changed from DSModelList to ModelList to match the updated shared infrastructure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • infiniflow/ragflow#15885: Adds Gitee ListModels alias/metadata tests in the same gitee_test.go file that this PR updates.
  • infiniflow/ragflow#15940: Modifies ParseListModel to propagate Dimensions/dimension fields, which is now the shared helper FishAudio.ListModels delegates to after this refactor.

Suggested labels

☯️ refactor, size:M

Poem

🐇 A fish swam through the model stream,
Its title trimmed to stay pristine.
If the title's blank, the _id shines,
And ParseListModel aligns the lines.
No blanks allowed in my clean list—
The rabbit tests, and nothing's missed! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(go-models): harden ListModels for FishAudio' accurately describes one of the main changes in the PR—improving the FishAudio ListModels implementation through the shared ParseListModel helper. However, the PR also includes a significant Voyage implementation, which is not reflected in the title.
Description check ✅ Passed The PR description fully addresses the required template sections: it clearly explains what problems the PR solves (Voyage static catalog and FishAudio refactoring), marks both New Feature and Refactoring change types, and documents testing performed (build, vet, and comprehensive unit tests).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/entity/models/gitee_test.go (1)

107-109: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use t.Errorf inside the httptest handler goroutine

At Line 108, t.Fatalf is called inside http.HandlerFunc. In this goroutine context, prefer t.Errorf so test failure is reliably recorded without goroutine-local Goexit.

Suggested fix
-		if err := json.NewEncoder(w).Encode(resp); err != nil {
-			t.Fatalf("encode response: %v", err)
-		}
+		if err := json.NewEncoder(w).Encode(resp); err != nil {
+			t.Errorf("encode response: %v", err)
+		}

Based on learnings, in httptest handler goroutines use t.Errorf(...) instead of t.Fatalf(...) because t.Fatalf may only stop that goroutine and can miss failing the overall test.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/gitee_test.go` around lines 107 - 109, The handler
goroutine currently calls t.Fatalf when encoding the response
(json.NewEncoder(w).Encode(resp)) which only exits that goroutine; change that
to t.Errorf to record the test failure reliably, and after calling t.Errorf
return from the http.HandlerFunc to avoid further writes; specifically replace
the t.Fatalf(...) call inside the httptest handler with t.Errorf(...) and an
immediate return.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/entity/models/voyage_test.go`:
- Around line 63-65: The test reinitializes the package-global providerManager
via InitProviderManager(dir) and doesn't restore the previous global, causing
order-dependent failures; before calling InitProviderManager in the test save
the existing providerManager value to a local variable and register a t.Cleanup
closure that restores it (or re-calls InitProviderManager with the previous
config) so the global providerManager is restored after the test; reference the
InitProviderManager call and the providerManager global when making the change
and use t.Cleanup to perform restoration.

---

Outside diff comments:
In `@internal/entity/models/gitee_test.go`:
- Around line 107-109: The handler goroutine currently calls t.Fatalf when
encoding the response (json.NewEncoder(w).Encode(resp)) which only exits that
goroutine; change that to t.Errorf to record the test failure reliably, and
after calling t.Errorf return from the http.HandlerFunc to avoid further writes;
specifically replace the t.Fatalf(...) call inside the httptest handler with
t.Errorf(...) and an immediate return.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3574966b-be6e-4266-b9b0-0e41c994f11c

📥 Commits

Reviewing files that changed from the base of the PR and between bde2b1f and 56410e6.

📒 Files selected for processing (5)
  • internal/entity/models/fishaudio.go
  • internal/entity/models/fishaudio_test.go
  • internal/entity/models/gitee_test.go
  • internal/entity/models/voyage.go
  • internal/entity/models/voyage_test.go

Comment thread internal/entity/models/voyage_test.go Resolved

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

@hunnyboy1217 please show your output in RAGFlow CLI for your code tests

@Haruko386 Haruko386 removed 💞 feature Feature request, pull request that fullfill a new feature. ☯️ refactor Pull request that refactor/refine code labels Jun 12, 2026

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

@hunnyboy1217 please refer Voyage api reference for more info

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.

not exist for this api

… to stub (infiniflow#15853)

Per review: Voyage AI's public API exposes only /v1/embeddings and /v1/rerank,
with no model-list endpoint (https://docs.voyageai.com/reference). The previous
static-catalog ListModels misrepresented a capability the API does not have, so
revert it to the not-supported stub used by other endpoint-less providers.

Also removes the static-catalog test (and its global ProviderManager mutation,
which CodeRabbit flagged as order-dependent) in favour of a small test asserting
ListModels returns a not-supported error. FishAudio (which does have a /model
endpoint) is unchanged.
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 16, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/entity/models/voyage_test.go`:
- Around line 56-57: The test in voyage_test.go for the ListModels method
currently only checks that an error is returned, but does not verify the
specific error message. Enhance the assertion to ensure that the error returned
contains the exact "no such method" text by checking that err.Error() contains
this string. This will prevent regressions where ListModels might fail with an
unrelated error instead of the expected unsupported-method error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 90c90fc1-0017-48de-93c1-123307cc7631

📥 Commits

Reviewing files that changed from the base of the PR and between 56410e6 and a722d5a.

📒 Files selected for processing (2)
  • internal/entity/models/voyage.go
  • internal/entity/models/voyage_test.go
✅ Files skipped from review due to trivial changes (1)
  • internal/entity/models/voyage.go

Comment thread internal/entity/models/voyage_test.go Outdated
Comment on lines +56 to +57
if _, err := newVoyageForTest("http://unused").ListModels(&APIConfig{}); err == nil {
t.Fatal("ListModels: expected not-supported error, got nil")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Assert the exact unsupported-method contract, not just non-nil error.

On Line 56, this test currently passes for any failure mode. Please assert that err.Error() contains "no such method" so regressions to unrelated errors don’t go undetected.

Suggested patch
 func TestVoyageListModelsNotSupported(t *testing.T) {
 	// Voyage has no model-list endpoint, so ListModels returns a not-supported error.
-	if _, err := newVoyageForTest("http://unused").ListModels(&APIConfig{}); err == nil {
-		t.Fatal("ListModels: expected not-supported error, got nil")
+	if _, err := newVoyageForTest("http://unused").ListModels(&APIConfig{}); err == nil ||
+		!strings.Contains(err.Error(), "no such method") {
+		t.Fatalf("ListModels: expected no such method error, got %v", err)
 	}
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if _, err := newVoyageForTest("http://unused").ListModels(&APIConfig{}); err == nil {
t.Fatal("ListModels: expected not-supported error, got nil")
func TestVoyageListModelsNotSupported(t *testing.T) {
// Voyage has no model-list endpoint, so ListModels returns a not-supported error.
if _, err := newVoyageForTest("http://unused").ListModels(&APIConfig{}); err == nil ||
!strings.Contains(err.Error(), "no such method") {
t.Fatalf("ListModels: expected no such method error, got %v", err)
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/voyage_test.go` around lines 56 - 57, The test in
voyage_test.go for the ListModels method currently only checks that an error is
returned, but does not verify the specific error message. Enhance the assertion
to ensure that the error returned contains the exact "no such method" text by
checking that err.Error() contains this string. This will prevent regressions
where ListModels might fail with an unrelated error instead of the expected
unsupported-method error.

@hunnyboy1217

Copy link
Copy Markdown
Contributor Author

@Haruko386, Updated. Thank you!

Removed outdated comments regarding Fish Audio model parsing.
Removed unsupported ListModels test for Voyage.
@Haruko386 Haruko386 changed the title feat(go-models): implement ListModels for Voyage and FishAudio (#15853) feat(go-models): harden ListModels for FishAudio (#15853) Jun 17, 2026

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

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 17, 2026
@Haruko386 Haruko386 added the ci Continue Integration label Jun 17, 2026
@Haruko386
Haruko386 marked this pull request as draft June 17, 2026 01:59
@Haruko386
Haruko386 marked this pull request as ready for review June 17, 2026 01:59
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (92c4b76) to head (94f2ddd).
⚠️ Report is 82 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15957   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 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.

@JinHai-CN
JinHai-CN merged commit fd196f6 into infiniflow:main Jun 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants