Documentation
¶
Overview ¶
Package thinking folds how-hard-to-think into the native shape each upstream model accepts. Callers speak two dialects — Anthropic sends a token budget, OpenAI sends an effort ordinal — and every upstream reasons by its own control: GLM/DeepSeek by a reasoning_effort ordinal, Qwen by an enable_thinking gate, Kimi by a thinking object. Between them sits ONE neutral value, a Depth ordinal: each dialect is a constructor into it, each upstream a projection out of it.
This is the sole home of that map, so ai and zen share one table (as they already share hanzoai/decimal and hanzoai/money). The fold is total and monotone — deeper in, harder out — and lossy where a vocabulary is coarser.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Keys = []string{"reasoning_effort", "enable_thinking", "thinking_budget", "thinking"}
Keys is every field any vocabulary may write. A caller clears these before applying Fields so the fold is the sole writer and nothing leaks across a vocabulary boundary.
Functions ¶
This section is empty.
Types ¶
type Depth ¶
type Depth int
Depth is how hard to think, as an ordinal — the neutral value both wire dialects normalize into and every upstream projects out of. Off means the caller declined to think; the rest ascend.
func Budget ¶
Budget folds an Anthropic thinking.budget_tokens into a Depth. Zero (thinking absent or disabled) is Off; any positive budget is on, at a tier set by size.
func Effort ¶
Effort folds an OpenAI reasoning_effort ordinal into a Depth. An unknown or empty value is Off.
func (Depth) Fields ¶
Fields projects the depth into the request fields a vocabulary accepts, as a map to merge into an upstream chat body — {} when the vocabulary takes no field for the depth. It is the sole producer of these keys, so a caller clears Keys first: a stale field from another vocabulary must never reach this upstream.
Off is not always empty: a GLM-family upstream reasons BY DEFAULT, so Off (the instant path) must actively send reasoning_effort:"none" — the absence of the field would leave the model reasoning, streaming a long content:null preamble that reads as an empty completion. Vocabularies that default OFF (Qwen/Kimi gates, OpenAI o-series) write nothing for Off, as before.
type Vocab ¶
type Vocab string
Vocab is the reasoning control an upstream accepts, keyed by request shape — not by brand. Pick it with Of.
const ( GLM Vocab = "glm" // reasoning_effort ∈ {none, high, max}: GLM-5.*, DeepSeek V4, the DO-AI default (reasons unless told none) OpenAI Vocab = "openai" // reasoning_effort ∈ {low, medium, high}: o-series Qwen Vocab = "qwen" // enable_thinking gate Kimi Vocab = "kimi" // a thinking object {type, preserve_thinking} )
func Of ¶
Of returns the vocabulary an upstream model id accepts, keyed by id prefix — the one place brand maps to control shape. Unknown ids fold as GLM: the DO-AI family (glm-5.*, deepseek-*, minimax-*, nemotron-*, llama*) is the universal upstream and its two-tier ordinal is the safe supposition.