mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
refactor(thinking): simplify ModeNone and budget validation logic
This commit is contained in:
@@ -159,27 +159,22 @@ func ValidateConfig(config ThinkingConfig, modelInfo *registry.ModelInfo, provid
|
||||
normalized = convertAutoToMidRange(normalized, support, provider, model)
|
||||
}
|
||||
|
||||
// ModeNone handling varies by provider/model capability:
|
||||
// - Claude can always disable thinking via thinking.type="disabled".
|
||||
// - Some models/providers cannot be fully disabled; for those we force minimal thinking
|
||||
// while hiding thoughts (ModeNone + Budget>0 and/or Level set).
|
||||
if normalized.Mode == ModeNone {
|
||||
if provider == "claude" {
|
||||
normalized.Budget = 0
|
||||
normalized.Level = ""
|
||||
} else if !support.ZeroAllowed {
|
||||
if support.Min > 0 {
|
||||
normalized.Budget = support.Min
|
||||
}
|
||||
if normalized.Level == "" && normalized.Budget > 0 && len(support.Levels) > 0 {
|
||||
normalized.Level = ThinkingLevel(support.Levels[0])
|
||||
}
|
||||
if normalized.Mode == ModeNone && provider == "claude" {
|
||||
// Claude supports explicit disable via thinking.type="disabled".
|
||||
// Keep Budget=0 so applier can omit budget_tokens.
|
||||
normalized.Budget = 0
|
||||
normalized.Level = ""
|
||||
} else {
|
||||
switch normalized.Mode {
|
||||
case ModeBudget, ModeAuto, ModeNone:
|
||||
normalized.Budget = ClampBudget(normalized.Budget, modelInfo, provider)
|
||||
}
|
||||
}
|
||||
|
||||
switch normalized.Mode {
|
||||
case ModeBudget, ModeAuto:
|
||||
normalized.Budget = ClampBudget(normalized.Budget, modelInfo, provider)
|
||||
// ModeNone with clamped Budget > 0: set Level to lowest for Level-only/Hybrid models
|
||||
// This ensures Apply layer doesn't need to access support.Levels
|
||||
if normalized.Mode == ModeNone && normalized.Budget > 0 && len(support.Levels) > 0 {
|
||||
normalized.Level = ThinkingLevel(support.Levels[0])
|
||||
}
|
||||
}
|
||||
|
||||
return &normalized, nil
|
||||
|
||||
Reference in New Issue
Block a user