diff --git a/core/http/endpoints/localai/system.go b/core/http/endpoints/localai/system.go index 64b1d111b..349f97cf8 100644 --- a/core/http/endpoints/localai/system.go +++ b/core/http/endpoints/localai/system.go @@ -14,7 +14,7 @@ import ( func SystemInformations(ml *model.ModelLoader, appConfig *config.ApplicationConfig) func(*fiber.Ctx) error { return func(c *fiber.Ctx) error { availableBackends := []string{} - loadedModels := ml.ListModels() + loadedModels := ml.ListLoadedModels() for b := range appConfig.ExternalGRPCBackends { availableBackends = append(availableBackends, b) } diff --git a/core/http/endpoints/localai/welcome.go b/core/http/endpoints/localai/welcome.go index 7f5e0076c..23efd0788 100644 --- a/core/http/endpoints/localai/welcome.go +++ b/core/http/endpoints/localai/welcome.go @@ -16,6 +16,15 @@ func WelcomeEndpoint(appConfig *config.ApplicationConfig, modelConfigs := cl.GetAllModelsConfigs() galleryConfigs := map[string]*gallery.ModelConfig{} + backends, _ := gallery.AvailableBackends(appConfig.BackendGalleries, appConfig.SystemState) + + installedBackends := gallery.GalleryElements[*gallery.GalleryBackend]{} + for _, b := range backends { + if b.Installed { + installedBackends = append(installedBackends, b) + } + } + for _, m := range modelConfigs { cfg, err := gallery.GetLocalModelConfiguration(ml.ModelPath, m.Name) if err != nil { @@ -24,6 +33,12 @@ func WelcomeEndpoint(appConfig *config.ApplicationConfig, galleryConfigs[m.Name] = cfg } + loadedModels := ml.ListLoadedModels() + loadedModelsMap := map[string]bool{} + for _, m := range loadedModels { + loadedModelsMap[m.ID] = true + } + modelsWithoutConfig, _ := services.ListModels(cl, ml, config.NoFilterFn, services.LOOSE_ONLY) // Get model statuses to display in the UI the operation in progress @@ -39,6 +54,8 @@ func WelcomeEndpoint(appConfig *config.ApplicationConfig, "ApplicationConfig": appConfig, "ProcessingModels": processingModels, "TaskTypes": taskTypes, + "LoadedModels": loadedModelsMap, + "InstalledBackends": installedBackends, } if string(c.Context().Request.Header.ContentType()) == "application/json" || len(c.Accepts("html")) == 0 { diff --git a/core/http/static/chat.js b/core/http/static/chat.js index db5c884e2..3de1e0724 100644 --- a/core/http/static/chat.js +++ b/core/http/static/chat.js @@ -48,6 +48,24 @@ function submitSystemPrompt(event) { document.getElementById("systemPrompt").blur(); } +function handleShutdownResponse(event, modelName) { + // Check if the request was successful + if (event.detail.successful) { + // Show a success message (optional) + console.log(`Model ${modelName} stopped successfully`); + + // Refresh the page to update the UI + window.location.reload(); + } else { + // Show an error message (optional) + console.error(`Failed to stop model ${modelName}`); + + // You could also show a user-friendly error message here + // For now, we'll still refresh to show the current state + window.location.reload(); + } +} + var images = []; var audios = []; var fileContents = []; diff --git a/core/http/views/backends.html b/core/http/views/backends.html index 23f7d43de..25d7535cb 100644 --- a/core/http/views/backends.html +++ b/core/http/views/backends.html @@ -2,7 +2,7 @@ {{template "views/partials/head" .}} -
+- {{.AvailableBackends}} backends available - - - +
+ Discover and install AI backends to power your models
+The FOSS alternative to OpenAI, Claude, and more
+The powerful FOSS alternative to OpenAI, Claude, and more
+Get started by installing models from the gallery or check our documentation for guidance
+ + -Install models from the 🖼️ Gallery or check the Getting started documentation
{{ if ne (len .Models) 0 }} -These models were found but don't have configuration files yet
{{if .Name}}{{.Name}}{{else}}{{.}}{{end}}
+{{if .Name}}{{.Name}}{{else}}{{.}}{{end}}
+No configuration
++ {{len .InstalledBackends}} backend{{if gt (len .InstalledBackends) 1}}s{{end}} ready to use +
+Get started by installing backends from the gallery or check our documentation for guidance
+Configure your model settings using the form or YAML editor
-Configure your model settings using the form or YAML editor
+