-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
b57f399
feat: Add backend gallery
mudler 5226227
Add backends docs
mudler 3099afb
wip: Backend Dockerfile for python backends
mudler 2ba3899
feat: drop extras images, build python backends separately
mudler eb5707c
fixup on all backends
mudler 9bd1478
test CI
mudler 389d4e2
Tweaks
mudler ee692be
Drop old backends leftovers
mudler c07c577
Fixup CI
mudler 6d96f00
Move dockerfile upper
mudler 6b90ef5
Fix proto
mudler 97d3176
Feature dropped for consistency - we prefer model galleries
mudler 06234d6
Merge branch 'master' into feat/backend_gallery
mudler 4493bc4
Add missing packages in the build image
mudler 98573b4
exllama is ponly available on cublas
mudler 06628f8
pin torch on chatterbox
mudler 427bbf4
Fixups to index
mudler c36deef
CI
mudler 1a924b2
Debug CI
mudler 5751d2e
Install accellerators deps
mudler 7402a4e
Add target arch
mudler 28f90e5
Add cuda minor version
mudler 5e83023
Use self-hosted runners
mudler ed39960
ci: use quay for test images
mudler 1545d31
fixups for vllm and chatterbox
mudler a427c7a
Small fixups on CI
mudler 7da886d
chatterbox is only available for nvidia
mudler 1699c96
Simplify CI builds
mudler 3b63a71
Adapt test, use qwen3
mudler 5d1241d
Merge branch 'master' into feat/backend_gallery
mudler ff820f8
chore(model gallery): add jina-reranker-v1-tiny-en-gguf
mudler 211891c
fix(gguf-parser): recover from potential panics that can happen while…
mudler ad05b49
Use reranker from llama.cpp in AIO images
mudler f12e009
Limit concurrent jobs
mudler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package gallery | ||
|
||
import "github.com/mudler/LocalAI/core/config" | ||
|
||
type GalleryBackend struct { | ||
Metadata `json:",inline" yaml:",inline"` | ||
Alias string `json:"alias,omitempty" yaml:"alias,omitempty"` | ||
URI string `json:"uri,omitempty" yaml:"uri,omitempty"` | ||
} | ||
|
||
type GalleryBackends []*GalleryBackend | ||
|
||
func (m *GalleryBackend) SetGallery(gallery config.Gallery) { | ||
m.Gallery = gallery | ||
} | ||
|
||
func (m *GalleryBackend) SetInstalled(installed bool) { | ||
m.Installed = installed | ||
} | ||
|
||
func (m *GalleryBackend) GetName() string { | ||
return m.Name | ||
} | ||
|
||
func (m *GalleryBackend) GetGallery() config.Gallery { | ||
return m.Gallery | ||
} | ||
|
||
func (m *GalleryBackend) GetDescription() string { | ||
return m.Description | ||
} | ||
|
||
func (m *GalleryBackend) GetTags() []string { | ||
return m.Tags | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package gallery | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/mudler/LocalAI/core/config" | ||
"github.com/mudler/LocalAI/pkg/model" | ||
"github.com/mudler/LocalAI/pkg/oci" | ||
) | ||
|
||
// Installs a model from the gallery | ||
func InstallBackendFromGallery(galleries []config.Gallery, name string, basePath string, downloadStatus func(string, string, string, float64)) error { | ||
backends, err := AvailableBackends(galleries, basePath) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
backend := FindGalleryElement(backends, name, basePath) | ||
if backend == nil { | ||
return fmt.Errorf("no model found with name %q", name) | ||
} | ||
|
||
return InstallBackend(basePath, backend, downloadStatus) | ||
} | ||
|
||
func InstallBackend(basePath string, config *GalleryBackend, downloadStatus func(string, string, string, float64)) error { | ||
// Create base path if it doesn't exist | ||
err := os.MkdirAll(basePath, 0750) | ||
if err != nil { | ||
return fmt.Errorf("failed to create base path: %v", err) | ||
} | ||
|
||
name := config.Name | ||
|
||
img, err := oci.GetImage(config.URI, "", nil, nil) | ||
if err != nil { | ||
return fmt.Errorf("failed to get image %q: %v", config.URI, err) | ||
} | ||
|
||
backendPath := filepath.Join(basePath, name) | ||
if err := os.MkdirAll(backendPath, 0750); err != nil { | ||
return fmt.Errorf("failed to create backend path %q: %v", backendPath, err) | ||
} | ||
|
||
if err := oci.ExtractOCIImage(img, backendPath); err != nil { | ||
return fmt.Errorf("failed to extract image %q: %v", config.URI, err) | ||
} | ||
|
||
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 failureCode scanning / gosec Expect WriteFile permissions to be 0600 or less Error
Expect WriteFile permissions to be 0600 or less
|
||
return fmt.Errorf("failed to write alias file %q: %v", aliasFile, err) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func DeleteBackendFromSystem(basePath string, name string) error { | ||
backendFile := filepath.Join(basePath, name) | ||
|
||
return os.RemoveAll(backendFile) | ||
} | ||
|
||
func ListSystemBackends(basePath string) (map[string]string, error) { | ||
backends, err := os.ReadDir(basePath) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
backendsNames := make(map[string]string) | ||
|
||
for _, backend := range backends { | ||
if backend.IsDir() { | ||
runFile := filepath.Join(basePath, backend.Name(), "run.sh") | ||
backendsNames[backend.Name()] = runFile | ||
|
||
aliasFile := filepath.Join(basePath, backend.Name(), "alias") | ||
if _, err := os.Stat(aliasFile); err == nil { | ||
// read the alias file, and use it as key | ||
alias, err := os.ReadFile(aliasFile) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
backendsNames[string(alias)] = runFile | ||
} | ||
} | ||
} | ||
|
||
return backendsNames, nil | ||
} | ||
|
||
func RegisterBackends(basePath string, modelLoader *model.ModelLoader) error { | ||
backends, err := ListSystemBackends(basePath) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for name, runFile := range backends { | ||
modelLoader.SetExternalBackend(name, runFile) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / gosec
Errors unhandled Warning