Skip to main content

Module thinking

Module thinking 

Source
Expand description

Thinking levels and output token budgets.

Constants§

MIN_ANSWER_TOKENS
Output tokens kept for the answer when a thinking budget would consume all.

Functions§

budget_for_level
The budget for budget-based thinking at level. xhigh and max use high.
budgeted
Budget-based thinking at level on top of the output limit base: the output limit capped to the context, and the budget leaving room to answer under it. Returns (max_tokens, budget).
clamp_level
The nearest supported level: the requested one, else the next higher, else the next lower.
clamp_max_tokens_to_context
Caps max_tokens so the estimated context plus output fits the window.
effort
The requested level clamped to the model, or None when it is off.
requested_max_tokens
pi’s streamSimple output limit: the requested limit, else the model’s, capped to the context window.
supported_levels
The levels a model accepts: only off without reasoning, xhigh and max only when its thinking level map names them, and none the map marks unsupported.