File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,33 @@ import (
99 "strings"
1010
1111 "github.com/gin-gonic/gin"
12+ "github.com/openai/openai-go"
1213
1314 "github.com/NexaAI/nexa-sdk/runner/internal/store"
1415 "github.com/NexaAI/nexa-sdk/runner/internal/types"
1516)
1617
1718func ListModels (c * gin.Context ) {
19+ s := store .Get ()
20+
21+ models , err := s .List ()
22+ if err != nil {
23+ c .JSON (http .StatusInternalServerError , map [string ]any {"error" : err .Error ()})
24+ return
25+ }
1826
27+ res := make ([]openai.Model , 0 , len (models ))
28+ for _ , m := range models {
29+ res = append (res , openai.Model {
30+ ID : m .Name ,
31+ OwnedBy : strings .Split (m .Name , "/" )[0 ],
32+ })
33+ }
34+
35+ c .JSON (http .StatusOK , map [string ]any {
36+ "object" : "list" ,
37+ "data" : res ,
38+ })
1939}
2040
2141func RetrieveModel (c * gin.Context ) {
Original file line number Diff line number Diff line change @@ -38,5 +38,7 @@ func RegisterAPIv1(r *gin.Engine) {
3838 //g.POST("/reranking", handler.Reranking)
3939
4040 g .GET ("/models/*model" , handler .RetrieveModel )
41+ g .GET ("/models" , handler .ListModels )
42+ // extend for pull model
4143 g .POST ("/models" , handler .PullModel )
4244}
You can’t perform that action at this time.
0 commit comments