feat: add upstreamModel config for model name mapping
CI / CI (pull_request) Successful in 3m10s

When the upstream LLM server expects a different model name than what
clients send, the gateway now rewrites the 'model' field in the request
body before forwarding.

Config example:
  models:
  - name: "ornith:35b"           # client-facing name
    address: "ornith-predictor:80"
    upstreamModel: "qwen2.5:72b"  # what upstream expects

Fixes 400 'model is required' errors when upstream model names differ.
This commit is contained in:
Admin Bot
2026-09-15 09:52:55 +09:00
parent 509cb39521
commit d16597ca0b
4 changed files with 91 additions and 8 deletions
+10 -8
View File
@@ -37,10 +37,11 @@ type rawRoute struct {
// rawModel represents a single model entry in the YAML configuration.
type rawModel struct {
Name string `yaml:"name"`
Address string `yaml:"address"`
Path string `yaml:"path"`
AuthRequired *bool `yaml:"authRequired"`
Name string `yaml:"name"`
Address string `yaml:"address"`
Path string `yaml:"path"`
UpstreamModel string `yaml:"upstreamModel"`
AuthRequired *bool `yaml:"authRequired"`
}
// rawAdapter represents a service adapter in the YAML configuration.
@@ -132,10 +133,11 @@ func LoadRoutesAndModelsFromFile(path string) (map[string]*Route, map[string]*Mo
authRequired = *rawModel.AuthRequired
}
models[rawModel.Name] = &ModelUpstream{
Name: rawModel.Name,
Address: rawModel.Address,
Path: rawModel.Path,
AuthRequired: authRequired,
Name: rawModel.Name,
Address: rawModel.Address,
Path: rawModel.Path,
UpstreamModel: rawModel.UpstreamModel,
AuthRequired: authRequired,
}
}