mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 12:20:52 +08:00
feat: merge per-account excluded_models with global config
This commit is contained in:
@@ -53,6 +53,8 @@ func (g *StableIDGenerator) Next(kind string, parts ...string) (string, string)
|
|||||||
|
|
||||||
// ApplyAuthExcludedModelsMeta applies excluded models metadata to an auth entry.
|
// ApplyAuthExcludedModelsMeta applies excluded models metadata to an auth entry.
|
||||||
// It computes a hash of excluded models and sets the auth_kind attribute.
|
// It computes a hash of excluded models and sets the auth_kind attribute.
|
||||||
|
// For OAuth entries, perKey (from the JSON file's excluded-models field) is merged
|
||||||
|
// with the global oauth-excluded-models config for the provider.
|
||||||
func ApplyAuthExcludedModelsMeta(auth *coreauth.Auth, cfg *config.Config, perKey []string, authKind string) {
|
func ApplyAuthExcludedModelsMeta(auth *coreauth.Auth, cfg *config.Config, perKey []string, authKind string) {
|
||||||
if auth == nil || cfg == nil {
|
if auth == nil || cfg == nil {
|
||||||
return
|
return
|
||||||
@@ -72,10 +74,14 @@ func ApplyAuthExcludedModelsMeta(auth *coreauth.Auth, cfg *config.Config, perKey
|
|||||||
}
|
}
|
||||||
if authKindKey == "apikey" {
|
if authKindKey == "apikey" {
|
||||||
add(perKey)
|
add(perKey)
|
||||||
} else if cfg.OAuthExcludedModels != nil {
|
} else {
|
||||||
|
// For OAuth: merge per-account excluded models with global provider-level exclusions
|
||||||
|
add(perKey)
|
||||||
|
if cfg.OAuthExcludedModels != nil {
|
||||||
providerKey := strings.ToLower(strings.TrimSpace(auth.Provider))
|
providerKey := strings.ToLower(strings.TrimSpace(auth.Provider))
|
||||||
add(cfg.OAuthExcludedModels[providerKey])
|
add(cfg.OAuthExcludedModels[providerKey])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
combined := make([]string, 0, len(seen))
|
combined := make([]string, 0, len(seen))
|
||||||
for k := range seen {
|
for k := range seen {
|
||||||
combined = append(combined, k)
|
combined = append(combined, k)
|
||||||
@@ -88,6 +94,10 @@ func ApplyAuthExcludedModelsMeta(auth *coreauth.Auth, cfg *config.Config, perKey
|
|||||||
if hash != "" {
|
if hash != "" {
|
||||||
auth.Attributes["excluded_models_hash"] = hash
|
auth.Attributes["excluded_models_hash"] = hash
|
||||||
}
|
}
|
||||||
|
// Store the combined excluded models list so that routing can read it at runtime
|
||||||
|
if len(combined) > 0 {
|
||||||
|
auth.Attributes["excluded_models"] = strings.Join(combined, ",")
|
||||||
|
}
|
||||||
if authKind != "" {
|
if authKind != "" {
|
||||||
auth.Attributes["auth_kind"] = authKind
|
auth.Attributes["auth_kind"] = authKind
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user