mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-19 04:40:52 +08:00
refactor: simplify per-account excluded_models merge in routing
This commit is contained in:
@@ -740,24 +740,11 @@ func (s *Service) registerModelsForAuth(a *coreauth.Auth) {
|
|||||||
provider = "openai-compatibility"
|
provider = "openai-compatibility"
|
||||||
}
|
}
|
||||||
excluded := s.oauthExcludedModels(provider, authKind)
|
excluded := s.oauthExcludedModels(provider, authKind)
|
||||||
// Merge per-account excluded models from auth attributes (set by synthesizer)
|
// The synthesizer pre-merges per-account and global exclusions into the "excluded_models" attribute.
|
||||||
|
// If this attribute is present, it represents the complete list of exclusions and overrides the global config.
|
||||||
if a.Attributes != nil {
|
if a.Attributes != nil {
|
||||||
if perAccount := strings.TrimSpace(a.Attributes["excluded_models"]); perAccount != "" {
|
if val, ok := a.Attributes["excluded_models"]; ok && strings.TrimSpace(val) != "" {
|
||||||
parts := strings.Split(perAccount, ",")
|
excluded = strings.Split(val, ",")
|
||||||
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
|
var models []*ModelInfo
|
||||||
|
|||||||
Reference in New Issue
Block a user