From 6887076ce0944576fc38ef8edd84fac71bed8e17 Mon Sep 17 00:00:00 2001 From: cybermaggedon Date: Wed, 1 Jul 2026 16:50:47 +0100 Subject: [PATCH] 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. --- .../model/text_completion/openai/variants.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/trustgraph-flow/trustgraph/model/text_completion/openai/variants.py b/trustgraph-flow/trustgraph/model/text_completion/openai/variants.py index 0c314a04..7e650e37 100644 --- a/trustgraph-flow/trustgraph/model/text_completion/openai/variants.py +++ b/trustgraph-flow/trustgraph/model/text_completion/openai/variants.py @@ -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, }