Merge pull request #17311 from Chesars/fix/azure-gpt5.1-reasoning-effort-none
Fix: Allow reasoning_effort='none' for Azure gpt-5.1 models
This commit is contained in:
commit
50fc30644e
@ -40,7 +40,11 @@ class AzureOpenAIGPT5Config(AzureOpenAIConfig, OpenAIGPT5Config):
|
||||
or optional_params.get("reasoning_effort")
|
||||
)
|
||||
|
||||
if reasoning_effort_value == "none":
|
||||
# gpt-5.1 supports reasoning_effort='none', but other gpt-5 models don't
|
||||
# See: https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/reasoning
|
||||
is_gpt_5_1 = self.is_model_gpt_5_1_model(model)
|
||||
|
||||
if reasoning_effort_value == "none" and not is_gpt_5_1:
|
||||
if litellm.drop_params is True or (
|
||||
drop_params is not None and drop_params is True
|
||||
):
|
||||
@ -54,8 +58,9 @@ class AzureOpenAIGPT5Config(AzureOpenAIConfig, OpenAIGPT5Config):
|
||||
raise UnsupportedParamsError(
|
||||
status_code=400,
|
||||
message=(
|
||||
"Azure OpenAI does not support reasoning_effort='none'. "
|
||||
"Azure OpenAI does not support reasoning_effort='none' for this model. "
|
||||
"Supported values are: 'low', 'medium', and 'high'. "
|
||||
"Note: gpt-5.1 does support reasoning_effort='none'. "
|
||||
"To drop this parameter, set `litellm.drop_params=True` or for proxy:\n\n"
|
||||
"`litellm_settings:\n drop_params: true`\n"
|
||||
"Issue: https://github.com/BerriAI/litellm/issues/16704"
|
||||
@ -70,7 +75,8 @@ class AzureOpenAIGPT5Config(AzureOpenAIConfig, OpenAIGPT5Config):
|
||||
drop_params=drop_params,
|
||||
)
|
||||
|
||||
if result.get("reasoning_effort") == "none":
|
||||
# Only drop reasoning_effort='none' for non-gpt-5.1 models
|
||||
if result.get("reasoning_effort") == "none" and not is_gpt_5_1:
|
||||
result.pop("reasoning_effort")
|
||||
|
||||
return result
|
||||
|
||||
@ -104,34 +104,33 @@ def test_azure_gpt5_codex_series_transform_request(config: AzureOpenAIGPT5Config
|
||||
|
||||
# GPT-5.1 temperature handling tests for Azure
|
||||
def test_azure_gpt5_1_temperature_with_reasoning_effort_none(config: AzureOpenAIGPT5Config):
|
||||
"""Test that Azure GPT-5.1 supports any temperature when reasoning_effort='none' and drop_params=True.
|
||||
|
||||
Note: Azure OpenAI doesn't support reasoning_effort='none', so it's dropped from the params
|
||||
when drop_params=True. The temperature logic still works correctly because the parent treats
|
||||
missing reasoning_effort the same as 'none' for gpt-5.1.
|
||||
"""Test that Azure GPT-5.1 supports any temperature when reasoning_effort='none'.
|
||||
|
||||
Azure OpenAI supports reasoning_effort='none' for gpt-5.1 models.
|
||||
See: https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/reasoning
|
||||
"""
|
||||
params = config.map_openai_params(
|
||||
non_default_params={"temperature": 0.5, "reasoning_effort": "none"},
|
||||
optional_params={},
|
||||
model="azure/gpt-5.1",
|
||||
drop_params=True,
|
||||
drop_params=False,
|
||||
api_version="2024-05-01-preview",
|
||||
)
|
||||
assert params["temperature"] == 0.5
|
||||
# Azure doesn't support reasoning_effort="none", so it should be dropped
|
||||
assert "reasoning_effort" not in params or params.get("reasoning_effort") != "none"
|
||||
# Azure supports reasoning_effort="none" for gpt-5.1
|
||||
assert params.get("reasoning_effort") == "none"
|
||||
|
||||
|
||||
def test_azure_gpt5_1_reasoning_effort_none_error_when_drop_params_false(config: AzureOpenAIGPT5Config):
|
||||
"""Test that Azure GPT-5.1 raises error for reasoning_effort='none' when drop_params=False."""
|
||||
with pytest.raises(litellm.utils.UnsupportedParamsError):
|
||||
config.map_openai_params(
|
||||
non_default_params={"reasoning_effort": "none"},
|
||||
optional_params={},
|
||||
model="azure/gpt-5.1",
|
||||
drop_params=False,
|
||||
api_version="2024-05-01-preview",
|
||||
)
|
||||
def test_azure_gpt5_1_reasoning_effort_none_supported(config: AzureOpenAIGPT5Config):
|
||||
"""Test that Azure GPT-5.1 supports reasoning_effort='none' without error."""
|
||||
params = config.map_openai_params(
|
||||
non_default_params={"reasoning_effort": "none"},
|
||||
optional_params={},
|
||||
model="azure/gpt-5.1",
|
||||
drop_params=False,
|
||||
api_version="2024-05-01-preview",
|
||||
)
|
||||
assert params.get("reasoning_effort") == "none"
|
||||
|
||||
|
||||
def test_azure_gpt5_1_temperature_without_reasoning_effort(config: AzureOpenAIGPT5Config):
|
||||
@ -181,3 +180,27 @@ def test_azure_gpt5_1_series_temperature_handling(config: AzureOpenAIGPT5Config)
|
||||
)
|
||||
assert params["temperature"] == 0.6
|
||||
|
||||
|
||||
def test_azure_gpt5_reasoning_effort_none_error(config: AzureOpenAIGPT5Config):
|
||||
"""Test that Azure GPT-5 (non-5.1) raises error for reasoning_effort='none' when drop_params=False."""
|
||||
with pytest.raises(litellm.utils.UnsupportedParamsError):
|
||||
config.map_openai_params(
|
||||
non_default_params={"reasoning_effort": "none"},
|
||||
optional_params={},
|
||||
model="azure/gpt-5",
|
||||
drop_params=False,
|
||||
api_version="2024-05-01-preview",
|
||||
)
|
||||
|
||||
|
||||
def test_azure_gpt5_reasoning_effort_none_dropped(config: AzureOpenAIGPT5Config):
|
||||
"""Test that Azure GPT-5 (non-5.1) drops reasoning_effort='none' when drop_params=True."""
|
||||
params = config.map_openai_params(
|
||||
non_default_params={"reasoning_effort": "none"},
|
||||
optional_params={},
|
||||
model="azure/gpt-5",
|
||||
drop_params=True,
|
||||
api_version="2024-05-01-preview",
|
||||
)
|
||||
assert "reasoning_effort" not in params or params.get("reasoning_effort") != "none"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user