mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
Merge pull request #17071 from BerriAI/litellm_azure_gpt_5_reasoning
Fix `reasoning_effort="none"` not working on Azure for GPT-5.1
This commit is contained in:
commit
2e50db81a5
2 changed files with 56 additions and 4 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
from typing import List
|
||||
|
||||
import litellm
|
||||
from litellm.exceptions import UnsupportedParamsError
|
||||
from litellm.llms.openai.chat.gpt_5_transformation import OpenAIGPT5Config
|
||||
from litellm.types.llms.openai import AllMessageValues
|
||||
|
||||
|
|
@ -33,7 +35,34 @@ class AzureOpenAIGPT5Config(AzureOpenAIConfig, OpenAIGPT5Config):
|
|||
drop_params: bool,
|
||||
api_version: str = "",
|
||||
) -> dict:
|
||||
return OpenAIGPT5Config.map_openai_params(
|
||||
reasoning_effort_value = (
|
||||
non_default_params.get("reasoning_effort")
|
||||
or optional_params.get("reasoning_effort")
|
||||
)
|
||||
|
||||
if reasoning_effort_value == "none":
|
||||
if litellm.drop_params is True or (
|
||||
drop_params is not None and drop_params is True
|
||||
):
|
||||
non_default_params = non_default_params.copy()
|
||||
optional_params = optional_params.copy()
|
||||
if non_default_params.get("reasoning_effort") == "none":
|
||||
non_default_params.pop("reasoning_effort")
|
||||
if optional_params.get("reasoning_effort") == "none":
|
||||
optional_params.pop("reasoning_effort")
|
||||
else:
|
||||
raise UnsupportedParamsError(
|
||||
status_code=400,
|
||||
message=(
|
||||
"Azure OpenAI does not support reasoning_effort='none'. "
|
||||
"Supported values are: 'low', 'medium', and 'high'. "
|
||||
"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"
|
||||
),
|
||||
)
|
||||
|
||||
result = OpenAIGPT5Config.map_openai_params(
|
||||
self,
|
||||
non_default_params=non_default_params,
|
||||
optional_params=optional_params,
|
||||
|
|
@ -41,6 +70,11 @@ class AzureOpenAIGPT5Config(AzureOpenAIConfig, OpenAIGPT5Config):
|
|||
drop_params=drop_params,
|
||||
)
|
||||
|
||||
if result.get("reasoning_effort") == "none":
|
||||
result.pop("reasoning_effort")
|
||||
|
||||
return result
|
||||
|
||||
def transform_request(
|
||||
self,
|
||||
model: str,
|
||||
|
|
|
|||
|
|
@ -104,16 +104,34 @@ 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'."""
|
||||
"""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.
|
||||
"""
|
||||
params = config.map_openai_params(
|
||||
non_default_params={"temperature": 0.5, "reasoning_effort": "none"},
|
||||
optional_params={},
|
||||
model="azure/gpt-5.1",
|
||||
drop_params=False,
|
||||
drop_params=True,
|
||||
api_version="2024-05-01-preview",
|
||||
)
|
||||
assert params["temperature"] == 0.5
|
||||
assert params["reasoning_effort"] == "none"
|
||||
# Azure doesn't support reasoning_effort="none", so it should be dropped
|
||||
assert "reasoning_effort" not in params or 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_temperature_without_reasoning_effort(config: AzureOpenAIGPT5Config):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue