Moge-Row commited on
Commit
39041c5
·
1 Parent(s): 4a63a7a

restore models.go

Browse files
Files changed (1) hide show
  1. internal/handler/models.go +18 -7
internal/handler/models.go CHANGED
@@ -1,12 +1,23 @@
1
  package handler
2
 
3
  import (
4
- "net/http"
5
- "zai-proxy/internal/model"
 
6
  )
7
 
8
- func HandleModelsPage(w http.ResponseWriter, r *http.Request) {
9
- w.Header().Set("Content-Type", "text/html; charset=utf-8")
10
- // El HTML se generará dinámicamente
11
- w.Write([]byte("<h1>Modelos cargando...</h1>"))
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
+ }