mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
fix(deepseek): forward output_config.effort and thinking as sent on /v1/messages
This commit is contained in:
parent
73aaf9e3da
commit
df53f7a615
2 changed files with 50 additions and 0 deletions
|
|
@ -42,6 +42,10 @@ class DeepSeekAnthropicMessagesConfig(AnthropicMessagesConfig):
|
|||
It accepts the native Anthropic Messages conversation shape, including
|
||||
thinking blocks in assistant history, but rejects Anthropic's explicit
|
||||
custom-tool discriminator (`{"type": "custom"}`).
|
||||
|
||||
It reads `thinking` and `output_config.effort` natively (ignoring
|
||||
`budget_tokens`) and accepts any `temperature`, so the Claude-specific
|
||||
effort and temperature reshaping is skipped.
|
||||
"""
|
||||
|
||||
@property
|
||||
|
|
@ -115,6 +119,18 @@ class DeepSeekAnthropicMessagesConfig(AnthropicMessagesConfig):
|
|||
|
||||
return join_api_base(base_url, "v1/messages")
|
||||
|
||||
@staticmethod
|
||||
def _translate_adaptive_effort_for_non_adaptive_model(
|
||||
model: str, optional_params: Mapping[str, object], max_tokens: int | None, custom_llm_provider: str
|
||||
) -> None:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _drop_incompatible_temperature_for_thinking(
|
||||
model: str, optional_params: Mapping[str, object], custom_llm_provider: str
|
||||
) -> None:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _sanitize_tools_for_deepseek(tools: object) -> object:
|
||||
if not isinstance(tools, list):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import pytest
|
||||
|
||||
import litellm
|
||||
from litellm.llms.anthropic.messages.native.transformation import (
|
||||
AnthropicMessagesConfig,
|
||||
|
|
@ -187,3 +189,35 @@ def test_deepseek_anthropic_messages_preserves_thinking_and_sanitizes_custom_too
|
|||
"input_schema": {"type": "object"},
|
||||
}
|
||||
assert request["tools"][1]["type"] == "web_search_20260209"
|
||||
|
||||
|
||||
def _deepseek_messages_request(optional_params: dict) -> dict:
|
||||
return DeepSeekAnthropicMessagesConfig().transform_anthropic_messages_request(
|
||||
model="deepseek-v4-pro",
|
||||
messages=[{"role": "user", "content": "Hi"}],
|
||||
anthropic_messages_optional_request_params={"max_tokens": 32000, **optional_params},
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
headers={},
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("effort", ["max", "low", "none", "ultra"])
|
||||
def test_deepseek_anthropic_messages_forwards_effort_as_sent(effort):
|
||||
request = _deepseek_messages_request({"output_config": {"effort": effort}})
|
||||
|
||||
assert request["output_config"] == {"effort": effort}
|
||||
assert "thinking" not in request
|
||||
|
||||
|
||||
def test_deepseek_anthropic_messages_forwards_adaptive_thinking_with_effort():
|
||||
request = _deepseek_messages_request({"thinking": {"type": "adaptive"}, "output_config": {"effort": "max"}})
|
||||
|
||||
assert request["thinking"] == {"type": "adaptive"}
|
||||
assert request["output_config"] == {"effort": "max"}
|
||||
|
||||
|
||||
def test_deepseek_anthropic_messages_keeps_temperature_with_effort_none():
|
||||
request = _deepseek_messages_request({"output_config": {"effort": "none"}, "temperature": 0})
|
||||
|
||||
assert request["output_config"] == {"effort": "none"}
|
||||
assert request["temperature"] == 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue