Skip to content

Commit 798b107

Browse files
Fixed the API endpoint /api/tags when the model list is empty. (ollama#4424)
* Fixed the API endpoint /api/tags to return {models: []} instead of {models: null} when the model list is empty. * Update server/routes.go --------- Co-authored-by: Jeffrey Morgan <[email protected]>
1 parent 6a1b471 commit 798b107

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

server/routes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ func (s *Server) ListModelsHandler(c *gin.Context) {
725725
return
726726
}
727727

728-
var models []api.ModelResponse
728+
models := []api.ModelResponse{}
729729
if err := filepath.Walk(manifests, func(path string, info os.FileInfo, _ error) error {
730730
if !info.IsDir() {
731731
rel, err := filepath.Rel(manifests, path)

server/routes_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func Test_Routes(t *testing.T) {
9595
err = json.Unmarshal(body, &modelList)
9696
assert.Nil(t, err)
9797

98+
assert.NotNil(t, modelList.Models)
9899
assert.Equal(t, 0, len(modelList.Models))
99100
},
100101
},

0 commit comments

Comments
 (0)