-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add endpoint to list system informations (#3449)
* feat: add endpoint to list system informations For now, it lists the available backends, but can be expanded later on to include more system informations (such as GPU devices detected, RAM, threads configured, and so on so forth). Signed-off-by: Ettore Di Giacinto <[email protected]> * show also external backends Signed-off-by: Ettore Di Giacinto <[email protected]> * add test Signed-off-by: Ettore Di Giacinto <[email protected]> --------- Signed-off-by: Ettore Di Giacinto <[email protected]>
- Loading branch information
Showing
5 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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 | ||
} | ||
for b := range appConfig.ExternalGRPCBackends { | ||
availableBackends = append(availableBackends, b) | ||
} | ||
return c.JSON( | ||
schema.SystemInformationResponse{ | ||
Backends: availableBackends, | ||
}, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters