mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-06 09:25:27 +08:00
- replace legacy DeepSeek ids with the new deepseek-v4 model family\n- move thinking control to request parameters and preserve assistant reasoning content\n- switch history split to IGNORE transcript injection and map upload auth failures to 401\n- update admin defaults, API docs, samples, and tests for the new model scheme
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package util
|
|
|
|
import "strings"
|
|
|
|
func ResolveThinkingEnabled(req map[string]any, defaultEnabled bool) bool {
|
|
if enabled, ok := parseThinkingSetting(req["thinking"]); ok {
|
|
return enabled
|
|
}
|
|
if extraBody, ok := req["extra_body"].(map[string]any); ok {
|
|
if enabled, ok := parseThinkingSetting(extraBody["thinking"]); ok {
|
|
return enabled
|
|
}
|
|
}
|
|
if enabled, ok := parseReasoningEffort(req["reasoning_effort"]); ok {
|
|
return enabled
|
|
}
|
|
return defaultEnabled
|
|
}
|
|
|
|
func parseThinkingSetting(raw any) (bool, bool) {
|
|
switch v := raw.(type) {
|
|
case string:
|
|
switch strings.ToLower(strings.TrimSpace(v)) {
|
|
case "enabled":
|
|
return true, true
|
|
case "disabled":
|
|
return false, true
|
|
default:
|
|
return false, false
|
|
}
|
|
case map[string]any:
|
|
if typ, ok := v["type"]; ok {
|
|
return parseThinkingSetting(typ)
|
|
}
|
|
}
|
|
return false, false
|
|
}
|
|
|
|
func parseReasoningEffort(raw any) (bool, bool) {
|
|
switch strings.ToLower(strings.TrimSpace(toString(raw))) {
|
|
case "low", "medium", "high", "xhigh":
|
|
return true, true
|
|
default:
|
|
return false, false
|
|
}
|
|
}
|
|
|
|
func toString(raw any) string {
|
|
if s, ok := raw.(string); ok {
|
|
return s
|
|
}
|
|
return ""
|
|
}
|