mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
fix(responses): dispatch effort capability check by provider and drop test monkeypatching - Azure responses config reads Azure map entry (OpenAI entry disables minimal on gpt-5.4, Azure enables it); temperature revalidation test now uses real gpt-5.1 map data
This commit is contained in:
parent
257224cd65
commit
0764a0a923
2 changed files with 42 additions and 7 deletions
|
|
@ -38,6 +38,15 @@ class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
def _effort_resolves_to_none(model: str, effort: str | None) -> bool:
|
||||
return AzureOpenAIGPT5Config.effort_resolves_to_none(model, effort)
|
||||
|
||||
@staticmethod
|
||||
def _is_unsupported_reasoning_effort(model: str, effort: str | None) -> bool:
|
||||
"""Read the effort capability from the Azure map entry, like the sibling checks above.
|
||||
|
||||
The inherited OpenAI lookup would resolve a bare Azure deployment name (e.g. ``gpt-5.4``)
|
||||
against the OpenAI entry, which can explicitly disable an effort Azure supports.
|
||||
"""
|
||||
return AzureOpenAIGPT5Config.is_reasoning_effort_unsupported(model, effort)
|
||||
|
||||
def get_supported_openai_params(self, model: str) -> list:
|
||||
"""
|
||||
Azure Responses API does not support context_management (compaction).
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import pytest
|
||||
|
||||
import litellm
|
||||
from litellm.llms.openai.chat.gpt_5_transformation import OpenAIGPT5Config
|
||||
from litellm.llms.azure.responses.transformation import AzureOpenAIResponsesAPIConfig
|
||||
from litellm.llms.openai.responses.transformation import OpenAIResponsesAPIConfig
|
||||
|
||||
|
||||
|
|
@ -41,18 +41,44 @@ def test_drop_params_removes_only_unsupported_effort() -> None:
|
|||
assert result["reasoning"] == {"summary": "detailed"}
|
||||
|
||||
|
||||
def test_drop_params_revalidates_temperature_after_effort_drop(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
config = OpenAIResponsesAPIConfig()
|
||||
def test_drop_params_revalidates_temperature_after_effort_drop() -> None:
|
||||
"""Dropping an unsupported effort revalidates temperature against the emptied effort.
|
||||
|
||||
monkeypatch.setattr(OpenAIGPT5Config, "_supports_reasoning_effort_level", lambda model, level: False)
|
||||
monkeypatch.setattr(config, "_supports_reasoning_effort_none", lambda model: True)
|
||||
monkeypatch.setattr(config, "_effort_resolves_to_none", lambda model, effort: effort is None)
|
||||
`gpt-5.1` really declares `xhigh` unsupported while supporting (and defaulting to)
|
||||
`none`, so no capability stubbing is needed: the dropped effort resolves to `none`
|
||||
and a valid non-default temperature survives.
|
||||
"""
|
||||
config = OpenAIResponsesAPIConfig()
|
||||
|
||||
result = config.map_openai_params(
|
||||
response_api_optional_params={"reasoning": {"effort": "xhigh"}, "temperature": 0.5},
|
||||
model="gpt-5-test",
|
||||
model="gpt-5.1",
|
||||
drop_params=True,
|
||||
)
|
||||
|
||||
assert "reasoning" not in result
|
||||
assert result["temperature"] == 0.5
|
||||
|
||||
|
||||
def test_azure_config_uses_azure_capability_map_for_effort() -> None:
|
||||
"""A bare Azure deployment name must resolve against the Azure map entry.
|
||||
|
||||
OpenAI's `gpt-5.4` entry explicitly disables `minimal` while Azure's enables it;
|
||||
the OpenAI lookup would wrongly reject an effort Azure supports.
|
||||
"""
|
||||
openai_config = OpenAIResponsesAPIConfig()
|
||||
with pytest.raises(litellm.UnsupportedParamsError, match="reasoning.effort=minimal"):
|
||||
openai_config.map_openai_params(
|
||||
response_api_optional_params={"reasoning": {"effort": "minimal"}},
|
||||
model="gpt-5.4",
|
||||
drop_params=False,
|
||||
)
|
||||
|
||||
azure_config = AzureOpenAIResponsesAPIConfig()
|
||||
result = azure_config.map_openai_params(
|
||||
response_api_optional_params={"reasoning": {"effort": "minimal"}},
|
||||
model="gpt-5.4",
|
||||
drop_params=False,
|
||||
)
|
||||
|
||||
assert result["reasoning"] == {"effort": "minimal"}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue