fix(llm): route all DashScope models through native provider (#7234)

DashScope's OpenAI-compatible endpoint serves DeepSeek/Kimi/GLM/etc.,
not only Qwen. Stop restricting the native match to the qwen* prefix so
DASHSCOPE_BASE_URL applies consistently. Fixes #7233.

Co-authored-by: Alphaxiaoteng <230277249+Alphaxiaoteng@users.noreply.github.com>
Co-authored-by: Vidit Ostwal <110953813+Vidit-Ostwal@users.noreply.github.com>
This commit is contained in:
αI
2026-09-08 14:08:40 +08:00
committed by GitHub
parent 09997bfd6f
commit 7e18abd108
2 changed files with 16 additions and 1 deletions

View File

@@ -573,7 +573,8 @@ class LLM(BaseLLM):
return True
if provider == "dashscope":
return model_lower.startswith("qwen")
# DashScope's OpenAI-compatible endpoint serves Qwen plus DeepSeek/Kimi/GLM/etc.
return True
if provider == "openrouter":
# OpenRouter uses org/model format but accepts anything

View File

@@ -298,6 +298,20 @@ class TestLLMIntegration:
assert isinstance(llm, OpenAICompatibleCompletion)
assert llm.provider == "dashscope"
def test_llm_creates_openai_compatible_for_dashscope_non_qwen(self):
"""Non-Qwen DashScope models must still use the native OpenAI-compatible path."""
with patch.dict(
os.environ,
{
"DASHSCOPE_API_KEY": "test-key",
"DASHSCOPE_BASE_URL": "https://my-dashscope.example.com/v1",
},
):
llm = LLM(model="dashscope/deepseek-v3")
assert isinstance(llm, OpenAICompatibleCompletion)
assert llm.provider == "dashscope"
assert llm.base_url == "https://my-dashscope.example.com/v1"
def test_llm_with_explicit_provider(self):
"""Test LLM with explicit provider parameter."""
with patch.dict(os.environ, {"DEEPSEEK_API_KEY": "test-key"}):