mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
fix(bedrock): drop thinking/reasoning_effort in converse mapping for DeepSeek
This commit is contained in:
parent
f06fdab04b
commit
f4ad6b0f0b
2 changed files with 42 additions and 1 deletions
|
|
@ -857,6 +857,9 @@ class AmazonConverseConfig(BaseConfig):
|
|||
drop_params: bool,
|
||||
) -> dict:
|
||||
is_thinking_enabled = self.is_thinking_enabled(non_default_params)
|
||||
accepts_thinking_param = self._model_accepts_anthropic_thinking_param(
|
||||
model=model, base_model=BedrockModelInfo.get_base_model(model)
|
||||
)
|
||||
|
||||
for param, value in non_default_params.items():
|
||||
if param == "response_format" and isinstance(value, dict):
|
||||
|
|
@ -906,7 +909,12 @@ class AmazonConverseConfig(BaseConfig):
|
|||
optional_params["_parallel_tool_use_config"] = {
|
||||
"tool_choice": {"disable_parallel_tool_use": disable_parallel}
|
||||
}
|
||||
if param == "thinking":
|
||||
if param == "thinking" and not accepts_thinking_param:
|
||||
verbose_logger.debug(
|
||||
"Dropping unsupported `thinking` param for Bedrock model=%s; it reasons natively and rejects it.",
|
||||
model,
|
||||
)
|
||||
elif param == "thinking":
|
||||
if (
|
||||
isinstance(value, dict)
|
||||
and value.get("type") == "adaptive"
|
||||
|
|
@ -929,6 +937,11 @@ class AmazonConverseConfig(BaseConfig):
|
|||
litellm.verbose_logger.warning(DROP_UNSUPPORTED_ADAPTIVE_THINKING_WARNING, model)
|
||||
else:
|
||||
optional_params["thinking"] = value
|
||||
elif param == "reasoning_effort" and isinstance(value, str) and not accepts_thinking_param:
|
||||
verbose_logger.debug(
|
||||
"Dropping unsupported `reasoning_effort` param for Bedrock model=%s; it reasons natively and rejects it.",
|
||||
model,
|
||||
)
|
||||
elif param == "reasoning_effort" and isinstance(value, str):
|
||||
self._handle_reasoning_effort_parameter(
|
||||
model=model, reasoning_effort=value, optional_params=optional_params
|
||||
|
|
|
|||
|
|
@ -605,6 +605,34 @@ def test_bedrock_deepseek_r1_thinking_dropped_does_not_leak_into_request():
|
|||
assert "thinking" not in request.get("additionalModelRequestFields", {})
|
||||
|
||||
|
||||
@pytest.mark.parametrize("param", ["thinking", "reasoning_effort"])
|
||||
def test_bedrock_deepseek_r1_reasoning_params_not_forwarded_by_map(param):
|
||||
"""Even when map_openai_params is called directly (bypassing the supported-params
|
||||
gate), DeepSeek R1 must not forward the Anthropic-shaped thinking/reasoning_effort
|
||||
into additionalModelRequestFields, since Bedrock rejects it with a 400."""
|
||||
config = AmazonConverseConfig()
|
||||
model = "bedrock/converse/us.deepseek.r1-v1:0"
|
||||
value = {"type": "enabled", "budget_tokens": 1024} if param == "thinking" else "high"
|
||||
|
||||
optional_params = config.map_openai_params(
|
||||
non_default_params={param: value, "max_tokens": 100},
|
||||
optional_params={},
|
||||
model=model,
|
||||
drop_params=False,
|
||||
)
|
||||
assert "thinking" not in optional_params
|
||||
assert "reasoning_effort" not in optional_params
|
||||
|
||||
request = config._transform_request(
|
||||
model=model,
|
||||
messages=[{"role": "user", "content": "Say hi in one word."}],
|
||||
optional_params=optional_params,
|
||||
litellm_params={},
|
||||
headers={},
|
||||
)
|
||||
assert request.get("additionalModelRequestFields") is None
|
||||
|
||||
|
||||
def test_get_supported_openai_params_bedrock_converse():
|
||||
"""
|
||||
Test that all documented bedrock converse models have the same set of supported openai params when using
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue