mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-10 22:24:51 +00:00
Remove none support from reasoning param
This commit is contained in:
@@ -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,7 +104,12 @@ 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'.
|
||||
|
||||
Note: Azure OpenAI doesn't support reasoning_effort='none', so it's dropped from the params.
|
||||
However, 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={},
|
||||
@@ -113,7 +118,8 @@ def test_azure_gpt5_1_temperature_with_reasoning_effort_none(config: AzureOpenAI
|
||||
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_temperature_without_reasoning_effort(config: AzureOpenAIGPT5Config):
|
||||
|
||||
Reference in New Issue
Block a user