From cf83b541e5c59ab9ba6fa42686f0ba9863c2e911 Mon Sep 17 00:00:00 2001 From: Krish Dholakia Date: Fri, 20 Jun 2025 09:40:33 -0700 Subject: [PATCH] Volcengine - thinking param support + Azure - handle more gpt custom naming patterns (#11914) * fix(volcengine.py): add thinking param support Closes https://github.com/BerriAI/litellm/issues/11879 * fix(gpt_transformation.py): handle azure custom names - e.g. `gpt-4-1` Closes https://github.com/BerriAI/litellm/issues/11834 --- litellm/llms/azure/chat/gpt_transformation.py | 9 ++++- litellm/llms/volcengine.py | 1 + .../test_azure_chat_gpt_transformation.py | 15 ++++++++ tests/test_litellm/llms/test_volcengine.py | 38 +++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 tests/test_litellm/llms/azure/chat/test_azure_chat_gpt_transformation.py create mode 100644 tests/test_litellm/llms/test_volcengine.py diff --git a/litellm/llms/azure/chat/gpt_transformation.py b/litellm/llms/azure/chat/gpt_transformation.py index 2ae684ddaeb..97a044cf01a 100644 --- a/litellm/llms/azure/chat/gpt_transformation.py +++ b/litellm/llms/azure/chat/gpt_transformation.py @@ -116,7 +116,14 @@ class AzureOpenAIConfig(BaseConfig): """ if "4o" in model: return True - elif supports_response_schema(model): + + # Normalize model name by replacing dashes between numbers with dots + # e.g., gpt-4-1 -> gpt-4.1, gpt-3-5-turbo -> gpt-3.5-turbo + import re + + normalized_model = re.sub(r"(\d)-(\d)", r"\1.\2", model) + + if supports_response_schema(normalized_model): return True return False diff --git a/litellm/llms/volcengine.py b/litellm/llms/volcengine.py index e4a78104f48..c569475b11c 100644 --- a/litellm/llms/volcengine.py +++ b/litellm/llms/volcengine.py @@ -61,4 +61,5 @@ class VolcEngineConfig(OpenAILikeChatConfig): "functions", "max_retries", "extra_headers", + "thinking", ] # works across all models diff --git a/tests/test_litellm/llms/azure/chat/test_azure_chat_gpt_transformation.py b/tests/test_litellm/llms/azure/chat/test_azure_chat_gpt_transformation.py new file mode 100644 index 00000000000..c4bf7a3300e --- /dev/null +++ b/tests/test_litellm/llms/azure/chat/test_azure_chat_gpt_transformation.py @@ -0,0 +1,15 @@ +import os +import sys + +sys.path.insert( + 0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../..")) +) + +from litellm.llms.azure.chat.gpt_transformation import AzureOpenAIConfig + + +class TestAzureOpenAIConfig: + def test_is_response_format_supported_model(self): + config = AzureOpenAIConfig() + assert config._is_response_format_supported_model("gpt-4.1") + assert config._is_response_format_supported_model("gpt-4-1") diff --git a/tests/test_litellm/llms/test_volcengine.py b/tests/test_litellm/llms/test_volcengine.py new file mode 100644 index 00000000000..cb9bc0f521c --- /dev/null +++ b/tests/test_litellm/llms/test_volcengine.py @@ -0,0 +1,38 @@ +import os +import sys + +from pydantic import BaseModel + +from litellm.llms.volcengine import VolcEngineConfig +from litellm.utils import get_optional_params + + +class TestVolcEngineConfig: + def test_get_optional_params(self): + config = VolcEngineConfig() + supported_params = config.get_supported_openai_params(model="doubao-seed-1.6") + assert "thinking" in supported_params + + mapped_params = config.map_openai_params( + non_default_params={ + "thinking": {"type": "disabled"}, + }, + optional_params={}, + model="doubao-seed-1.6", + drop_params=False, + ) + + assert mapped_params == { + "thinking": {"type": "disabled"}, + } + + e2e_mapped_params = get_optional_params( + model="doubao-seed-1.6", + custom_llm_provider="volcengine", + thinking={"type": "enabled"}, + drop_params=False, + ) + + assert "thinking" in e2e_mapped_params and e2e_mapped_params["thinking"] == { + "type": "enabled", + }