Repository navigation
feat(go-models): list LongCat models - #15241
Conversation
Add LongCat model-list support using the documented OpenAI-compatible models endpoint, including connection checks and focused regression coverage for response handling.
📝 WalkthroughWalkthroughLongCat's ChangesLongCat Models Endpoint
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
|
This one is also ready, @Haruko386 - last one for tonight :) Ty |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
conf/models/longcat.jsoninternal/entity/models/longcat.gointernal/entity/models/longcat_test.go
Update the LongCat httptest helper to expose the raw request so the model-list test can detect accidental GET request bodies.
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
internal/entity/models/longcat_test.go
| 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 { |
There was a problem hiding this comment.
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.
| 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
left a comment
There was a problem hiding this comment.
@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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Summary
What changed
modelsURL suffix for/openai/v1/models.ListModelsfor the LongCat Go driver.CheckConnectionto the lightweight model-list request.Why
LongCat documents a models endpoint under the OpenAI-compatible API surface, but the Go driver still returned
no such methodfor model listing and connection checks.Validation
go test ./internal/entity/models -run TestLongCat -count=1go test -race ./internal/entity/models -run TestLongCat -count=1go test ./internal/entity -count=1git diff --checkNotes
go test ./internal/entity/models -count=1is currently blocked by an unrelated Astraflow test panic outside this LongCat change.