Skip to content

feat: Add backend gallery #5607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Jun 15, 2025
Merged

feat: Add backend gallery #5607

merged 34 commits into from
Jun 15, 2025

Conversation

mudler
Copy link
Owner

@mudler mudler commented Jun 9, 2025

Description

This PR add support to manage backends as similar to models. There is now available a backend gallery which can be used to install and remove extra backends. The backend gallery can be configured similarly as a model gallery, and
API calls allows to install and remove new backends in runtime, and as well during the startup phase of LocalAI.

Users are encouraged, as with models, to create their own backend galleries. Backends are just standard OCI images which have packed all the bits to run a backend. Documentation is provided too.

Users can specify the path of backends with --backends-path or by using the LOCALAI_BACKENDS_PATH environment variable. --external-backends or LOCALAI_EXTERNAL_BACKENDS can be set to a list of backends to load automatically on start. Finally, LOCALAI_BACKEND_GALLERIES or --backend-galleries can be a json list of backend galleries, for example default is [{"name":"localai", "url":"github:mudler/LocalAI/backend/index.yaml@master"}].

Fixes #3953

Screenshot From 2025-06-11 18-39-16

Notes for Reviewers

Not-exhaustive list of related tickets of backends that can be now implemented completely separately (yay!):

#5519
#1126
#5447
#5215
#4168

Signed commits

  • Yes, I signed my commits.

Copy link

netlify bot commented Jun 9, 2025

Deploy Preview for localai ready!

Name Link
🔨 Latest commit f12e009
🔍 Latest deploy log https://app.netlify.com/projects/localai/deploys/684e828ecc31a000086c091d
😎 Deploy Preview https://deploy-preview-5607--localai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

models, err := AvailableGalleryModels(galleries, basePath)
func ReadConfigFile[T any](filePath string) (*T, error) {
// Read the YAML file
yamlFile, err := os.ReadFile(filePath)

Check failure

Code scanning / gosec

Potential file inclusion via variable Error

Potential file inclusion via variable
@mudler mudler force-pushed the feat/backend_gallery branch from 49199b6 to f18108c Compare June 10, 2025 17:39
if config.Alias != "" {
// Write an alias file inside
aliasFile := filepath.Join(backendPath, "alias")
if err := os.WriteFile(aliasFile, []byte(config.Alias), 0644); err != nil {

Check failure

Code scanning / gosec

Expect WriteFile permissions to be 0600 or less Error

Expect WriteFile permissions to be 0600 or less
This PR add support to manage backends as similar to models. There is
now available a backend gallery which can be used to install and remove
extra backends.
The backend gallery can be configured similarly as a model gallery, and
API calls allows to install and remove new backends in runtime, and as
well during the startup phase of LocalAI.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler mudler force-pushed the feat/backend_gallery branch from fe47de8 to b57f399 Compare June 11, 2025 17:29
@mudler mudler changed the title wip: backend gallery feat: Add backend gallery Jun 11, 2025
@@ -73,11 +76,15 @@
}

func (r *RunCMD) Run(ctx *cliContext.Context) error {
os.MkdirAll(r.BackendsPath, 0750)

Check warning

Code scanning / gosec

Errors unhandled Warning

Errors unhandled
@@ -73,11 +76,15 @@
}

func (r *RunCMD) Run(ctx *cliContext.Context) error {
os.MkdirAll(r.BackendsPath, 0750)
os.MkdirAll(r.ModelsPath, 0750)

Check warning

Code scanning / gosec

Errors unhandled Warning

Errors unhandled
"Title": "LocalAI - Backends",
"BaseURL": utils.BaseURL(c),
"Version": internal.PrintableVersion(),
"Backends": template.HTML(elements.ListBackends(backends, opcache, galleryService)),

Check failure

Code scanning / gosec

The used method does not auto-escape HTML. This can potentially lead to 'Cross-site Scripting' vulnerabilities, in case the attacker controls the input. Error

The used method does not auto-escape HTML. This can potentially lead to 'Cross-site Scripting' vulnerabilities, in case the attacker controls the input.
summary["NextPage"] = nextPage
summary["TotalPages"] = totalPages
summary["CurrentPage"] = pageNum
summary["Backends"] = template.HTML(elements.ListBackends(backends, opcache, galleryService))

Check failure

Code scanning / gosec

The used method does not auto-escape HTML. This can potentially lead to 'Cross-site Scripting' vulnerabilities, in case the attacker controls the input. Error

The used method does not auto-escape HTML. This can potentially lead to 'Cross-site Scripting' vulnerabilities, in case the attacker controls the input.
"Title": "LocalAI - Models",
"BaseURL": utils.BaseURL(c),
"Version": internal.PrintableVersion(),
"Models": template.HTML(elements.ListModels(models, opcache, galleryService)),

Check failure

Code scanning / gosec

The used method does not auto-escape HTML. This can potentially lead to 'Cross-site Scripting' vulnerabilities, in case the attacker controls the input. Error

The used method does not auto-escape HTML. This can potentially lead to 'Cross-site Scripting' vulnerabilities, in case the attacker controls the input.
summary["NextPage"] = nextPage
summary["TotalPages"] = totalPages
summary["CurrentPage"] = pageNum
summary["Models"] = template.HTML(elements.ListModels(models, opcache, galleryService))

Check failure

Code scanning / gosec

The used method does not auto-escape HTML. This can potentially lead to 'Cross-site Scripting' vulnerabilities, in case the attacker controls the input. Error

The used method does not auto-escape HTML. This can potentially lead to 'Cross-site Scripting' vulnerabilities, in case the attacker controls the input.
}

func ApplyGalleryFromFile(modelPath, s string, enforceScan bool, galleries []config.Gallery) error {
dat, err := os.ReadFile(s)

Check failure

Code scanning / gosec

Potential file inclusion via variable Error

Potential file inclusion via variable
@mudler mudler added enhancement New feature or request breaking-change labels Jun 11, 2025
mudler added 2 commits June 11, 2025 19:44
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler mudler force-pushed the feat/backend_gallery branch from 11968f3 to 672f467 Compare June 12, 2025 16:46
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler mudler force-pushed the feat/backend_gallery branch from 672f467 to 2ba3899 Compare June 12, 2025 16:47
mudler added 4 commits June 12, 2025 18:50
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@github-actions github-actions bot added the ci label Jun 12, 2025
mudler and others added 9 commits June 12, 2025 23:13
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
mudler added 7 commits June 13, 2025 22:15
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler mudler force-pushed the feat/backend_gallery branch from 8666e76 to ed39960 Compare June 14, 2025 08:58
mudler added 4 commits June 14, 2025 16:05
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler mudler force-pushed the feat/backend_gallery branch from ef1e957 to 1699c96 Compare June 14, 2025 15:31
mudler and others added 5 commits June 14, 2025 18:49
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
… reading ggufs with gguf-parser

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler mudler marked this pull request as ready for review June 15, 2025 10:15
@mudler mudler merged commit 2d64269 into master Jun 15, 2025
71 of 77 checks passed
@mudler mudler deleted the feat/backend_gallery branch June 15, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Install backends from WebUI
1 participant