Skip to content

feat(go-models): list LongCat models - #15241

Merged
JinHai-CN merged 4 commits into
infiniflow:mainfrom
oktofeesh1:codex/longcat-list-models
May 26, 2026
Merged

JinHai-CN merged 4 commits into
infiniflow:mainfrom
oktofeesh1:codex/longcat-list-models

Conversation

@oktofeesh1

Copy link
Copy Markdown
Contributor

Summary

  • Add LongCat model-list support through the documented OpenAI-compatible models endpoint.

What changed

  • Add the LongCat models URL suffix for /openai/v1/models.
  • Implement ListModels for the LongCat Go driver.
  • Delegate CheckConnection to the lightweight model-list request.
  • Add focused regression coverage for successful, malformed, oversized, and missing-key responses.

Why

LongCat documents a models endpoint under the OpenAI-compatible API surface, but the Go driver still returned no such method for model listing and connection checks.

Validation

  • go test ./internal/entity/models -run TestLongCat -count=1
  • go test -race ./internal/entity/models -run TestLongCat -count=1
  • go test ./internal/entity -count=1
  • git diff --check

Notes

Add LongCat model-list support using the documented OpenAI-compatible models endpoint, including connection checks and focused regression coverage for response handling.
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 26, 2026
@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

LongCat's ListModels and CheckConnection methods are now implemented to call the /v1/models endpoint instead of returning stub errors. Configuration adds the models endpoint, implementation performs HTTP GET with response parsing and validation, and comprehensive tests verify the new behavior and error handling.

Changes

LongCat Models Endpoint

Layer / File(s) Summary
Models endpoint configuration and documentation
conf/models/longcat.json, internal/entity/models/longcat.go
url_suffix expanded to include models: "openai/v1/models" mapping alongside chat. LongCatModel documentation updated to clarify that reasoning_content is carried alongside content for thinking models.
ListModels and CheckConnection implementation
internal/entity/models/longcat.go
ListModels now performs HTTP GET to the region-specific /v1/models endpoint, enforces max response byte limit, parses data array from JSON response, validates upstream error fields and non-200 statuses, and returns collected model IDs. CheckConnection delegates to ListModels and returns its result instead of always failing.
Test coverage and helpers
internal/entity/models/longcat_test.go
Test helper updated to pass *http.Request to handlers. Tests wired with /openai/v1/models endpoint validate GET request has no body, correct parsing/filtering of model IDs across calls, rejection of malformed or oversized responses, and enforcement of API key requirements for ListModels and CheckConnection.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • infiniflow/ragflow#14809: Both PRs modify the LongCat provider wiring and implementation—conf/models/longcat.json and internal/entity/models/longcat.go/tests—so the main PR’s changes to url_suffix plus implementing /v1/models-backed ListModels and CheckConnection directly extend/fix the LongCat driver introduced in the retrieved PR.

Suggested labels

💞 feature, ci

Suggested reviewers

  • Haruko386

Poem

🐰 I tunneled through configs, tests, and codes,
GET /v1/models on dependable roads.
No more stubs that left me forlorn—
IDs returned with each new morn.
LongCat sings; the rabbit cheers and bops.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is comprehensive but does not follow the required template structure with 'What problem does this PR solve?' and 'Type of change' sections. Restructure the description to match the template: add a 'What problem does this PR solve?' section and include a 'Type of change' checklist with the appropriate option selected.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(go-models): list LongCat models' accurately describes the main change: implementing model listing support for the LongCat driver.
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.

@oktofeesh1

Copy link
Copy Markdown
Contributor Author

This one is also ready, @Haruko386 - last one for tonight :) Ty

@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/longcat_test.go`:
- Around line 411-415: The current GET body assertion is ineffective because
newLongCatServer supplies nil for non-POST bodies; update the test handler (the
anonymous handler passed into newLongCatServer in
internal/entity/models/longcat_test.go) to inspect the raw *http.Request instead
of the already-parsed body: check r.ContentLength and/or call io.ReadAll(r.Body)
(and close/reset as needed) and fail the test if any bytes are present, e.g.,
error when ContentLength > 0 or when ReadAll returns non-empty payload, so
accidental request bodies are detected for GET requests.
🪄 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: 69a6db74-ef0f-4562-83fc-c6223d02639f

📥 Commits

Reviewing files that changed from the base of the PR and between 036ed5b and e51e6a3.

📒 Files selected for processing (3)
  • conf/models/longcat.json
  • internal/entity/models/longcat.go
  • internal/entity/models/longcat_test.go

Comment thread internal/entity/models/longcat_test.go Resolved
Update the LongCat httptest helper to expose the raw request so the model-list test can detect accidental GET request bodies.

@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/longcat_test.go`:
- Around line 411-427: The handler inside newLongCatServer (the closure
receiving t, r *http.Request, body map[string]interface{}, w
http.ResponseWriter) currently checks path/auth/body but not the HTTP method;
add an explicit assertion that r.Method == "GET" (using t.Errorf or the test
helper used elsewhere) so that non-GET requests with empty bodies fail the test.
Locate the closure in longcat_test.go around the newLongCatServer call and
insert the GET method check early (before inspecting body/content length) to
make the expectation explicit.
🪄 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: f111fc1a-cf6e-4eca-80af-e191f0453037

