From b2acb3d845968c089064e0d3f870e70736f86365 Mon Sep 17 00:00:00 2001 From: V <815559417@qq.com> Date: Thu, 19 Mar 2026 15:24:28 +0800 Subject: [PATCH] fix(dashscope): address PR review feedback for Responses API config - Add supports_native_websocket() returning False (DashScope has no native WS) - Remove metadata from _SUPPORTED_OPTIONAL_PARAMS (was contradictory) - Add DashScopeResponsesAPIConfig to TYPE_CHECKING block in __init__.py - Fix get_complete_url fallback to use /responses for custom proxy URLs --- litellm/__init__.py | 3 +++ litellm/llms/dashscope/responses/transformation.py | 13 ++++++------- .../test_dashscope_responses_transformation.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/litellm/__init__.py b/litellm/__init__.py index e45d926e8db..818160ee039 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -1632,6 +1632,9 @@ if TYPE_CHECKING: from .llms.volcengine.responses.transformation import ( VolcEngineResponsesAPIConfig as VolcEngineResponsesAPIConfig, ) + from .llms.dashscope.responses.transformation import ( + DashScopeResponsesAPIConfig as DashScopeResponsesAPIConfig, + ) from .llms.manus.responses.transformation import ( ManusResponsesAPIConfig as ManusResponsesAPIConfig, ) diff --git a/litellm/llms/dashscope/responses/transformation.py b/litellm/llms/dashscope/responses/transformation.py index d654bbfcf50..89dff05f2ce 100644 --- a/litellm/llms/dashscope/responses/transformation.py +++ b/litellm/llms/dashscope/responses/transformation.py @@ -23,7 +23,6 @@ _DEFAULT_API_BASE = "https://dashscope.aliyuncs.com/compatible-mode/v1" _SUPPORTED_OPTIONAL_PARAMS: List[str] = [ "instructions", "max_output_tokens", - "metadata", "previous_response_id", "reasoning", "store", @@ -48,13 +47,13 @@ class DashScopeResponsesAPIConfig(OpenAIResponsesAPIConfig): def custom_llm_provider(self) -> LlmProviders: return LlmProviders.DASHSCOPE + def supports_native_websocket(self) -> bool: + """DashScope compatible-mode does not expose a native WebSocket endpoint.""" + return False + def get_supported_openai_params(self, model: str) -> list: """Return the parameter whitelist for DashScope Responses API.""" - supported = ["input", "model"] + list(_SUPPORTED_OPTIONAL_PARAMS) - # metadata is LiteLLM-internal; advertise all others - if "metadata" in supported: - supported.remove("metadata") - return supported + return ["input", "model"] + list(_SUPPORTED_OPTIONAL_PARAMS) def map_openai_params( self, @@ -125,7 +124,7 @@ class DashScopeResponsesAPIConfig(OpenAIResponsesAPIConfig): return f"{base_url}/responses" if base_url.endswith("/compatible-mode/v1"): return f"{base_url}/responses" - return f"{base_url}/compatible-mode/v1/responses" + return f"{base_url}/responses" def get_error_class( self, diff --git a/tests/test_litellm/llms/dashscope/responses/test_dashscope_responses_transformation.py b/tests/test_litellm/llms/dashscope/responses/test_dashscope_responses_transformation.py index 9d4adca04e3..963e3fd555b 100644 --- a/tests/test_litellm/llms/dashscope/responses/test_dashscope_responses_transformation.py +++ b/tests/test_litellm/llms/dashscope/responses/test_dashscope_responses_transformation.py @@ -63,7 +63,7 @@ class TestDashScopeResponsesAPITransformation: url = config.get_complete_url( api_base="https://custom.example.com", litellm_params={} ) - assert url == "https://custom.example.com/compatible-mode/v1/responses" + assert url == "https://custom.example.com/responses" @pytest.mark.parametrize( "litellm_params, expected_key",