Skip to content

Commit 5536480

Browse files
committed
Enhance model response to support multiple tags and add integration tests for packaging functionality
1 parent 010b091 commit 5536480

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

pkg/ollama/http_handler.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -362,24 +362,29 @@ func (h *HTTPHandler) handleListModels(w http.ResponseWriter, r *http.Request) {
362362
QuantizationLevel: model.Config.Quantization,
363363
}
364364

365-
// Get the first tag as the name, or use ID if no tags
366-
name := model.ID
367-
if len(model.Tags) > 0 {
368-
name = model.Tags[0]
369-
}
370-
371365
// Parse size from config string to int64
372366
size := int64(0)
373367
// TODO: Parse size from model.Config.Size if needed
374368

375-
response.Models = append(response.Models, ModelResponse{
376-
Name: name,
377-
Model: name,
378-
ModifiedAt: time.Unix(model.Created, 0),
379-
Size: size,
380-
Digest: model.ID,
381-
Details: details,
382-
})
369+
// Get tags, or use ID if no tags exist
370+
tags := model.Tags
371+
if len(tags) == 0 {
372+
tags = []string{model.ID}
373+
}
374+
375+
// Create a response entry for each tag to match Ollama's behavior
376+
// This ensures that models with multiple tags (e.g., mymodel:latest and mymodel:v1.0)
377+
// are listed separately, allowing clients like OpenWebUI to see all available tags
378+
for _, tag := range tags {
379+
response.Models = append(response.Models, ModelResponse{
380+
Name: tag,
381+
Model: tag,
382+
ModifiedAt: time.Unix(model.Created, 0),
383+
Size: size,
384+
Digest: model.ID,
385+
Details: details,
386+
})
387+
}
383388
}
384389

385390
w.Header().Set("Content-Type", "application/json")

0 commit comments

Comments
 (0)