mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-29 15:04:59 +00:00
feat(ui): allow to select between all the available models in the chat (#2657)
feat(ui): let the chat to select from all the detected models Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
5d83c8d3a2
commit
59af0e77af
3 changed files with 11 additions and 10 deletions
|
@ -26,6 +26,7 @@ func RegisterUIRoutes(app *fiber.App,
|
||||||
appConfig *config.ApplicationConfig,
|
appConfig *config.ApplicationConfig,
|
||||||
galleryService *services.GalleryService,
|
galleryService *services.GalleryService,
|
||||||
auth func(*fiber.Ctx) error) {
|
auth func(*fiber.Ctx) error) {
|
||||||
|
tmpLMS := services.NewListModelsService(ml, cl, appConfig) // TODO: once createApplication() is fully in use, reference the central instance.
|
||||||
|
|
||||||
// keeps the state of models that are being installed from the UI
|
// keeps the state of models that are being installed from the UI
|
||||||
var processingModels = xsync.NewSyncedMap[string, string]()
|
var processingModels = xsync.NewSyncedMap[string, string]()
|
||||||
|
@ -235,7 +236,7 @@ func RegisterUIRoutes(app *fiber.App,
|
||||||
|
|
||||||
// Show the Chat page
|
// Show the Chat page
|
||||||
app.Get("/chat/:model", auth, func(c *fiber.Ctx) error {
|
app.Get("/chat/:model", auth, func(c *fiber.Ctx) error {
|
||||||
backendConfigs := cl.GetAllBackendConfigs()
|
backendConfigs, _ := tmpLMS.ListModels("", true)
|
||||||
|
|
||||||
summary := fiber.Map{
|
summary := fiber.Map{
|
||||||
"Title": "LocalAI - Chat with " + c.Params("model"),
|
"Title": "LocalAI - Chat with " + c.Params("model"),
|
||||||
|
@ -249,7 +250,7 @@ func RegisterUIRoutes(app *fiber.App,
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Get("/talk/", auth, func(c *fiber.Ctx) error {
|
app.Get("/talk/", auth, func(c *fiber.Ctx) error {
|
||||||
backendConfigs := cl.GetAllBackendConfigs()
|
backendConfigs, _ := tmpLMS.ListModels("", true)
|
||||||
|
|
||||||
if len(backendConfigs) == 0 {
|
if len(backendConfigs) == 0 {
|
||||||
// If no model is available redirect to the index which suggests how to install models
|
// If no model is available redirect to the index which suggests how to install models
|
||||||
|
@ -259,7 +260,7 @@ func RegisterUIRoutes(app *fiber.App,
|
||||||
summary := fiber.Map{
|
summary := fiber.Map{
|
||||||
"Title": "LocalAI - Talk",
|
"Title": "LocalAI - Talk",
|
||||||
"ModelsConfig": backendConfigs,
|
"ModelsConfig": backendConfigs,
|
||||||
"Model": backendConfigs[0].Name,
|
"Model": backendConfigs[0].ID,
|
||||||
"Version": internal.PrintableVersion(),
|
"Version": internal.PrintableVersion(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +270,7 @@ func RegisterUIRoutes(app *fiber.App,
|
||||||
|
|
||||||
app.Get("/chat/", auth, func(c *fiber.Ctx) error {
|
app.Get("/chat/", auth, func(c *fiber.Ctx) error {
|
||||||
|
|
||||||
backendConfigs := cl.GetAllBackendConfigs()
|
backendConfigs, _ := tmpLMS.ListModels("", true)
|
||||||
|
|
||||||
if len(backendConfigs) == 0 {
|
if len(backendConfigs) == 0 {
|
||||||
// If no model is available redirect to the index which suggests how to install models
|
// If no model is available redirect to the index which suggests how to install models
|
||||||
|
@ -277,9 +278,9 @@ func RegisterUIRoutes(app *fiber.App,
|
||||||
}
|
}
|
||||||
|
|
||||||
summary := fiber.Map{
|
summary := fiber.Map{
|
||||||
"Title": "LocalAI - Chat with " + backendConfigs[0].Name,
|
"Title": "LocalAI - Chat with " + backendConfigs[0].ID,
|
||||||
"ModelsConfig": backendConfigs,
|
"ModelsConfig": backendConfigs,
|
||||||
"Model": backendConfigs[0].Name,
|
"Model": backendConfigs[0].ID,
|
||||||
"Version": internal.PrintableVersion(),
|
"Version": internal.PrintableVersion(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,10 +100,10 @@ SOFTWARE.
|
||||||
<option value="" disabled class="text-gray-400" >Select a model</option>
|
<option value="" disabled class="text-gray-400" >Select a model</option>
|
||||||
{{ $model:=.Model}}
|
{{ $model:=.Model}}
|
||||||
{{ range .ModelsConfig }}
|
{{ range .ModelsConfig }}
|
||||||
{{ if eq .Name $model }}
|
{{ if eq .ID $model }}
|
||||||
<option value="/chat/{{.Name}}" selected class="bg-gray-700 text-white">{{.Name}}</option>
|
<option value="/chat/{{.ID}}" selected class="bg-gray-700 text-white">{{.ID}}</option>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<option value="/chat/{{.Name}}" class="bg-gray-700 text-white">{{.Name}}</option>
|
<option value="/chat/{{.ID}}" class="bg-gray-700 text-white">{{.ID}}</option>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
<option value="" disabled class="text-gray-400" >Select a model</option>
|
<option value="" disabled class="text-gray-400" >Select a model</option>
|
||||||
|
|
||||||
{{ range .ModelsConfig }}
|
{{ range .ModelsConfig }}
|
||||||
<option value="{{.Name}}" class="bg-gray-700 text-white">{{.Name}}</option>
|
<option value="{{.ID}}" class="bg-gray-700 text-white">{{.ID}}</option>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue