effort

package
v1.81.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package effort defines the canonical set of thinking-effort levels and provides per-provider mapping helpers. All provider packages should use this package instead of hard-coding effort strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BedrockTokens

func BedrockTokens(l Level) (int, bool)

BedrockTokens maps l to a token budget for Bedrock Claude, which only supports token-based thinking budgets.

func ForAnthropic

func ForAnthropic(l Level) (string, bool)

ForAnthropic returns the Anthropic output_config effort string for l. Anthropic accepts: low, medium, high, xhigh, max. xhigh is only supported by newer Claude models (e.g. Opus 4.7+). Minimal is mapped to low as the closest equivalent.

func ForGemini3

func ForGemini3(l Level) (string, bool)

ForGemini3 returns the Gemini 3 thinking-level string for l. Gemini 3 accepts: minimal, low, medium, high.

func ForOpenAI

func ForOpenAI(l Level) (string, bool)

ForOpenAI returns the OpenAI reasoning_effort string for l. OpenAI accepts: minimal, low, medium, high, xhigh.

func IsValid

func IsValid(s string) bool

IsValid reports whether s is a recognised thinking_budget effort value. It accepts every Level constant, plain "adaptive", and the "adaptive/<effort>" form.

func IsValidAdaptive

func IsValidAdaptive(sub string) bool

IsValidAdaptive reports whether sub is a valid effort for "adaptive/<sub>".

func ValidNames

func ValidNames() string

ValidNames returns a human-readable list of accepted values, suitable for error messages.

Types

type Level

type Level string

Level represents a thinking effort level.

const (
	None    Level = "none"
	Minimal Level = "minimal"
	Low     Level = "low"
	Medium  Level = "medium"
	High    Level = "high"
	XHigh   Level = "xhigh"
	Max     Level = "max"
)

func Clamp added in v1.80.0

func Clamp(supported []Level, requested Level) Level

Clamp maps requested onto the nearest level in supported. When requested is already supported it is returned unchanged. Otherwise the canonical ordering is scanned upward (toward higher effort) first and then downward, so a too-precise request degrades to the closest tier the model accepts. Falls back to the first supported level, or None when supported is empty.

func NextSupportedLevel added in v1.80.0

func NextSupportedLevel(supported []Level, current Level) Level

NextSupportedLevel returns the level following current within supported, wrapping back to the first level. When current is not in supported (or supported is empty) the first supported level (or None) is returned.

func Parse

func Parse(s string) (Level, bool)

Parse normalises s (case-insensitive, trimmed) and returns the matching Level. It returns ("", false) for unknown strings, adaptive values, and empty input. Use IsValid for full validation including adaptive forms.

func SupportedLevels added in v1.80.0

func SupportedLevels(reasoning bool, m LevelMap) []Level

SupportedLevels returns the ordered subset of thinking-effort levels a model supports, derived from its reasoning capability and level map. Models that cannot reason only support None. A nil map is valid and yields every level except the explicit-only top tiers.

func (Level) String

func (l Level) String() string

String returns the string representation of the Level.

type LevelMap added in v1.80.0

type LevelMap map[Level]bool

LevelMap describes per-model thinking-level support. A level mapped to true is supported, a level mapped to false is explicitly unsupported, and an absent level is unspecified: supported by default, except for the explicit-only top tiers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL