Skip to content

Commit c87870b

Browse files
authored
feat(ui): improve chat interface (mudler#4910)
* feat(ui): show more informations in the chat view, minor adjustments to model gallery Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(ui): UI improvements Visual improvements and bugfixes including: - disable pagination during search - fix scrolling on new message Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 5ad2be9 commit c87870b

File tree

5 files changed

+410
-193
lines changed

5 files changed

+410
-193
lines changed

core/gallery/gallery.go

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ func InstallModelFromGallery(galleries []config.Gallery, name string, basePath s
2929
if err != nil {
3030
return err
3131
}
32+
config.Description = model.Description
33+
config.License = model.License
3234
} else if len(model.ConfigFile) > 0 {
3335
// TODO: is this worse than using the override method with a blank cfg yaml?
3436
reYamlConfig, err := yaml.Marshal(model.ConfigFile)

core/http/routes/ui.go

+21
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,15 @@ func RegisterUIRoutes(app *fiber.App,
404404
return c.Redirect(utils.BaseURL(c))
405405
}
406406
modelThatCanBeUsed := ""
407+
galleryConfigs := map[string]*gallery.Config{}
408+
409+
for _, m := range backendConfigs {
410+
cfg, err := gallery.GetLocalModelConfiguration(ml.ModelPath, m.Name)
411+
if err != nil {
412+
continue
413+
}
414+
galleryConfigs[m.Name] = cfg
415+
}
407416

408417
title := "LocalAI - Chat"
409418

@@ -419,6 +428,7 @@ func RegisterUIRoutes(app *fiber.App,
419428
"Title": title,
420429
"BaseURL": utils.BaseURL(c),
421430
"ModelsWithoutConfig": modelsWithoutConfig,
431+
"GalleryConfig": galleryConfigs,
422432
"ModelsConfig": backendConfigs,
423433
"Model": modelThatCanBeUsed,
424434
"Version": internal.PrintableVersion(),
@@ -434,10 +444,21 @@ func RegisterUIRoutes(app *fiber.App,
434444
backendConfigs := cl.GetAllBackendConfigs()
435445
modelsWithoutConfig, _ := services.ListModels(cl, ml, config.NoFilterFn, services.LOOSE_ONLY)
436446

447+
galleryConfigs := map[string]*gallery.Config{}
448+
449+
for _, m := range backendConfigs {
450+
cfg, err := gallery.GetLocalModelConfiguration(ml.ModelPath, m.Name)
451+
if err != nil {
452+
continue
453+
}
454+
galleryConfigs[m.Name] = cfg
455+
}
456+
437457
summary := fiber.Map{
438458
"Title": "LocalAI - Chat with " + c.Params("model"),
439459
"BaseURL": utils.BaseURL(c),
440460
"ModelsConfig": backendConfigs,
461+
"GalleryConfig": galleryConfigs,
441462
"ModelsWithoutConfig": modelsWithoutConfig,
442463
"Model": c.Params("model"),
443464
"Version": internal.PrintableVersion(),

core/http/static/chat.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function submitPrompt(event) {
4949
document.getElementById("input").value = "";
5050
const key = localStorage.getItem("key");
5151
const systemPrompt = localStorage.getItem("system_prompt");
52-
52+
Alpine.nextTick(() => { document.getElementById('messages').scrollIntoView(false); });
5353
promptGPT(systemPrompt, key, input);
5454
}
5555

@@ -74,7 +74,6 @@ function readInputImage() {
7474
// Make the "loader" visible
7575
document.getElementById("loader").style.display = "block";
7676
document.getElementById("input").disabled = true;
77-
document.getElementById('messages').scrollIntoView(false)
7877

7978
messages = Alpine.store("chat").messages();
8079

@@ -181,8 +180,8 @@ function readInputImage() {
181180
const chatStore = Alpine.store("chat");
182181
chatStore.add("assistant", token);
183182
// Efficiently scroll into view without triggering multiple reflows
184-
const messages = document.getElementById('messages');
185-
messages.scrollTop = messages.scrollHeight;
183+
// const messages = document.getElementById('messages');
184+
// messages.scrollTop = messages.scrollHeight;
186185
};
187186

188187
let buffer = "";

0 commit comments

Comments
 (0)