mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
fix(util): do not strip thinking suffix on registered models
NormalizeThinkingModel now checks ModelSupportsThinking before removing "-thinking" or "-thinking-<ver>", avoiding accidental parsing of model names where the suffix is part of the official id (e.g., kimi-k2-thinking, qwen3-235b-a22b-thinking-2507). The registry adds ThinkingSupport metadata for several models and propagates it via ModelInfo (e.g., kimi-k2-thinking, deepseek-r1, qwen3-235b-a22b-thinking-2507, minimax-m2), enabling accurate detection of thinking-capable models and correcting base model inference.
This commit is contained in:
@@ -52,6 +52,11 @@ func NormalizeThinkingModel(modelName string) (string, map[string]any) {
|
||||
matched = true
|
||||
default:
|
||||
if idx := strings.LastIndex(lower, "-thinking-"); idx != -1 {
|
||||
// Skip stripping if the original model is a registered thinking model.
|
||||
// This prevents "-thinking-2507" in "qwen3-235b-a22b-thinking-2507" from being parsed.
|
||||
if ModelSupportsThinking(modelName) {
|
||||
break
|
||||
}
|
||||
value := modelName[idx+len("-thinking-"):]
|
||||
if value != "" {
|
||||
if parsed, ok := parseIntPrefix(value); ok {
|
||||
@@ -95,10 +100,16 @@ func NormalizeThinkingModel(modelName string) (string, map[string]any) {
|
||||
}
|
||||
}
|
||||
} else if strings.HasSuffix(lower, "-thinking") {
|
||||
baseModel = modelName[:len(modelName)-len("-thinking")]
|
||||
effort := "medium"
|
||||
reasoningEffort = &effort
|
||||
matched = true
|
||||
candidateBase := modelName[:len(modelName)-len("-thinking")]
|
||||
// Only strip the suffix if the original model is NOT a registered thinking model.
|
||||
// This prevents stripping "-thinking" from models like "kimi-k2-thinking" where
|
||||
// the suffix is part of the model's actual name.
|
||||
if !ModelSupportsThinking(modelName) {
|
||||
baseModel = candidateBase
|
||||
effort := "medium"
|
||||
reasoningEffort = &effort
|
||||
matched = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user