Skip to content

Commit

Permalink
chore(api): return values from schema (#4153)
Browse files Browse the repository at this point in the history
Signed-off-by: Ettore Di Giacinto <[email protected]>
  • Loading branch information
mudler authored Nov 14, 2024
1 parent a73c660 commit 1770b92
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
7 changes: 6 additions & 1 deletion core/http/endpoints/localai/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ func SystemInformations(ml *model.ModelLoader, appConfig *config.ApplicationConf
for b := range appConfig.ExternalGRPCBackends {
availableBackends = append(availableBackends, b)
}

sysmodels := []schema.SysInfoModel{}
for _, m := range loadedModels {
sysmodels = append(sysmodels, schema.SysInfoModel{ID: m.ID})
}
return c.JSON(
schema.SystemInformationResponse{
Backends: availableBackends,
Models: loadedModels,
Models: sysmodels,
},
)
}
Expand Down
9 changes: 6 additions & 3 deletions core/schema/localai.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package schema

import (
"github.com/mudler/LocalAI/core/p2p"
"github.com/mudler/LocalAI/pkg/model"
gopsutil "github.com/shirou/gopsutil/v3/process"
)

Expand Down Expand Up @@ -77,7 +76,11 @@ type P2PNodesResponse struct {
FederatedNodes []p2p.NodeData `json:"federated_nodes" yaml:"federated_nodes"`
}

type SysInfoModel struct {
ID string `json:"id"`
}

type SystemInformationResponse struct {
Backends []string `json:"backends"`
Models []model.Model `json:"loaded_models"`
Backends []string `json:"backends"`
Models []SysInfoModel `json:"loaded_models"`
}
6 changes: 3 additions & 3 deletions pkg/model/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ FILE:
return models, nil
}

func (ml *ModelLoader) ListModels() []Model {
func (ml *ModelLoader) ListModels() []*Model {
ml.mu.Lock()
defer ml.mu.Unlock()

models := []Model{}
models := []*Model{}
for _, model := range ml.models {
models = append(models, *model)
models = append(models, model)
}

return models
Expand Down

0 comments on commit 1770b92

Please sign in to comment.