mirror of
https://github.com/mudler/LocalAI.git
synced 2024-12-29 08:58:52 +00:00
cca881ec49
* Wip p2p enhancements * get online state * Pass-by token to show in the dashboard Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Style * Minor fixups * parametrize SearchID * Refactoring * Allow to expose/bind more services Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Add federation * Display federated mode in the WebUI Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Small fixups Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * make federated nodes visible from the WebUI * Fix version display * improve web page * live page update * visual enhancements * enhancements * visual enhancements --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package localai
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/mudler/LocalAI/core/config"
|
|
"github.com/mudler/LocalAI/core/gallery"
|
|
"github.com/mudler/LocalAI/core/p2p"
|
|
"github.com/mudler/LocalAI/internal"
|
|
"github.com/mudler/LocalAI/pkg/model"
|
|
)
|
|
|
|
func WelcomeEndpoint(appConfig *config.ApplicationConfig,
|
|
cl *config.BackendConfigLoader, ml *model.ModelLoader, modelStatus func() (map[string]string, map[string]string)) func(*fiber.Ctx) error {
|
|
return func(c *fiber.Ctx) error {
|
|
models, _ := ml.ListModels()
|
|
backendConfigs := cl.GetAllBackendConfigs()
|
|
|
|
galleryConfigs := map[string]*gallery.Config{}
|
|
for _, m := range backendConfigs {
|
|
|
|
cfg, err := gallery.GetLocalModelConfiguration(ml.ModelPath, m.Name)
|
|
if err != nil {
|
|
continue
|
|
}
|
|
galleryConfigs[m.Name] = cfg
|
|
}
|
|
|
|
// Get model statuses to display in the UI the operation in progress
|
|
processingModels, taskTypes := modelStatus()
|
|
|
|
summary := fiber.Map{
|
|
"Title": "LocalAI API - " + internal.PrintableVersion(),
|
|
"Version": internal.PrintableVersion(),
|
|
"Models": models,
|
|
"ModelsConfig": backendConfigs,
|
|
"GalleryConfig": galleryConfigs,
|
|
"IsP2PEnabled": p2p.IsP2PEnabled(),
|
|
"ApplicationConfig": appConfig,
|
|
"ProcessingModels": processingModels,
|
|
"TaskTypes": taskTypes,
|
|
}
|
|
|
|
if string(c.Context().Request.Header.ContentType()) == "application/json" || len(c.Accepts("html")) == 0 {
|
|
// The client expects a JSON response
|
|
return c.Status(fiber.StatusOK).JSON(summary)
|
|
} else {
|
|
// Render index
|
|
return c.Render("views/index", summary)
|
|
}
|
|
}
|
|
}
|