From bc0784f41d0e6d51dce00ed75b518ed4264b0035 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 Aug 2025 11:18:29 +0800 Subject: [PATCH] fix: enable_thinking parameter for qwen3 models in non-streaming calls (#2424) * Initial plan * Fix ModelScope enable_thinking parameter for non-streaming calls Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com> * Tighten enable_thinking condition to only Qwen/Qwen3 models Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com> * qwen3 model handle * Update astrbot/core/provider/sources/openai_source.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- astrbot/core/provider/sources/openai_source.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index 14c2da2de..b286eb701 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -99,6 +99,11 @@ class ProviderOpenAIOfficial(Provider): for key in to_del: del payloads[key] + # 针对 qwen3 模型的特殊处理:非流式调用必须设置 enable_thinking=false + model = payloads.get("model", "") + if "qwen3" in model.lower(): + extra_body["enable_thinking"] = False + completion = await self.client.chat.completions.create( **payloads, stream=False, extra_body=extra_body )