mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
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
This commit is contained in:
parent
d6ba114aff
commit
b2acb3d845
3 changed files with 10 additions and 8 deletions
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue