Spaces:
Paused
Paused
restore models.go
Browse files- internal/handler/models.go +18 -7
internal/handler/models.go
CHANGED
|
@@ -1,12 +1,23 @@
|
|
| 1 |
package handler
|
| 2 |
|
| 3 |
import (
|
| 4 |
-
|
| 5 |
-
|
|
|
|
| 6 |
)
|
| 7 |
|
| 8 |
-
func
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
package handler
|
| 2 |
|
| 3 |
import (
|
| 4 |
+
"encoding/json"
|
| 5 |
+
"net/http"
|
| 6 |
+
"zai-proxy/internal/model"
|
| 7 |
)
|
| 8 |
|
| 9 |
+
func HandleModels(w http.ResponseWriter, r *http.Request) {
|
| 10 |
+
w.Header().Set("Content-Type", "application/json")
|
| 11 |
+
var models []map[string]string
|
| 12 |
+
for _, id := range model.ModelList {
|
| 13 |
+
models = append(models, map[string]string{
|
| 14 |
+
"id": id,
|
| 15 |
+
"object": "model",
|
| 16 |
+
"owned_by": "z.ai",
|
| 17 |
+
})
|
| 18 |
+
}
|
| 19 |
+
json.NewEncoder(w).Encode(map[string]interface{}{
|
| 20 |
+
"object": "list",
|
| 21 |
+
"data": models,
|
| 22 |
+
})
|
| 23 |
+
}
|