INNER CODE UNIT · Python
_build_thinking_extra_body
TianGzlab/OmicsClaw · omicsclaw/surfaces/desktop/server.py:558
def _build_thinking_extra_body(
thinking: Any,
*,
provider: str = "",
model: str = "",
) -> dict[str, Any] | None:
"""Normalize optional thinking controls for provider-compatible requests.
The ``adaptive`` thinking type is a frontend UX concept, not a portable
provider contract. This function resolves it to a concrete action based
on the active provider and model:
* **Native providers** (e.g. ``deepseek``): ``adaptive`` → ``enabled``
with a default budget so that reasoning tokens are always generated.
* **Incompatible providers** (e.g. ``siliconflow``): ``adaptive`` → omit
the field entirely to avoid gateway errors.
* **Gateway providers** (e.g. ``openrouter``, ``nvidia``): check whether
the selected *model* name matches a known thinking-capable pattern; if