mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
fix(openai/responses): drop unsupported temperature for o-series models when drop_params=True (#49927)
This commit is contained in:
parent
b18188dee2
commit
b4013e90bc
2 changed files with 25 additions and 2 deletions
|
|
@ -369,6 +369,20 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
|
|||
def _model_map_lookup_name(model: str) -> str:
|
||||
return model
|
||||
|
||||
@staticmethod
|
||||
def _without_unsupported_o_series_temperature(
|
||||
params: Mapping[str, object], model: str, drop_params: bool
|
||||
) -> Mapping[str, object]:
|
||||
temperature: Final = params.get("temperature")
|
||||
if (
|
||||
litellm.openaiOSeriesConfig.is_model_o_series_model(model=model)
|
||||
and temperature is not None
|
||||
and temperature != 1
|
||||
and (drop_params or litellm.drop_params)
|
||||
):
|
||||
return {key: value for key, value in params.items() if key != "temperature"}
|
||||
return params
|
||||
|
||||
@staticmethod
|
||||
def _supports_reasoning_effort_none(model: str) -> bool:
|
||||
"""Return True if the model supports reasoning.effort='none'."""
|
||||
|
|
@ -585,8 +599,7 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
|
|||
),
|
||||
status_code=400,
|
||||
)
|
||||
|
||||
return params
|
||||
return self._without_unsupported_o_series_temperature(params, lookup_name, drop_params)
|
||||
|
||||
def transform_responses_api_request(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -2383,6 +2383,16 @@ class TestPromptCacheOptionsOnResponsesPath:
|
|||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("temperature", "survives"), ((0.5, False), (1, True)))
|
||||
def test_o_series_responses_temperature_follows_the_chat_rule(temperature: float, survives: bool) -> None:
|
||||
mapped: Final = OpenAIResponsesAPIConfig().map_openai_params(
|
||||
response_api_optional_params={"temperature": temperature},
|
||||
model="o3-mini",
|
||||
drop_params=True,
|
||||
)
|
||||
assert ("temperature" in mapped) is survives
|
||||
|
||||
|
||||
class TestResponsesSurfaceSharesTheEffortRule:
|
||||
"""The Responses API reaches the same gpt-5 models over a different wire, and the default
|
||||
/v1/messages bridge for openai models routes through it. It carried its own copy of the
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue