mirror of
https://github.com/mudler/LocalAI.git
synced 2026-10-28 09:08:54 -04:00
refactor(stores): resolve the store backend and its loader slot explicitly
Store loading picked the backend and the loader's process slot in one function, which let an explicit `backend` argument collide with the store's own config and made traces report a fixed "local-store". This changes /stores/* behaviour for every store: - An explicit `backend` that differs from the one named in the store's model config now gets its own loader slot, `<store>@<backend>`, so it no longer reuses (or evicts) the process of the configured backend. Naming the configured backend, or one of its aliases, keeps the store's own slot. - When the config names a different backend than the explicit one, the config's `options` are not passed on, since they are meant for the configured backend. A config without `backend:` still passes its options to the explicit backend. - Backend names are compared and reported in canonical form (aliases resolved, lower case) through the new model.CanonicalBackend, and traces record the backend that was actually used instead of always "local-store". Backend loading itself uses CanonicalBackend for alias handling; type aliases keep their existing effect. Signed-off-by: Anush008 <mail@anush.sh> Assisted-by: Claude Code:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
1 parent
5aabc5891f
commit
dee4d8a399
3 files changed
+164
-51
No files matched your search
+11
-11
@@ -37,6 +37,14 @@ var Aliases = map[string]string{
|
||||
"stablediffusion": StableDiffusionGGMLBackend,
|
||||
}
|
||||
|
||||
func CanonicalBackend(name string) string {
|
||||
b := strings.ToLower(name)
|
||||
if real, ok := Aliases[b]; ok {
|
||||
return real
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
var TypeAlias = map[string]string{
|
||||
"sentencetransformers": "SentenceTransformer",
|
||||
"huggingface-embeddings": "SentenceTransformer",
|
||||
@@ -337,17 +345,9 @@ func (ml *ModelLoader) backendLoader(opts ...Option) (client grpc.Backend, err e
|
||||
"f16", opt.F16Memory)
|
||||
}
|
||||
|
||||
backend := strings.ToLower(o.backendString)
|
||||
if realBackend, exists := Aliases[backend]; exists {
|
||||
typeAlias, exists := TypeAlias[backend]
|
||||
if exists {
|
||||
xlog.Debug("alias is a type alias", "alias", backend, "realBackend", realBackend, "type", typeAlias)
|
||||
o.gRPCOptions.Type = typeAlias
|
||||
} else {
|
||||
xlog.Debug("alias", "alias", backend, "realBackend", realBackend)
|
||||
}
|
||||
|
||||
backend = realBackend
|
||||
backend := CanonicalBackend(o.backendString)
|
||||
if typeAlias, ok := TypeAlias[strings.ToLower(o.backendString)]; ok {
|
||||
o.gRPCOptions.Type = typeAlias
|
||||
}
|
||||
|
||||
modelFileName := o.modelFile
|
||||
|
||||
Reference in new issue
Block a user