mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-19 00:01:29 +00:00
fix(deepseek): allow thinking parameter to accept "disabled" type
This commit is contained in:
parent
6068bdf3e8
commit
9dacaf3957
2 changed files with 21 additions and 7 deletions
|
|
@ -47,14 +47,14 @@ class DeepSeekChatConfig(OpenAIGPTConfig):
|
|||
thinking_value = optional_params.pop("thinking", None)
|
||||
reasoning_effort = optional_params.pop("reasoning_effort", None)
|
||||
|
||||
# Handle thinking parameter - only accept {"type": "enabled"}
|
||||
# Handle thinking parameter - accept {"type": "enabled"} or {"type": "disabled"}
|
||||
if thinking_value is not None:
|
||||
if (
|
||||
isinstance(thinking_value, dict)
|
||||
and thinking_value.get("type") == "enabled"
|
||||
):
|
||||
# DeepSeek only accepts {"type": "enabled"}, ignore budget_tokens
|
||||
optional_params["thinking"] = {"type": "enabled"}
|
||||
if isinstance(thinking_value, dict) and thinking_value.get(
|
||||
"type"
|
||||
) in ("enabled", "disabled"):
|
||||
optional_params["thinking"] = {
|
||||
"type": thinking_value["type"]
|
||||
}
|
||||
|
||||
# Handle reasoning_effort - map to thinking enabled/disabled
|
||||
elif reasoning_effort is not None:
|
||||
|
|
|
|||
|
|
@ -139,6 +139,20 @@ class TestDeepSeekThinkingParams:
|
|||
# thinking should be set, reasoning_effort should not override
|
||||
assert result["thinking"] == {"type": "enabled"}
|
||||
|
||||
def test_map_thinking_disabled(self):
|
||||
"""Test that thinking={"type": "disabled"} is passed through correctly."""
|
||||
non_default_params = {"thinking": {"type": "disabled"}}
|
||||
optional_params = {}
|
||||
|
||||
result = self.config.map_openai_params(
|
||||
non_default_params=non_default_params,
|
||||
optional_params=optional_params,
|
||||
model=self.model,
|
||||
drop_params=False,
|
||||
)
|
||||
|
||||
assert result["thinking"] == {"type": "disabled"}
|
||||
|
||||
def test_invalid_thinking_type_ignored(self):
|
||||
"""Test that invalid thinking type values are ignored."""
|
||||
non_default_params = {"thinking": {"type": "invalid"}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue