feat: read per-account excluded_models at routing time

This commit is contained in:
RGBadmin
2026-02-11 15:21:19 +08:00
parent b93026d83a
commit 4cbcc835d1

View File

@@ -740,6 +740,26 @@ func (s *Service) registerModelsForAuth(a *coreauth.Auth) {
provider = "openai-compatibility"
}
excluded := s.oauthExcludedModels(provider, authKind)
// Merge per-account excluded models from auth attributes (set by synthesizer)
if a.Attributes != nil {
if perAccount := strings.TrimSpace(a.Attributes["excluded_models"]); perAccount != "" {
parts := strings.Split(perAccount, ",")
seen := make(map[string]struct{}, len(excluded)+len(parts))
for _, e := range excluded {
seen[strings.ToLower(strings.TrimSpace(e))] = struct{}{}
}
for _, p := range parts {
seen[strings.ToLower(strings.TrimSpace(p))] = struct{}{}
}
merged := make([]string, 0, len(seen))
for k := range seen {
if k != "" {
merged = append(merged, k)
}
}
excluded = merged
}
}
var models []*ModelInfo
switch provider {
case "gemini":