mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
Route OpenAI reasoning effort through ThinkingEffortToBudget for Claude translators, preserve "minimal" when translating OpenAI Responses, and treat blank/unknown efforts as no-ops for Gemini thinking configs. Also map budget -1 to "auto" and expand cross-protocol thinking tests.
38 lines
1010 B
Go
38 lines
1010 B
Go
package util
|
|
|
|
// OpenAIThinkingBudgetToEffort maps a numeric thinking budget (tokens)
|
|
// into an OpenAI-style reasoning effort level for level-based models.
|
|
//
|
|
// Ranges:
|
|
// - 0 -> "none"
|
|
// - -1 -> "auto"
|
|
// - 1..1024 -> "low"
|
|
// - 1025..8192 -> "medium"
|
|
// - 8193..24576 -> "high"
|
|
// - 24577.. -> highest supported level for the model (defaults to "xhigh")
|
|
//
|
|
// Negative values other than -1 are treated as unsupported.
|
|
func OpenAIThinkingBudgetToEffort(model string, budget int) (string, bool) {
|
|
switch {
|
|
case budget == -1:
|
|
return "auto", true
|
|
case budget < -1:
|
|
return "", false
|
|
case budget == 0:
|
|
return "none", true
|
|
case budget > 0 && budget <= 1024:
|
|
return "low", true
|
|
case budget <= 8192:
|
|
return "medium", true
|
|
case budget <= 24576:
|
|
return "high", true
|
|
case budget > 24576:
|
|
if levels := GetModelThinkingLevels(model); len(levels) > 0 {
|
|
return levels[len(levels)-1], true
|
|
}
|
|
return "xhigh", true
|
|
default:
|
|
return "", false
|
|
}
|
|
}
|