📥 Commits

Reviewing files that changed from the base of the PR and between e51e6a3 and bbd1857.

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

Comment on lines +411 to +427
srv := newLongCatServer(t, "/openai/v1/models", func(t *testing.T, r *http.Request, body map[string]interface{}, w http.ResponseWriter) {
requests++
if body != nil {
t.Errorf("GET /models should not send a JSON body: %v", body)
}
if r.ContentLength > 0 {
t.Errorf("GET /models should not send request body with ContentLength=%d", r.ContentLength)
}
raw, err := io.ReadAll(r.Body)
if err != nil {
t.Errorf("read GET body: %v", err)
return
}
if len(raw) > 0 {
t.Errorf("GET /models should not send request body: %q", string(raw))
}
if requests == 1 {

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 /models HTTP method explicitly.

Line 411 verifies path/auth/body, but it never checks method, so a non-GET request with empty body could still pass. Add an explicit GET assertion here.

✅ Suggested patch
 srv := newLongCatServer(t, "/openai/v1/models", func(t *testing.T, r *http.Request, body map[string]interface{}, w http.ResponseWriter) {
+    if r.Method != http.MethodGet {
+        t.Errorf("expected GET /models, got %s", r.Method)
+        return
+    }
     requests++
     if body != nil {
         t.Errorf("GET /models should not send a JSON body: %v", body)
     }
📝 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
srv := newLongCatServer(t, "/openai/v1/models", func(t *testing.T, r *http.Request, body map[string]interface{}, w http.ResponseWriter) {
requests++
if body != nil {
t.Errorf("GET /models should not send a JSON body: %v", body)
}
if r.ContentLength > 0 {
t.Errorf("GET /models should not send request body with ContentLength=%d", r.ContentLength)
}
raw, err := io.ReadAll(r.Body)
if err != nil {
t.Errorf("read GET body: %v", err)
return
}
if len(raw) > 0 {
t.Errorf("GET /models should not send request body: %q", string(raw))
}
if requests == 1 {
srv := newLongCatServer(t, "/openai/v1/models", func(t *testing.T, r *http.Request, body map[string]interface{}, w http.ResponseWriter) {
if r.Method != http.MethodGet {
t.Errorf("expected GET /models, got %s", r.Method)
return
}
requests++
if body != nil {
t.Errorf("GET /models should not send a JSON body: %v", body)
}
if r.ContentLength > 0 {
t.Errorf("GET /models should not send request body with ContentLength=%d", r.ContentLength)
}
raw, err := io.ReadAll(r.Body)
if err != nil {
t.Errorf("read GET body: %v", err)
return
}
if len(raw) > 0 {
t.Errorf("GET /models should not send request body: %q", string(raw))
}
if requests == 1 {
🤖 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/longcat_test.go` around lines 411 - 427, The handler
inside newLongCatServer (the closure receiving t, r *http.Request, body
map[string]interface{}, w http.ResponseWriter) currently checks path/auth/body
but not the HTTP method; add an explicit assertion that r.Method == "GET" (using
t.Errorf or the test helper used elsewhere) so that non-GET requests with empty
bodies fail the test. Locate the closure in longcat_test.go around the
newLongCatServer call and insert the GET method check early (before inspecting
body/content length) to make the expectation explicit.

@Haruko386 Haruko386 added the ci Continue Integration label May 26, 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.

@oktofeesh1 LGTM
Thank you for your contribution

Verified from CLI

RAGFlow(user)> list supported models from 'longcat' 'test'
+-----------------------------+
| model_name                  |
+-----------------------------+
| LongCat-2.0-Preview         |
| LongCat-Flash-Lite          |
| LongCat-Flash-Chat          |
| LongCat-Flash-Thinking-2601 |
| LongCat-Flash-Omni-2603     |
+-----------------------------+

@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (84add43) to head (7671d76).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15241   +/-   ##
=======================================
  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 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.

@JinHai-CN
JinHai-CN merged commit 22a3b8c into infiniflow:main May 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants