Skip to content

Commit

Permalink
fix model endpoint API response format (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
samos123 committed Sep 10, 2024
1 parent e9b1a93 commit 4cbf0c1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/openaiserver/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ func (h *Handler) getModels(w http.ResponseWriter, r *http.Request) {
models[i] = model
}

if err := json.NewEncoder(w).Encode(models); err != nil {
// Wrapper struct to match the desired output format
response := struct {
Object string `json:"object"`
Data []Model `json:"data"`
}{
Object: "list",
Data: models,
}

if err := json.NewEncoder(w).Encode(response); err != nil {
sendErrorResponse(w, http.StatusInternalServerError, "failed to encode response: %v", err)
return
}
Expand Down

0 comments on commit 4cbf0c1

Please sign in to comment.