reasoning.go RawHistoryFolder
1package provider
2
3import "strings"
4
5// NormalizeReasoning canonicalizes zot's user-facing thinking levels.
6// Empty string means reasoning/thinking is disabled.
7func NormalizeReasoning(level string) string {
8 switch strings.ToLower(strings.TrimSpace(level)) {
9 case "", "off", "none", "no", "false", "disabled":
10 return ""
11 case "min", "minimal", "minimum":
12 return "minimum"
13 case "low":
14 return "low"
15 case "med", "medium":
16 return "medium"
17 case "hi", "high":
18 return "high"
19 case "max", "maximum":
20 return "maximum"
21 default:
22 return strings.ToLower(strings.TrimSpace(level))
23 }
24}
25
26// ReasoningBudget returns zot's approximate token budget for thinking-capable
27// providers that accept explicit budgets.
28func ReasoningBudget(level string) int {
29 switch NormalizeReasoning(level) {
30 case "minimum":
31 return 1024
32 case "low":
33 return 2048
34 case "medium":
35 return 8192
36 case "high":
37 return 16384
38 case "maximum":
39 return 32768
40 default:
41 return 0
42 }
43}
44
45// AnthropicAdaptiveEffort maps zot's user-facing thinking levels onto the
46// effort enum used by Anthropic's adaptive-thinking models (Opus 4.7+).
47// These models reject explicit thinking budgets; thinking depth is
48// controlled by output_config.effort instead. Returns "" when reasoning
49// is disabled.
50func AnthropicAdaptiveEffort(level string) string {
51 switch NormalizeReasoning(level) {
52 case "minimum", "low":
53 return "low"
54 case "medium":
55 return "medium"
56 case "high":
57 return "high"
58 case "maximum":
59 return "xhigh"
60 default:
61 return ""
62 }
63}
64
65// OpenAIReasoningEffort maps zot's six-level setting onto the effort enum
66// accepted by OpenAI-compatible chat-completions endpoints.
67func OpenAIReasoningEffort(level string) string {
68 switch NormalizeReasoning(level) {
69 case "minimum", "low":
70 // Many OpenAI-compatible endpoints only accept low/medium/high.
71 // Use low for zot's minimum instead of the newer minimal enum.
72 return "low"
73 case "medium":
74 return "medium"
75 case "high", "maximum":
76 return "high"
77 default:
78 return ""
79 }
80}
81
82// OpenAICompatAnthropicEffort maps zot's user-facing thinking levels
83// onto reasoning_effort values when an adaptive-thinking Anthropic
84// model (Opus 4.7+) is served over the OpenAI-compatible chat-
85// completions wire (openrouter, opencode, ...). Differs from
86// OpenAIReasoningEffort only at the top: zot's "maximum" maps to
87// "xhigh" instead of being clamped to "high", so the model's full
88// adaptive-thinking ceiling is preserved when reachable through a
89// gateway that accepts the effort knob.
90func OpenAICompatAnthropicEffort(level string) string {
91 switch NormalizeReasoning(level) {
92 case "minimum", "low":
93 return "low"
94 case "medium":
95 return "medium"
96 case "high":
97 return "high"
98 case "maximum":
99 return "xhigh"
100 default:
101 return ""
102 }
103}
104
105// OpenAICodexReasoningEffort maps zot levels onto the ChatGPT/Codex
106// Responses backend enum. That backend rejects "minimal" and uses
107// "xhigh" for the highest tier on recent GPT-5.x models.
108func OpenAICodexReasoningEffort(level string) string {
109 switch NormalizeReasoning(level) {
110 case "minimum", "low":
111 return "low"
112 case "medium":
113 return "medium"
114 case "high":
115 return "high"
116 case "maximum":
117 return "xhigh"
118 default:
119 return ""
120 }
121}