feat: add dashscope variant for Alibaba Cloud DashScope API (#1010)

DashScope uses enable_thinking as a top-level parameter rather than
inside extra_body as the Qwen docs suggest.
This commit is contained in:
cybermaggedon 2026-07-01 16:50:47 +01:00 committed by GitHub
parent 55e2a2a3ce
commit 6887076ce0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -118,6 +118,26 @@ class QwenVariant(Variant):
return {}
class DashScopeVariant(Variant):
"""Alibaba Cloud DashScope API (Qwen models via DashScope)."""
name = "dashscope"
token_param = "max_completion_tokens"
temperature_with_thinking = True
def completion_kwargs(self, max_output, temperature, thinking):
enabled = thinking != "off"
kwargs = {
self.token_param: max_output,
"temperature": temperature,
"enable_thinking": enabled,
}
return kwargs
def thinking_kwargs(self, effort):
return {}
class MistralVariant(Variant):
"""Mistral API (Mistral Large, etc.)."""
@ -181,6 +201,7 @@ VARIANTS = {
"deepseek": DeepSeekVariant,
"qwen": QwenVariant,
"mistral": MistralVariant,
"dashscope": DashScopeVariant,
"glm": GlmVariant,
"llama": LlamaVariant,
}