Repository navigation
refactor(go-models): harden Ollama ListModels and route through ParseListModel (#15853) - #15955
Conversation
…ListModel (infiniflow#15853) - Point the Ollama models endpoint at /api/tags (all installed models) instead of /api/ps (only currently-running models), which is what a model picker needs. - Decode the Ollama {"models":[{"name","model"}]} shape into a typed struct, map names into ModelList, and enrich through the shared ParseListModel helper (issue infiniflow#15853). This removes the previous unchecked type assertions (result["models"].([]interface{}) etc.) that panicked on a missing or malformed body, and falls back to the "model" field when "name" is blank. - Drop the pointless GET request body and the dead base-URL reassignment. - Add unit tests (httptest) covering the happy path, the model-field fallback, HTTP errors, and the missing-base-URL guard. Also includes the shared gitee_test.go DSModelList->ModelList compile fix (infiniflow#15900 rename) so the models test package builds; it auto-resolves against the sibling infiniflow#15853 PRs. go build and go vet are clean.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR updates the Ollama model listing implementation to use the correct ChangesOllama /api/tags Migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
Haruko386
left a comment
There was a problem hiding this comment.
@hunnyboy1217 please show your output in RAGFlow CLI for your code tests
Haruko386
left a comment
There was a problem hiding this comment.
@hunnyboy1217 LGTM
It would be better if you could provider your test output in RAGFlow CLI
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15955 +/- ##
=======================================
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. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Part of #15853 (provider model-list refactor).
Refactors Ollama
ListModelsonto the sharedParseListModelpattern and fixes two correctness issues:api/ps(only currently-running models) toapi/tags(all installed models) — the latter is what a model picker should show.{"models":[{"name","model"}]}, a non-OpenAI shape. Decode it into a typed struct, map the names intoModelList, then enrich throughParseListModel. This removes the previous unchecked type assertions (result["models"].([]interface{})/.(map[string]interface{})/.(string)) that panicked when the body was missing themodelsarray or any field, and adds a fallback to themodelfield whennameis blank.Drive-by fix
Shared gitee_test.go
DSModelList->ModelListcompile fix (renamed in #15900) so the models test package builds; auto-resolves against the sibling #15853 PRs.Type of change
How has this been tested?