refactor(go-models): harden Ollama ListModels and route through ParseListModel (#15853) by hunnyboy1217 · Pull Request #15955 · infiniflow/ragflow (original) (raw)
…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.
Bot added size:M
This PR changes 30-99 lines, ignoring generated files.
Pull request that refactor/refine code
Something isn't working, pull request that fix bug.
labels
This PR has been approved by a maintainer
label
Haruko386 marked this pull request as ready for review
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})