fix(deepseek): map minimal reasoning effort to low
This commit is contained in:
1 parent
cb03b0938d
commit
ff339e592e
2 files changed
+34
-14
No files matched your search
@@ -967,6 +967,9 @@ class OpenAICompatProvider(LLMProvider):
|
|||||||
if spec and spec.name == "dashscope" and semantic_effort == "minimal":
|
if spec and spec.name == "dashscope" and semantic_effort == "minimal":
|
||||||
# DashScope accepts none/minimum/low/medium/high/xhigh; "minimal" 400s.
|
# DashScope accepts none/minimum/low/medium/high/xhigh; "minimal" 400s.
|
||||||
wire_effort = "minimum"
|
wire_effort = "minimum"
|
||||||
|
elif spec and spec.name == "deepseek" and semantic_effort == "minimal":
|
||||||
|
# DeepSeek's minimal alias enables low-effort thinking.
|
||||||
|
semantic_effort = wire_effort = "low"
|
||||||
|
|
||||||
# Magistral and other providers where reasoning is implicit reject the
|
# Magistral and other providers where reasoning is implicit reject the
|
||||||
# reasoning_effort kwarg entirely. Strip it before the remap so we don't
|
# reasoning_effort kwarg entirely. Strip it before the remap so we don't
|
||||||
|
|||||||
@@ -1577,10 +1577,28 @@ def test_deepseek_thinking_enabled() -> None:
|
|||||||
assert kw["extra_body"] == {"thinking": {"type": "enabled"}}
|
assert kw["extra_body"] == {"thinking": {"type": "enabled"}}
|
||||||
|
|
||||||
|
|
||||||
def test_deepseek_thinking_disabled_for_minimal() -> None:
|
@pytest.mark.parametrize(
|
||||||
"""reasoning_effort='minimal' must send thinking.type=disabled to DeepSeek."""
|
"effort, wire_effort, thinking_type",
|
||||||
kw = _build_kwargs_for("deepseek", "deepseek-v4-pro", reasoning_effort="minimal")
|
[
|
||||||
assert kw["extra_body"] == {"thinking": {"type": "disabled"}}
|
("minimal", "low", "enabled"),
|
||||||
|
("low", "low", "enabled"),
|
||||||
|
("none", None, "disabled"),
|
||||||
|
(None, None, None),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_deepseek_reasoning_effort_controls(
|
||||||
|
effort: str | None, wire_effort: str | None, thinking_type: str | None,
|
||||||
|
) -> None:
|
||||||
|
"""DeepSeek's minimal alias enables low-effort thinking; none disables it."""
|
||||||
|
kw = _build_kwargs_for("deepseek", "deepseek-flash", reasoning_effort=effort)
|
||||||
|
if wire_effort is None:
|
||||||
|
assert "reasoning_effort" not in kw
|
||||||
|
else:
|
||||||
|
assert kw["reasoning_effort"] == wire_effort
|
||||||
|
if thinking_type is None:
|
||||||
|
assert "extra_body" not in kw
|
||||||
|
else:
|
||||||
|
assert kw["extra_body"] == {"thinking": {"type": thinking_type}}
|
||||||
|
|
||||||
|
|
||||||
def test_deepseek_backfills_reasoning_content_on_legacy_tool_call_messages() -> None:
|
def test_deepseek_backfills_reasoning_content_on_legacy_tool_call_messages() -> None:
|
||||||
@@ -1623,15 +1641,14 @@ def test_backfill_does_not_touch_messages_when_thinking_explicitly_off() -> None
|
|||||||
{"role": "tool", "tool_call_id": "tc1", "content": "result"},
|
{"role": "tool", "tool_call_id": "tc1", "content": "result"},
|
||||||
{"role": "user", "content": "thanks"},
|
{"role": "user", "content": "thanks"},
|
||||||
]
|
]
|
||||||
for effort in ("minimal", "none"):
|
kw = p._build_kwargs(
|
||||||
kw = p._build_kwargs(
|
messages=list(messages), tools=None, model="deepseek-v4-pro",
|
||||||
messages=list(messages), tools=None, model="deepseek-v4-pro",
|
max_tokens=1024, temperature=0.7,
|
||||||
max_tokens=1024, temperature=0.7,
|
reasoning_effort="none", tool_choice=None,
|
||||||
reasoning_effort=effort, tool_choice=None,
|
)
|
||||||
)
|
for msg in kw["messages"]:
|
||||||
for msg in kw["messages"]:
|
if msg.get("role") == "assistant" and msg.get("tool_calls"):
|
||||||
if msg.get("role") == "assistant" and msg.get("tool_calls"):
|
assert "reasoning_content" not in msg
|
||||||
assert "reasoning_content" not in msg
|
|
||||||
|
|
||||||
|
|
||||||
def test_deepseek_v4_backfills_incomplete_reasoning_history_when_effort_implicit() -> None:
|
def test_deepseek_v4_backfills_incomplete_reasoning_history_when_effort_implicit() -> None:
|
||||||
@@ -1704,7 +1721,7 @@ def test_deepseek_flash_backfills_missing_tool_history_reasoning(
|
|||||||
sent_assistant = kwargs["messages"][1]
|
sent_assistant = kwargs["messages"][1]
|
||||||
if history_reasoning is not None:
|
if history_reasoning is not None:
|
||||||
assert sent_assistant["reasoning_content"] == history_reasoning
|
assert sent_assistant["reasoning_content"] == history_reasoning
|
||||||
elif effort in ("none", "minimal"):
|
elif effort == "none":
|
||||||
assert "reasoning_content" not in sent_assistant
|
assert "reasoning_content" not in sent_assistant
|
||||||
else:
|
else:
|
||||||
assert sent_assistant["reasoning_content"] == ""
|
assert sent_assistant["reasoning_content"] == ""
|
||||||
|
|||||||
Reference in new issue
Block a user