feat(ui): generate avatars (#80)

* feat(ui): generate avatars

Signed-off-by: mudler <mudler@localai.io>

* Show a placeholder if the image is not ready

Signed-off-by: mudler <mudler@localai.io>

* feat(avatar): generate prompt first

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

---------

Signed-off-by: mudler <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2025-03-22 20:50:31 +01:00
committed by GitHub
parent c1ac7b675a
commit 3a921f6241
5 changed files with 168 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import (
"errors"
"math/rand"
"net/http"
"path/filepath"
"github.com/dave-gray101/v2keyauth"
fiber "github.com/gofiber/fiber/v2"
@@ -26,6 +27,13 @@ var embeddedFiles embed.FS
func (app *App) registerRoutes(pool *state.AgentPool, webapp *fiber.App) {
// Static avatars in a.pooldir/avatars
webapp.Use("/avatars", filesystem.New(filesystem.Config{
Root: http.Dir(filepath.Join(app.config.StateDir, "avatars")),
// PathPrefix: "avatars",
Browse: true,
}))
webapp.Use("/public", filesystem.New(filesystem.Config{
Root: http.FS(embeddedFiles),
PathPrefix: "public",
@@ -145,6 +153,7 @@ func (app *App) registerRoutes(pool *state.AgentPool, webapp *fiber.App) {
webapp.Post("/settings/import", app.ImportAgent(pool))
webapp.Get("/settings/export/:name", app.ExportAgent(pool))
}
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")