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. "maximum" remains
7// an alias for xhigh; "max" is the separate opt-in tier above it.
8func NormalizeReasoning(level string) string {
9 switch strings.ToLower(strings.TrimSpace(level)) {
10 case "", "off", "none", "no", "false", "disabled":
11 return ""
12 case "min", "minimal", "minimum":
13 return "minimum"
14 case "low":
15 return "low"
16 case "med", "medium":
17 return "medium"
18 case "hi", "high":
19 return "high"
20 case "xhigh", "maximum":
21 return "xhigh"
22 case "max":
23 return "max"
24 default:
25 return strings.ToLower(strings.TrimSpace(level))
26 }
27}
28
29// ReasoningBudget returns zot's approximate token budget for thinking-capable
30// providers that accept explicit budgets.
31func ReasoningBudget(level string) int {
32 switch NormalizeReasoning(level) {
33 case "minimum":
34 return 1024
35 case "low":
36 return 2048
37 case "medium":
38 return 8192
39 case "high":
40 return 16384
41 case "xhigh", "max":
42 return 32768
43 default:
44 return 0
45 }
46}
47
48// AnthropicAdaptiveEffort maps zot's user-facing thinking levels onto the
49// effort enum used by adaptive-thinking models. These models reject explicit
50// thinking budgets; reasoning depth is controlled by output_config.effort.
51func AnthropicAdaptiveEffort(level string) string {
52 switch NormalizeReasoning(level) {
53 case "minimum", "low":
54 return "low"
55 case "medium":
56 return "medium"
57 case "high":
58 return "high"
59 case "xhigh":
60 return "xhigh"
61 case "max":
62 return "max"
63 default:
64 return ""
65 }
66}
67
68// OpenAIReasoningEffort maps zot's thinking setting onto the effort enum
69// accepted by generic OpenAI-compatible chat-completions endpoints.
70func OpenAIReasoningEffort(level string) string {
71 switch NormalizeReasoning(level) {
72 case "minimum", "low":
73 // Many compatible endpoints only accept low/medium/high.
74 return "low"
75 case "medium":
76 return "medium"
77 case "high", "xhigh", "max":
78 return "high"
79 default:
80 return ""
81 }
82}
83
84// OpenAICompatAnthropicEffort maps zot's thinking setting when an adaptive
85// Anthropic model is served over an OpenAI-compatible chat-completions wire.
86// Adaptive models accept native xhigh and max effort values.
87func OpenAICompatAnthropicEffort(level string) string {
88 switch NormalizeReasoning(level) {
89 case "minimum", "low":
90 return "low"
91 case "medium":
92 return "medium"
93 case "high":
94 return "high"
95 case "xhigh":
96 return "xhigh"
97 case "max":
98 return "max"
99 default:
100 return ""
101 }
102}
103
104// OpenAICodexReasoningEffort maps zot levels onto the Responses API effort
105// enum. GPT-5.6 supports native max; other models clamp max to xhigh.
106func OpenAICodexReasoningEffort(level, model string) string {
107 switch NormalizeReasoning(level) {
108 case "minimum", "low":
109 return "low"
110 case "medium":
111 return "medium"
112 case "high":
113 return "high"
114 case "xhigh":
115 return "xhigh"
116 case "max":
117 if strings.HasPrefix(strings.ToLower(model), "gpt-5.6-") {
118 return "max"
119 }
120 return "xhigh"
121 default:
122 return ""
123 }
124}