mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-07 06:29:41 +00:00
fix: use DeepSeekChatConfig instead of OpenAIConfig for deepseek provider (#22971)
* fix: use DeepSeekChatConfig instead of OpenAIConfig for deepseek provider The deepseek provider was incorrectly using OpenAIConfig().map_openai_params() instead of DeepSeekChatConfig().map_openai_params(), which meant DeepSeek-specific parameter mappings were not being applied. * test: add unit tests for deepseek DeepSeekChatConfig param mapping Verify that get_optional_params uses DeepSeekChatConfig (not OpenAIConfig) for the deepseek provider by testing thinking, reasoning_effort, and budget_tokens stripping behavior.
This commit is contained in:
+1
-1
@@ -4491,7 +4491,7 @@ def get_optional_params( # noqa: PLR0915
|
||||
),
|
||||
)
|
||||
elif custom_llm_provider == "deepseek":
|
||||
optional_params = litellm.OpenAIConfig().map_openai_params(
|
||||
optional_params = litellm.DeepSeekChatConfig().map_openai_params(
|
||||
non_default_params=non_default_params,
|
||||
optional_params=optional_params,
|
||||
model=model,
|
||||
|
||||
@@ -3473,6 +3473,53 @@ class TestDropParamsWithPromptCacheKey:
|
||||
assert result.get("temperature") == 0.7
|
||||
|
||||
|
||||
class TestGetOptionalParamsDeepSeek:
|
||||
"""Tests that deepseek provider uses DeepSeekChatConfig for parameter mapping."""
|
||||
|
||||
def test_deepseek_supports_thinking_param(self):
|
||||
"""
|
||||
Verify that get_optional_params for deepseek accepts the 'thinking' param,
|
||||
which is only supported by DeepSeekChatConfig, not OpenAIConfig.
|
||||
"""
|
||||
from litellm.utils import get_optional_params
|
||||
|
||||
result = get_optional_params(
|
||||
model="deepseek-reasoner",
|
||||
custom_llm_provider="deepseek",
|
||||
thinking={"type": "enabled"},
|
||||
)
|
||||
assert result.get("thinking") == {"type": "enabled"}
|
||||
|
||||
def test_deepseek_supports_reasoning_effort_param(self):
|
||||
"""
|
||||
Verify that get_optional_params for deepseek accepts 'reasoning_effort',
|
||||
which is only supported by DeepSeekChatConfig, not OpenAIConfig.
|
||||
"""
|
||||
from litellm.utils import get_optional_params
|
||||
|
||||
result = get_optional_params(
|
||||
model="deepseek-reasoner",
|
||||
custom_llm_provider="deepseek",
|
||||
reasoning_effort="high",
|
||||
)
|
||||
assert result.get("thinking") == {"type": "enabled"}
|
||||
|
||||
def test_deepseek_thinking_strips_budget_tokens(self):
|
||||
"""
|
||||
DeepSeekChatConfig strips budget_tokens from thinking param.
|
||||
This would not happen with OpenAIConfig.
|
||||
"""
|
||||
from litellm.utils import get_optional_params
|
||||
|
||||
result = get_optional_params(
|
||||
model="deepseek-reasoner",
|
||||
custom_llm_provider="deepseek",
|
||||
thinking={"type": "enabled", "budget_tokens": 5000},
|
||||
)
|
||||
assert "budget_tokens" not in result.get("thinking", {})
|
||||
assert result.get("thinking") == {"type": "enabled"}
|
||||
|
||||
|
||||
class TestIsStreamingRequest:
|
||||
def test_stream_true_in_kwargs(self):
|
||||
assert _is_streaming_request(kwargs={"stream": True}, call_type="acompletion") is True
|
||||
|
||||
Reference in New Issue
Block a user