2024-09-05 18:44:30 +00:00
|
|
|
package localai
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
"github.com/mudler/LocalAI/core/config"
|
|
|
|
"github.com/mudler/LocalAI/core/schema"
|
|
|
|
"github.com/mudler/LocalAI/pkg/model"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SystemInformations returns the system informations
|
|
|
|
// @Summary Show the LocalAI instance information
|
|
|
|
// @Success 200 {object} schema.SystemInformationResponse "Response"
|
|
|
|
// @Router /system [get]
|
|
|
|
func SystemInformations(ml *model.ModelLoader, appConfig *config.ApplicationConfig) func(*fiber.Ctx) error {
|
|
|
|
return func(c *fiber.Ctx) error {
|
|
|
|
availableBackends, err := ml.ListAvailableBackends(appConfig.AssetsDestination)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-09-25 16:00:23 +00:00
|
|
|
loadedModels := ml.ListModels()
|
2024-09-05 18:44:30 +00:00
|
|
|
for b := range appConfig.ExternalGRPCBackends {
|
|
|
|
availableBackends = append(availableBackends, b)
|
|
|
|
}
|
2024-11-14 13:12:29 +00:00
|
|
|
|
|
|
|
sysmodels := []schema.SysInfoModel{}
|
|
|
|
for _, m := range loadedModels {
|
|
|
|
sysmodels = append(sysmodels, schema.SysInfoModel{ID: m.ID})
|
|
|
|
}
|
2024-09-05 18:44:30 +00:00
|
|
|
return c.JSON(
|
|
|
|
schema.SystemInformationResponse{
|
|
|
|
Backends: availableBackends,
|
2024-11-14 13:12:29 +00:00
|
|
|
Models: sysmodels,
|
2024-09-05 18:44:30 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|