ooai_llm.reasoning¶
Provider-aware reasoning configuration.
- Purpose:
Normalize one ergonomic reasoning policy into provider-specific keyword arguments for chat-model construction.
- Design:
Accept either string presets or a typed configuration object.
Keep provider differences explicit through a structured resolution object that records notes about lossy mappings and unsupported options.
Focus on constructor kwargs consumed by
create_llm(...)while leaving room for future invoke-time configuration.
- Type aliases:
ReasoningPresetName: Semantic presets for common reasoning modes. ReasoningEffortName: Provider-agnostic effort scale. ReasoningSummaryName: Cross-provider summary visibility preference.
Examples
>>> from ooai_llm.types import ModelString
>>> resolution = build_reasoning_resolution(
... model=ModelString.parse("openai:gpt-5.4-mini"),
... reasoning="deep",
... )
>>> resolution.constructor_kwargs["reasoning"]["effort"]
'high'
>>> resolution.provider.value
'openai'
Attributes¶
Classes¶
Provider-agnostic reasoning preferences. |
|
Provider-specific reasoning kwargs resolution. |
Functions¶
|
Resolve provider-specific reasoning kwargs. |
Module Contents¶
- class ooai_llm.reasoning.ReasoningConfig(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelProvider-agnostic reasoning preferences.
- Parameters:
effort – Normalized reasoning effort.
summary – Desired reasoning-summary visibility.
budget_tokens – Optional explicit reasoning-budget token count.
dynamic_budget – Whether the provider should choose the budget when it exposes a dynamic mode.
include_thoughts – Whether provider-visible thought summaries should be included when supported.
strict – Whether unsupported or lossy mappings should raise errors.
Examples
>>> config = ReasoningConfig.from_preset("balanced") >>> config.effort 'medium' >>> config.summary 'auto'
- model_config[source]¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- effort: ReasoningEffortName = 'auto'[source]¶
- summary: ReasoningSummaryName = 'auto'[source]¶
- property enabled: bool[source]¶
Whether reasoning is conceptually enabled.
- Returns:
Truewhen reasoning is enabled or a nonzero budget is present.
- classmethod from_preset(preset: ReasoningPresetName) Self[source]¶
Build a configuration from a semantic preset.
- Parameters:
preset – Semantic preset name.
- Returns:
Normalized reasoning configuration.
- Raises:
ValueError – If the preset is unknown.
- classmethod normalize(reasoning: ReasoningInput) Self | None[source]¶
Normalize string or typed input into a config object.
- Parameters:
reasoning – Reasoning input.
- Returns:
Typed config or
Nonewhen reasoning is absent.- Raises:
ValueError – If the string value is unknown.
- type ooai_llm.reasoning.ReasoningInput = ReasoningConfig | ReasoningPresetName | ReasoningEffortName | None[source]¶
- class ooai_llm.reasoning.ReasoningResolution(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelProvider-specific reasoning kwargs resolution.
- Parameters:
model – Canonical model string.
provider – Resolved provider.
config – Normalized reasoning config.
constructor_kwargs – Keyword arguments suitable for chat-model construction.
invoke_kwargs – Reserved for future invoke-time reasoning configuration.
notes – Informational notes about ignored or lossy mappings.
Examples
>>> resolution = ReasoningResolution( ... model=ModelString.parse("openai:gpt-5.4"), ... provider=Provider.OPENAI, ... config=ReasoningConfig(), ... ) >>> resolution.constructor_kwargs {}
- model_config[source]¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- provider: ooai_llm.providers.Provider[source]¶
- config: ReasoningConfig[source]¶
- ooai_llm.reasoning.build_reasoning_resolution(*, model: str | ooai_llm.types.ModelString, provider: ooai_llm.providers.Provider | str | None = None, reasoning: ReasoningInput) ReasoningResolution | None[source]¶
Resolve provider-specific reasoning kwargs.
- Parameters:
model – Model string or typed model-string object.
provider – Optional explicit provider.
reasoning – Semantic preset, effort string, typed config, or
None.
- Returns:
Structured reasoning resolution or
Nonewhen reasoning is absent.