mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-29 17:44:30 -04:00
fix(failover): send remote targets their own upstream model
A chain request reached a cloud-proxy target with the client's model, the chain name, whenever the target set no upstream_model: passthrough forwards the body's model and translate falls back to it. The upstream answered 404, which neither retries nor trips, while the liveness probe, which checks the target's own name, kept passing. PrepareTarget now sets the upstream model of a remote target to proxy.upstream_model or the target name, the same name the probe uses. The request pipeline and realtime chain stages both call it. Assisted-by: Claude:claude-opus-5-5
This commit is contained in:
1 parent
d1a59aae41
commit
e183ea11d1
8 files changed
+98
-7
No files matched your search
@@ -85,6 +85,17 @@ func UpstreamModel(cfg config.ModelConfig) string {
|
||||
return cfg.Name
|
||||
}
|
||||
|
||||
// PrepareTarget readies a copy of a target's config to serve a chain request.
|
||||
// A remote target gets its upstream model set explicitly: left empty,
|
||||
// passthrough forwards the client's "model" (the chain name) and translate
|
||||
// falls back to it, so the upstream would answer 404 for a model the liveness
|
||||
// probe (which checks UpstreamModel) just found.
|
||||
func PrepareTarget(cfg *config.ModelConfig) {
|
||||
if KindOf(*cfg) == KindRemote {
|
||||
cfg.Proxy.UpstreamModel = UpstreamModel(*cfg)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *DefaultProber) authorize(req *http.Request, cfg config.ModelConfig) error {
|
||||
key, err := cfg.Proxy.ResolveAPIKey()
|
||||
if err != nil || key == "" {
|
||||
|
||||
@@ -179,3 +179,20 @@ var _ = Describe("DefaultProber", func() {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
var _ = Describe("PrepareTarget", func() {
|
||||
It("names the upstream model of a remote target the way the probe does", func() {
|
||||
plain := config.ModelConfig{Name: "argus-llm", Backend: "cloud-proxy"}
|
||||
PrepareTarget(&plain)
|
||||
Expect(plain.Proxy.UpstreamModel).To(Equal("argus-llm"))
|
||||
|
||||
mapped := config.ModelConfig{Name: "argus-llm", Backend: "cloud-proxy"}
|
||||
mapped.Proxy.UpstreamModel = "big-llm"
|
||||
PrepareTarget(&mapped)
|
||||
Expect(mapped.Proxy.UpstreamModel).To(Equal("big-llm"))
|
||||
|
||||
local := config.ModelConfig{Name: "gemma", Backend: "llama-cpp"}
|
||||
PrepareTarget(&local)
|
||||
Expect(local.Proxy.UpstreamModel).To(BeEmpty())
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user