mirror of
https://github.com/usestrix/strix.git
synced 2026-11-12 08:41:23 +00:00
fix(llm): pass max reasoning effort to LiteLLM
This commit is contained in:
parent
8ca0c4a9b8
commit
1ad29e2a1e
2 changed files with 10 additions and 14 deletions
|
|
@ -219,7 +219,7 @@ def make_model_settings(
|
|||
and model_supports_reasoning(model_name)
|
||||
):
|
||||
model_settings = model_settings.resolve(
|
||||
_reasoning_settings(reasoning_effort, model_settings.extra_args),
|
||||
_reasoning_settings(reasoning_effort),
|
||||
)
|
||||
if force_required_tool_choice and _accepts_required_tool_choice(model_name):
|
||||
model_settings = model_settings.resolve(ModelSettings(tool_choice="required"))
|
||||
|
|
@ -247,18 +247,14 @@ def _request_headers(
|
|||
|
||||
def _reasoning_settings(
|
||||
effort: ReasoningEffort,
|
||||
extra_args: dict[str, Any] | None,
|
||||
) -> ModelSettings:
|
||||
"""``max`` is not in the OpenAI SDK's ``Reasoning.effort`` enum, so send it as
|
||||
a raw body field instead — also keeping it clear of LiteLLM's DeepSeek mapping,
|
||||
which collapses every ``reasoning_effort`` level to plain thinking-enabled.
|
||||
Providers that don't support ``max`` reject the request.
|
||||
"""``max`` is not in the OpenAI SDK's ``Reasoning.effort`` enum, so send it
|
||||
through ``extra_args`` for the LiteLLM model to promote to its top-level
|
||||
``reasoning_effort`` argument. Providers that don't support ``max`` reject it.
|
||||
"""
|
||||
if effort != "max":
|
||||
return ModelSettings(reasoning=Reasoning(effort=effort))
|
||||
return ModelSettings(
|
||||
extra_args={**(extra_args or {}), "extra_body": {"reasoning_effort": "max"}},
|
||||
)
|
||||
return ModelSettings(extra_args={"reasoning_effort": "max"})
|
||||
|
||||
|
||||
def _prompt_cache_extra_args(model_name: str) -> dict[str, Any] | None:
|
||||
|
|
|
|||
|
|
@ -134,15 +134,15 @@ def test_prompt_cache_kept_for_non_bedrock_claude_even_if_unmapped(monkeypatch:
|
|||
]
|
||||
|
||||
|
||||
def test_max_reasoning_effort_sent_as_raw_body_field() -> None:
|
||||
# "max" is absent from the OpenAI SDK's Reasoning enum, and LiteLLM's DeepSeek
|
||||
# mapping collapses every effort to thinking-enabled, so it has to ride along
|
||||
# as a raw body field to reach the provider.
|
||||
def test_max_reasoning_effort_sent_as_litellm_argument() -> None:
|
||||
# "max" is absent from the OpenAI SDK's Reasoning enum, so it has to use the
|
||||
# LiteLLM model's extra_args escape hatch to reach acompletion as a top-level
|
||||
# reasoning_effort argument.
|
||||
settings = make_model_settings(
|
||||
"max", model_name="deepseek/deepseek-v4-flash", request_timeout=30
|
||||
)
|
||||
assert settings.reasoning is None
|
||||
assert settings.extra_args == {"timeout": 30, "extra_body": {"reasoning_effort": "max"}}
|
||||
assert settings.extra_args == {"timeout": 30, "reasoning_effort": "max"}
|
||||
|
||||
|
||||
def test_conversation_tail_breakpoint_moves_with_appended_transcript() -> None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue