From 773b13321cb9123b39d2da041210fde432c01b07 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Wed, 26 Feb 2025 11:58:50 +0100 Subject: [PATCH] feat(ui): show more informations in the chat view, minor adjustments to model gallery Signed-off-by: Ettore Di Giacinto --- core/gallery/gallery.go | 2 + core/http/routes/ui.go | 21 ++++++++++ core/http/views/chat.html | 80 +++++++++++++++++++++++++++++++++---- core/http/views/models.html | 11 +++-- 4 files changed, 103 insertions(+), 11 deletions(-) diff --git a/core/gallery/gallery.go b/core/gallery/gallery.go index a3a1d909..0c540052 100644 --- a/core/gallery/gallery.go +++ b/core/gallery/gallery.go @@ -29,6 +29,8 @@ func InstallModelFromGallery(galleries []config.Gallery, name string, basePath s if err != nil { return err } + config.Description = model.Description + config.License = model.License } else if len(model.ConfigFile) > 0 { // TODO: is this worse than using the override method with a blank cfg yaml? reYamlConfig, err := yaml.Marshal(model.ConfigFile) diff --git a/core/http/routes/ui.go b/core/http/routes/ui.go index 40919a83..65d1b09c 100644 --- a/core/http/routes/ui.go +++ b/core/http/routes/ui.go @@ -404,6 +404,15 @@ func RegisterUIRoutes(app *fiber.App, return c.Redirect(utils.BaseURL(c)) } modelThatCanBeUsed := "" + 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 + } title := "LocalAI - Chat" @@ -419,6 +428,7 @@ func RegisterUIRoutes(app *fiber.App, "Title": title, "BaseURL": utils.BaseURL(c), "ModelsWithoutConfig": modelsWithoutConfig, + "GalleryConfig": galleryConfigs, "ModelsConfig": backendConfigs, "Model": modelThatCanBeUsed, "Version": internal.PrintableVersion(), @@ -434,10 +444,21 @@ func RegisterUIRoutes(app *fiber.App, backendConfigs := cl.GetAllBackendConfigs() modelsWithoutConfig, _ := services.ListModels(cl, ml, config.NoFilterFn, services.LOOSE_ONLY) + 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 + } + summary := fiber.Map{ "Title": "LocalAI - Chat with " + c.Params("model"), "BaseURL": utils.BaseURL(c), "ModelsConfig": backendConfigs, + "GalleryConfig": galleryConfigs, "ModelsWithoutConfig": modelsWithoutConfig, "Model": c.Params("model"), "Version": internal.PrintableVersion(), diff --git a/core/http/views/chat.html b/core/http/views/chat.html index 71e9b8d6..c3e30402 100644 --- a/core/http/views/chat.html +++ b/core/http/views/chat.html @@ -29,7 +29,8 @@ SOFTWARE. {{template "views/partials/head" .}} - + {{ $allGalleryConfigs:=.GalleryConfig }} + {{ $model:=.Model}} {{template "views/partials/navbar" .}} @@ -42,14 +43,64 @@ SOFTWARE.

+ {{ if $model }} + {{ $galleryConfig:= index $allGalleryConfigs $model}} + + + + + + + {{ end }} Chat {{ if .Model }} with {{.Model}} {{ end }} - - - +

@@ -124,7 +178,7 @@ SOFTWARE. class="bg-gray-800 text-white border border-gray-600 focus:border-blue-500 focus:ring focus:ring-blue-500 focus:ring-opacity-50 rounded-md shadow-sm p-2 appearance-none" > - {{ $model:=.Model}} + {{ range .ModelsConfig }} {{ $cfg := . }} {{ range .KnownUsecaseStrings }} @@ -162,10 +216,22 @@ SOFTWARE.