mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 04:10:51 +08:00
refactor(config): rename model blacklist fields to excluded models
This commit is contained in:
@@ -62,7 +62,7 @@ ws-auth: false
|
|||||||
# headers:
|
# headers:
|
||||||
# X-Custom-Header: "custom-value"
|
# X-Custom-Header: "custom-value"
|
||||||
# proxy-url: "socks5://proxy.example.com:1080"
|
# proxy-url: "socks5://proxy.example.com:1080"
|
||||||
# model-blacklist:
|
# excluded-models:
|
||||||
# - "gemini-2.0-pro-exp" # exclude specific models from this provider
|
# - "gemini-2.0-pro-exp" # exclude specific models from this provider
|
||||||
# - api-key: "AIzaSy...02"
|
# - api-key: "AIzaSy...02"
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ ws-auth: false
|
|||||||
# headers:
|
# headers:
|
||||||
# X-Custom-Header: "custom-value"
|
# X-Custom-Header: "custom-value"
|
||||||
# proxy-url: "socks5://proxy.example.com:1080" # optional: per-key proxy override
|
# proxy-url: "socks5://proxy.example.com:1080" # optional: per-key proxy override
|
||||||
# model-blacklist:
|
# excluded-models:
|
||||||
# - "gpt-5" # exclude specific models from this provider
|
# - "gpt-5" # exclude specific models from this provider
|
||||||
|
|
||||||
# Claude API keys
|
# Claude API keys
|
||||||
@@ -92,7 +92,7 @@ ws-auth: false
|
|||||||
# models:
|
# models:
|
||||||
# - name: "claude-3-5-sonnet-20241022" # upstream model name
|
# - name: "claude-3-5-sonnet-20241022" # upstream model name
|
||||||
# alias: "claude-sonnet-latest" # client alias mapped to the upstream model
|
# alias: "claude-sonnet-latest" # client alias mapped to the upstream model
|
||||||
# model-blacklist:
|
# excluded-models:
|
||||||
# - "claude-3-5-sonnet-20241022" # exclude specific models from this provider
|
# - "claude-3-5-sonnet-20241022" # exclude specific models from this provider
|
||||||
|
|
||||||
# OpenAI compatibility providers
|
# OpenAI compatibility providers
|
||||||
@@ -128,8 +128,8 @@ ws-auth: false
|
|||||||
# params: # JSON path (gjson/sjson syntax) -> value
|
# params: # JSON path (gjson/sjson syntax) -> value
|
||||||
# "reasoning.effort": "high"
|
# "reasoning.effort": "high"
|
||||||
|
|
||||||
# OAuth provider model blacklist
|
# OAuth provider excluded models
|
||||||
#oauth-model-blacklist:
|
#oauth-excluded-models:
|
||||||
# gemini-cli:
|
# gemini-cli:
|
||||||
# - "gemini-3-pro-preview"
|
# - "gemini-3-pro-preview"
|
||||||
# vertex:
|
# vertex:
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ type Config struct {
|
|||||||
// Payload defines default and override rules for provider payload parameters.
|
// Payload defines default and override rules for provider payload parameters.
|
||||||
Payload PayloadConfig `yaml:"payload" json:"payload"`
|
Payload PayloadConfig `yaml:"payload" json:"payload"`
|
||||||
|
|
||||||
// OAuthModelBlacklist defines per-provider global model blacklists applied to OAuth/file-backed auth entries.
|
// OAuthExcludedModels defines per-provider global model exclusions applied to OAuth/file-backed auth entries.
|
||||||
OAuthModelBlacklist map[string][]string `yaml:"oauth-model-blacklist,omitempty" json:"oauth-model-blacklist,omitempty"`
|
OAuthExcludedModels map[string][]string `yaml:"oauth-excluded-models,omitempty" json:"oauth-excluded-models,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TLSConfig holds HTTPS server settings.
|
// TLSConfig holds HTTPS server settings.
|
||||||
@@ -161,8 +161,8 @@ type ClaudeKey struct {
|
|||||||
// Headers optionally adds extra HTTP headers for requests sent with this key.
|
// Headers optionally adds extra HTTP headers for requests sent with this key.
|
||||||
Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
|
Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
|
||||||
|
|
||||||
// ModelBlacklist lists model IDs that should be excluded for this provider.
|
// ExcludedModels lists model IDs that should be excluded for this provider.
|
||||||
ModelBlacklist []string `yaml:"model-blacklist,omitempty" json:"model-blacklist,omitempty"`
|
ExcludedModels []string `yaml:"excluded-models,omitempty" json:"excluded-models,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClaudeModel describes a mapping between an alias and the actual upstream model name.
|
// ClaudeModel describes a mapping between an alias and the actual upstream model name.
|
||||||
@@ -190,8 +190,8 @@ type CodexKey struct {
|
|||||||
// Headers optionally adds extra HTTP headers for requests sent with this key.
|
// Headers optionally adds extra HTTP headers for requests sent with this key.
|
||||||
Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
|
Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
|
||||||
|
|
||||||
// ModelBlacklist lists model IDs that should be excluded for this provider.
|
// ExcludedModels lists model IDs that should be excluded for this provider.
|
||||||
ModelBlacklist []string `yaml:"model-blacklist,omitempty" json:"model-blacklist,omitempty"`
|
ExcludedModels []string `yaml:"excluded-models,omitempty" json:"excluded-models,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GeminiKey represents the configuration for a Gemini API key,
|
// GeminiKey represents the configuration for a Gemini API key,
|
||||||
@@ -209,8 +209,8 @@ type GeminiKey struct {
|
|||||||
// Headers optionally adds extra HTTP headers for requests sent with this key.
|
// Headers optionally adds extra HTTP headers for requests sent with this key.
|
||||||
Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
|
Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
|
||||||
|
|
||||||
// ModelBlacklist lists model IDs that should be excluded for this provider.
|
// ExcludedModels lists model IDs that should be excluded for this provider.
|
||||||
ModelBlacklist []string `yaml:"model-blacklist,omitempty" json:"model-blacklist,omitempty"`
|
ExcludedModels []string `yaml:"excluded-models,omitempty" json:"excluded-models,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenAICompatibility represents the configuration for OpenAI API compatibility
|
// OpenAICompatibility represents the configuration for OpenAI API compatibility
|
||||||
|
|||||||
@@ -509,12 +509,12 @@ func computeClaudeModelsHash(models []config.ClaudeModel) string {
|
|||||||
return hex.EncodeToString(sum[:])
|
return hex.EncodeToString(sum[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
func computeModelBlacklistHash(blacklist []string) string {
|
func computeExcludedModelsHash(excluded []string) string {
|
||||||
if len(blacklist) == 0 {
|
if len(excluded) == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
normalized := make([]string, 0, len(blacklist))
|
normalized := make([]string, 0, len(excluded))
|
||||||
for _, entry := range blacklist {
|
for _, entry := range excluded {
|
||||||
if trimmed := strings.TrimSpace(entry); trimmed != "" {
|
if trimmed := strings.TrimSpace(entry); trimmed != "" {
|
||||||
normalized = append(normalized, strings.ToLower(trimmed))
|
normalized = append(normalized, strings.ToLower(trimmed))
|
||||||
}
|
}
|
||||||
@@ -531,14 +531,14 @@ func computeModelBlacklistHash(blacklist []string) string {
|
|||||||
return hex.EncodeToString(sum[:])
|
return hex.EncodeToString(sum[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
type modelBlacklistSummary struct {
|
type excludedModelsSummary struct {
|
||||||
hash string
|
hash string
|
||||||
count int
|
count int
|
||||||
}
|
}
|
||||||
|
|
||||||
func summarizeModelBlacklist(list []string) modelBlacklistSummary {
|
func summarizeExcludedModels(list []string) excludedModelsSummary {
|
||||||
if len(list) == 0 {
|
if len(list) == 0 {
|
||||||
return modelBlacklistSummary{}
|
return excludedModelsSummary{}
|
||||||
}
|
}
|
||||||
seen := make(map[string]struct{}, len(list))
|
seen := make(map[string]struct{}, len(list))
|
||||||
normalized := make([]string, 0, len(list))
|
normalized := make([]string, 0, len(list))
|
||||||
@@ -552,30 +552,30 @@ func summarizeModelBlacklist(list []string) modelBlacklistSummary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sort.Strings(normalized)
|
sort.Strings(normalized)
|
||||||
return modelBlacklistSummary{
|
return excludedModelsSummary{
|
||||||
hash: computeModelBlacklistHash(normalized),
|
hash: computeExcludedModelsHash(normalized),
|
||||||
count: len(normalized),
|
count: len(normalized),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func summarizeOAuthBlacklistMap(entries map[string][]string) map[string]modelBlacklistSummary {
|
func summarizeOAuthExcludedModels(entries map[string][]string) map[string]excludedModelsSummary {
|
||||||
if len(entries) == 0 {
|
if len(entries) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
out := make(map[string]modelBlacklistSummary, len(entries))
|
out := make(map[string]excludedModelsSummary, len(entries))
|
||||||
for k, v := range entries {
|
for k, v := range entries {
|
||||||
key := strings.ToLower(strings.TrimSpace(k))
|
key := strings.ToLower(strings.TrimSpace(k))
|
||||||
if key == "" {
|
if key == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
out[key] = summarizeModelBlacklist(v)
|
out[key] = summarizeExcludedModels(v)
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func diffOAuthBlacklistChanges(oldMap, newMap map[string][]string) ([]string, []string) {
|
func diffOAuthExcludedModelChanges(oldMap, newMap map[string][]string) ([]string, []string) {
|
||||||
oldSummary := summarizeOAuthBlacklistMap(oldMap)
|
oldSummary := summarizeOAuthExcludedModels(oldMap)
|
||||||
newSummary := summarizeOAuthBlacklistMap(newMap)
|
newSummary := summarizeOAuthExcludedModels(newMap)
|
||||||
keys := make(map[string]struct{}, len(oldSummary)+len(newSummary))
|
keys := make(map[string]struct{}, len(oldSummary)+len(newSummary))
|
||||||
for k := range oldSummary {
|
for k := range oldSummary {
|
||||||
keys[k] = struct{}{}
|
keys[k] = struct{}{}
|
||||||
@@ -590,13 +590,13 @@ func diffOAuthBlacklistChanges(oldMap, newMap map[string][]string) ([]string, []
|
|||||||
newInfo, okNew := newSummary[key]
|
newInfo, okNew := newSummary[key]
|
||||||
switch {
|
switch {
|
||||||
case okOld && !okNew:
|
case okOld && !okNew:
|
||||||
changes = append(changes, fmt.Sprintf("oauth-model-blacklist[%s]: removed", key))
|
changes = append(changes, fmt.Sprintf("oauth-excluded-models[%s]: removed", key))
|
||||||
affected = append(affected, key)
|
affected = append(affected, key)
|
||||||
case !okOld && okNew:
|
case !okOld && okNew:
|
||||||
changes = append(changes, fmt.Sprintf("oauth-model-blacklist[%s]: added (%d entries)", key, newInfo.count))
|
changes = append(changes, fmt.Sprintf("oauth-excluded-models[%s]: added (%d entries)", key, newInfo.count))
|
||||||
affected = append(affected, key)
|
affected = append(affected, key)
|
||||||
case okOld && okNew && oldInfo.hash != newInfo.hash:
|
case okOld && okNew && oldInfo.hash != newInfo.hash:
|
||||||
changes = append(changes, fmt.Sprintf("oauth-model-blacklist[%s]: updated (%d -> %d entries)", key, oldInfo.count, newInfo.count))
|
changes = append(changes, fmt.Sprintf("oauth-excluded-models[%s]: updated (%d -> %d entries)", key, oldInfo.count, newInfo.count))
|
||||||
affected = append(affected, key)
|
affected = append(affected, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -605,7 +605,7 @@ func diffOAuthBlacklistChanges(oldMap, newMap map[string][]string) ([]string, []
|
|||||||
return changes, affected
|
return changes, affected
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyAuthModelBlacklistMeta(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
|
||||||
}
|
}
|
||||||
@@ -624,21 +624,21 @@ func applyAuthModelBlacklistMeta(auth *coreauth.Auth, cfg *config.Config, perKey
|
|||||||
}
|
}
|
||||||
if authKindKey == "apikey" {
|
if authKindKey == "apikey" {
|
||||||
add(perKey)
|
add(perKey)
|
||||||
} else if cfg.OAuthModelBlacklist != nil {
|
} else if cfg.OAuthExcludedModels != nil {
|
||||||
providerKey := strings.ToLower(strings.TrimSpace(auth.Provider))
|
providerKey := strings.ToLower(strings.TrimSpace(auth.Provider))
|
||||||
add(cfg.OAuthModelBlacklist[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)
|
||||||
}
|
}
|
||||||
sort.Strings(combined)
|
sort.Strings(combined)
|
||||||
hash := computeModelBlacklistHash(combined)
|
hash := computeExcludedModelsHash(combined)
|
||||||
if auth.Attributes == nil {
|
if auth.Attributes == nil {
|
||||||
auth.Attributes = make(map[string]string)
|
auth.Attributes = make(map[string]string)
|
||||||
}
|
}
|
||||||
if hash != "" {
|
if hash != "" {
|
||||||
auth.Attributes["model_blacklist_hash"] = hash
|
auth.Attributes["excluded_models_hash"] = hash
|
||||||
}
|
}
|
||||||
if authKind != "" {
|
if authKind != "" {
|
||||||
auth.Attributes["auth_kind"] = authKind
|
auth.Attributes["auth_kind"] = authKind
|
||||||
@@ -831,7 +831,7 @@ func (w *Watcher) reloadConfig() bool {
|
|||||||
|
|
||||||
var affectedOAuthProviders []string
|
var affectedOAuthProviders []string
|
||||||
if oldConfig != nil {
|
if oldConfig != nil {
|
||||||
_, affectedOAuthProviders = diffOAuthBlacklistChanges(oldConfig.OAuthModelBlacklist, newConfig.OAuthModelBlacklist)
|
_, affectedOAuthProviders = diffOAuthExcludedModelChanges(oldConfig.OAuthExcludedModels, newConfig.OAuthExcludedModels)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always apply the current log level based on the latest config.
|
// Always apply the current log level based on the latest config.
|
||||||
@@ -891,7 +891,7 @@ func (w *Watcher) reloadClients(rescanAuth bool, affectedOAuthProviders []string
|
|||||||
filtered[id] = auth
|
filtered[id] = auth
|
||||||
}
|
}
|
||||||
w.currentAuths = filtered
|
w.currentAuths = filtered
|
||||||
log.Debugf("applying oauth-model-blacklist to providers %v", affectedOAuthProviders)
|
log.Debugf("applying oauth-excluded-models to providers %v", affectedOAuthProviders)
|
||||||
} else {
|
} else {
|
||||||
w.currentAuths = nil
|
w.currentAuths = nil
|
||||||
}
|
}
|
||||||
@@ -1071,7 +1071,7 @@ func (w *Watcher) SnapshotCoreAuths() []*coreauth.Auth {
|
|||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
UpdatedAt: now,
|
UpdatedAt: now,
|
||||||
}
|
}
|
||||||
applyAuthModelBlacklistMeta(a, cfg, entry.ModelBlacklist, "apikey")
|
applyAuthExcludedModelsMeta(a, cfg, entry.ExcludedModels, "apikey")
|
||||||
out = append(out, a)
|
out = append(out, a)
|
||||||
}
|
}
|
||||||
// Claude API keys -> synthesize auths
|
// Claude API keys -> synthesize auths
|
||||||
@@ -1105,7 +1105,7 @@ func (w *Watcher) SnapshotCoreAuths() []*coreauth.Auth {
|
|||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
UpdatedAt: now,
|
UpdatedAt: now,
|
||||||
}
|
}
|
||||||
applyAuthModelBlacklistMeta(a, cfg, ck.ModelBlacklist, "apikey")
|
applyAuthExcludedModelsMeta(a, cfg, ck.ExcludedModels, "apikey")
|
||||||
out = append(out, a)
|
out = append(out, a)
|
||||||
}
|
}
|
||||||
// Codex API keys -> synthesize auths
|
// Codex API keys -> synthesize auths
|
||||||
@@ -1135,7 +1135,7 @@ func (w *Watcher) SnapshotCoreAuths() []*coreauth.Auth {
|
|||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
UpdatedAt: now,
|
UpdatedAt: now,
|
||||||
}
|
}
|
||||||
applyAuthModelBlacklistMeta(a, cfg, ck.ModelBlacklist, "apikey")
|
applyAuthExcludedModelsMeta(a, cfg, ck.ExcludedModels, "apikey")
|
||||||
out = append(out, a)
|
out = append(out, a)
|
||||||
}
|
}
|
||||||
for i := range cfg.OpenAICompatibility {
|
for i := range cfg.OpenAICompatibility {
|
||||||
@@ -1296,11 +1296,11 @@ func (w *Watcher) SnapshotCoreAuths() []*coreauth.Auth {
|
|||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
UpdatedAt: now,
|
UpdatedAt: now,
|
||||||
}
|
}
|
||||||
applyAuthModelBlacklistMeta(a, cfg, nil, "oauth")
|
applyAuthExcludedModelsMeta(a, cfg, nil, "oauth")
|
||||||
if provider == "gemini-cli" {
|
if provider == "gemini-cli" {
|
||||||
if virtuals := synthesizeGeminiVirtualAuths(a, metadata, now); len(virtuals) > 0 {
|
if virtuals := synthesizeGeminiVirtualAuths(a, metadata, now); len(virtuals) > 0 {
|
||||||
for _, v := range virtuals {
|
for _, v := range virtuals {
|
||||||
applyAuthModelBlacklistMeta(v, cfg, nil, "oauth")
|
applyAuthExcludedModelsMeta(v, cfg, nil, "oauth")
|
||||||
}
|
}
|
||||||
out = append(out, a)
|
out = append(out, a)
|
||||||
out = append(out, virtuals...)
|
out = append(out, virtuals...)
|
||||||
@@ -1693,10 +1693,10 @@ func buildConfigChangeDetails(oldCfg, newCfg *config.Config) []string {
|
|||||||
if !equalStringMap(o.Headers, n.Headers) {
|
if !equalStringMap(o.Headers, n.Headers) {
|
||||||
changes = append(changes, fmt.Sprintf("gemini[%d].headers: updated", i))
|
changes = append(changes, fmt.Sprintf("gemini[%d].headers: updated", i))
|
||||||
}
|
}
|
||||||
oldBL := summarizeModelBlacklist(o.ModelBlacklist)
|
oldExcluded := summarizeExcludedModels(o.ExcludedModels)
|
||||||
newBL := summarizeModelBlacklist(n.ModelBlacklist)
|
newExcluded := summarizeExcludedModels(n.ExcludedModels)
|
||||||
if oldBL.hash != newBL.hash {
|
if oldExcluded.hash != newExcluded.hash {
|
||||||
changes = append(changes, fmt.Sprintf("gemini[%d].model-blacklist: updated (%d -> %d entries)", i, oldBL.count, newBL.count))
|
changes = append(changes, fmt.Sprintf("gemini[%d].excluded-models: updated (%d -> %d entries)", i, oldExcluded.count, newExcluded.count))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(trimStrings(oldCfg.GlAPIKey), trimStrings(newCfg.GlAPIKey)) {
|
if !reflect.DeepEqual(trimStrings(oldCfg.GlAPIKey), trimStrings(newCfg.GlAPIKey)) {
|
||||||
@@ -1726,10 +1726,10 @@ func buildConfigChangeDetails(oldCfg, newCfg *config.Config) []string {
|
|||||||
if !equalStringMap(o.Headers, n.Headers) {
|
if !equalStringMap(o.Headers, n.Headers) {
|
||||||
changes = append(changes, fmt.Sprintf("claude[%d].headers: updated", i))
|
changes = append(changes, fmt.Sprintf("claude[%d].headers: updated", i))
|
||||||
}
|
}
|
||||||
oldBL := summarizeModelBlacklist(o.ModelBlacklist)
|
oldExcluded := summarizeExcludedModels(o.ExcludedModels)
|
||||||
newBL := summarizeModelBlacklist(n.ModelBlacklist)
|
newExcluded := summarizeExcludedModels(n.ExcludedModels)
|
||||||
if oldBL.hash != newBL.hash {
|
if oldExcluded.hash != newExcluded.hash {
|
||||||
changes = append(changes, fmt.Sprintf("claude[%d].model-blacklist: updated (%d -> %d entries)", i, oldBL.count, newBL.count))
|
changes = append(changes, fmt.Sprintf("claude[%d].excluded-models: updated (%d -> %d entries)", i, oldExcluded.count, newExcluded.count))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1756,15 +1756,15 @@ func buildConfigChangeDetails(oldCfg, newCfg *config.Config) []string {
|
|||||||
if !equalStringMap(o.Headers, n.Headers) {
|
if !equalStringMap(o.Headers, n.Headers) {
|
||||||
changes = append(changes, fmt.Sprintf("codex[%d].headers: updated", i))
|
changes = append(changes, fmt.Sprintf("codex[%d].headers: updated", i))
|
||||||
}
|
}
|
||||||
oldBL := summarizeModelBlacklist(o.ModelBlacklist)
|
oldExcluded := summarizeExcludedModels(o.ExcludedModels)
|
||||||
newBL := summarizeModelBlacklist(n.ModelBlacklist)
|
newExcluded := summarizeExcludedModels(n.ExcludedModels)
|
||||||
if oldBL.hash != newBL.hash {
|
if oldExcluded.hash != newExcluded.hash {
|
||||||
changes = append(changes, fmt.Sprintf("codex[%d].model-blacklist: updated (%d -> %d entries)", i, oldBL.count, newBL.count))
|
changes = append(changes, fmt.Sprintf("codex[%d].excluded-models: updated (%d -> %d entries)", i, oldExcluded.count, newExcluded.count))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if entries, _ := diffOAuthBlacklistChanges(oldCfg.OAuthModelBlacklist, newCfg.OAuthModelBlacklist); len(entries) > 0 {
|
if entries, _ := diffOAuthExcludedModelChanges(oldCfg.OAuthExcludedModels, newCfg.OAuthExcludedModels); len(entries) > 0 {
|
||||||
changes = append(changes, entries...)
|
changes = append(changes, entries...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -665,32 +665,32 @@ func (s *Service) registerModelsForAuth(a *coreauth.Auth) {
|
|||||||
if compatDetected {
|
if compatDetected {
|
||||||
provider = "openai-compatibility"
|
provider = "openai-compatibility"
|
||||||
}
|
}
|
||||||
blacklist := s.oauthBlacklist(provider, authKind)
|
excluded := s.oauthExcludedModels(provider, authKind)
|
||||||
var models []*ModelInfo
|
var models []*ModelInfo
|
||||||
switch provider {
|
switch provider {
|
||||||
case "gemini":
|
case "gemini":
|
||||||
models = registry.GetGeminiModels()
|
models = registry.GetGeminiModels()
|
||||||
if entry := s.resolveConfigGeminiKey(a); entry != nil {
|
if entry := s.resolveConfigGeminiKey(a); entry != nil {
|
||||||
if authKind == "apikey" {
|
if authKind == "apikey" {
|
||||||
blacklist = entry.ModelBlacklist
|
excluded = entry.ExcludedModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
models = applyModelBlacklist(models, blacklist)
|
models = applyExcludedModels(models, excluded)
|
||||||
case "vertex":
|
case "vertex":
|
||||||
// Vertex AI Gemini supports the same model identifiers as Gemini.
|
// Vertex AI Gemini supports the same model identifiers as Gemini.
|
||||||
models = registry.GetGeminiVertexModels()
|
models = registry.GetGeminiVertexModels()
|
||||||
models = applyModelBlacklist(models, blacklist)
|
models = applyExcludedModels(models, excluded)
|
||||||
case "gemini-cli":
|
case "gemini-cli":
|
||||||
models = registry.GetGeminiCLIModels()
|
models = registry.GetGeminiCLIModels()
|
||||||
models = applyModelBlacklist(models, blacklist)
|
models = applyExcludedModels(models, excluded)
|
||||||
case "aistudio":
|
case "aistudio":
|
||||||
models = registry.GetAIStudioModels()
|
models = registry.GetAIStudioModels()
|
||||||
models = applyModelBlacklist(models, blacklist)
|
models = applyExcludedModels(models, excluded)
|
||||||
case "antigravity":
|
case "antigravity":
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||||
models = executor.FetchAntigravityModels(ctx, a, s.cfg)
|
models = executor.FetchAntigravityModels(ctx, a, s.cfg)
|
||||||
cancel()
|
cancel()
|
||||||
models = applyModelBlacklist(models, blacklist)
|
models = applyExcludedModels(models, excluded)
|
||||||
case "claude":
|
case "claude":
|
||||||
models = registry.GetClaudeModels()
|
models = registry.GetClaudeModels()
|
||||||
if entry := s.resolveConfigClaudeKey(a); entry != nil {
|
if entry := s.resolveConfigClaudeKey(a); entry != nil {
|
||||||
@@ -698,24 +698,24 @@ func (s *Service) registerModelsForAuth(a *coreauth.Auth) {
|
|||||||
models = buildClaudeConfigModels(entry)
|
models = buildClaudeConfigModels(entry)
|
||||||
}
|
}
|
||||||
if authKind == "apikey" {
|
if authKind == "apikey" {
|
||||||
blacklist = entry.ModelBlacklist
|
excluded = entry.ExcludedModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
models = applyModelBlacklist(models, blacklist)
|
models = applyExcludedModels(models, excluded)
|
||||||
case "codex":
|
case "codex":
|
||||||
models = registry.GetOpenAIModels()
|
models = registry.GetOpenAIModels()
|
||||||
if entry := s.resolveConfigCodexKey(a); entry != nil {
|
if entry := s.resolveConfigCodexKey(a); entry != nil {
|
||||||
if authKind == "apikey" {
|
if authKind == "apikey" {
|
||||||
blacklist = entry.ModelBlacklist
|
excluded = entry.ExcludedModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
models = applyModelBlacklist(models, blacklist)
|
models = applyExcludedModels(models, excluded)
|
||||||
case "qwen":
|
case "qwen":
|
||||||
models = registry.GetQwenModels()
|
models = registry.GetQwenModels()
|
||||||
models = applyModelBlacklist(models, blacklist)
|
models = applyExcludedModels(models, excluded)
|
||||||
case "iflow":
|
case "iflow":
|
||||||
models = registry.GetIFlowModels()
|
models = registry.GetIFlowModels()
|
||||||
models = applyModelBlacklist(models, blacklist)
|
models = applyExcludedModels(models, excluded)
|
||||||
default:
|
default:
|
||||||
// Handle OpenAI-compatibility providers by name using config
|
// Handle OpenAI-compatibility providers by name using config
|
||||||
if s.cfg != nil {
|
if s.cfg != nil {
|
||||||
@@ -900,7 +900,7 @@ func (s *Service) resolveConfigCodexKey(auth *coreauth.Auth) *config.CodexKey {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) oauthBlacklist(provider, authKind string) []string {
|
func (s *Service) oauthExcludedModels(provider, authKind string) []string {
|
||||||
cfg := s.cfg
|
cfg := s.cfg
|
||||||
if cfg == nil {
|
if cfg == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -910,15 +910,15 @@ func (s *Service) oauthBlacklist(provider, authKind string) []string {
|
|||||||
if authKindKey == "apikey" {
|
if authKindKey == "apikey" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return cfg.OAuthModelBlacklist[providerKey]
|
return cfg.OAuthExcludedModels[providerKey]
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyModelBlacklist(models []*ModelInfo, blacklist []string) []*ModelInfo {
|
func applyExcludedModels(models []*ModelInfo, excluded []string) []*ModelInfo {
|
||||||
if len(models) == 0 || len(blacklist) == 0 {
|
if len(models) == 0 || len(excluded) == 0 {
|
||||||
return models
|
return models
|
||||||
}
|
}
|
||||||
blocked := make(map[string]struct{}, len(blacklist))
|
blocked := make(map[string]struct{}, len(excluded))
|
||||||
for _, item := range blacklist {
|
for _, item := range excluded {
|
||||||
if trimmed := strings.TrimSpace(item); trimmed != "" {
|
if trimmed := strings.TrimSpace(item); trimmed != "" {
|
||||||
blocked[strings.ToLower(trimmed)] = struct{}{}
|
blocked[strings.ToLower(trimmed)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user