(c *gin.Context)
| 1077 | } |
| 1078 | |
| 1079 | func (s *Server) handleHomeModels(c *gin.Context) { |
| 1080 | entries, ok := s.loadHomeModelEntries(c) |
| 1081 | if !ok { |
| 1082 | return |
| 1083 | } |
| 1084 | |
| 1085 | isClaude := isAnthropicModelsRequest(c) |
| 1086 | |
| 1087 | if isClaude { |
| 1088 | out := formatHomeClaudeModels(entries) |
| 1089 | firstID := "" |
| 1090 | lastID := "" |
| 1091 | if len(out) > 0 { |
| 1092 | if id, okID := out[0]["id"].(string); okID { |
| 1093 | firstID = id |
| 1094 | } |
| 1095 | if id, okID := out[len(out)-1]["id"].(string); okID { |
| 1096 | lastID = id |
| 1097 | } |
| 1098 | } |
| 1099 | c.JSON(http.StatusOK, gin.H{ |
| 1100 | "data": out, |
| 1101 | "has_more": false, |
| 1102 | "first_id": firstID, |
| 1103 | "last_id": lastID, |
| 1104 | }) |
| 1105 | return |
| 1106 | } |
| 1107 | |
| 1108 | filtered := make([]map[string]any, 0, len(entries)) |
| 1109 | for _, entry := range entries { |
| 1110 | model := map[string]any{ |
| 1111 | "id": entry.id, |
| 1112 | "object": "model", |
| 1113 | } |
| 1114 | if entry.created > 0 { |
| 1115 | model["created"] = entry.created |
| 1116 | } |
| 1117 | if entry.ownedBy != "" { |
| 1118 | model["owned_by"] = entry.ownedBy |
| 1119 | } |
| 1120 | filtered = append(filtered, model) |
| 1121 | } |
| 1122 | c.JSON(http.StatusOK, gin.H{ |
| 1123 | "object": "list", |
| 1124 | "data": filtered, |
| 1125 | }) |
| 1126 | } |
| 1127 | |
| 1128 | func formatHomeClaudeModels(entries []homeModelEntry) []map[string]any { |
| 1129 | out := make([]map[string]any, 0, len(entries)) |
no test coverage detected