From 549261fdff35ae5f89a3f8e90412eb18a5e2ef83 Mon Sep 17 00:00:00 2001 From: Sakura-RanChen <1908198662@qq.com> Date: Wed, 28 Oct 2026 16:18:58 +0800 Subject: [PATCH] =?UTF-8?q?PR=20=E6=8F=90=E4=BE=9B=E7=9A=84`keep`=20?= =?UTF-8?q?=E9=80=83=E7=94=9F=E9=97=A8=E8=A6=81=E6=B1=82=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=87=AA=E8=A1=8C=E5=8F=91=E7=8E=B0=E9=97=AE=E9=A2=98=E3=80=81?= =?UTF-8?q?=E4=BA=86=E8=A7=A3=E8=AF=A5=E9=AD=94=E6=B3=95=E5=80=BC=E5=B9=B6?= =?UTF-8?q?=E6=89=8B=E6=94=B9=20configJson=EF=BC=8C=E5=AF=B9=E6=99=AE?= =?UTF-8?q?=E9=80=9A=E7=94=A8=E6=88=B7=E4=B8=8D=E5=8F=AF=E8=BE=BE=E3=80=82?= =?UTF-8?q?=20=E8=B0=83=E6=95=B4LLM=20thinking=20=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E8=A7=84=E5=88=99=E6=94=AF=E6=8C=81=E6=8C=89?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E5=90=8D=E8=B1=81=E5=85=8D=EF=BC=88=E9=81=BF?= =?UTF-8?q?=E5=85=8D=20MaaS=20glm-5.3=20=E8=A2=AB=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=90=8E=20400=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/providers/llm/openai/openai.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/main/xiaozhi-server/core/providers/llm/openai/openai.py b/main/xiaozhi-server/core/providers/llm/openai/openai.py index 174130113..0229b4314 100644 --- a/main/xiaozhi-server/core/providers/llm/openai/openai.py +++ b/main/xiaozhi-server/core/providers/llm/openai/openai.py @@ -19,6 +19,11 @@ THINKING_DISABLED_DOMAINS = { "modelarts-maas.com": {"thinking": {"type": "disabled"}}, } +# 域名规则的模型名豁免表: 强制思考模型不接受该参数注入(如 MaaS glm-5.3 传 thinking 必 400) +THINKING_DISABLED_MODEL_EXCLUSIONS = { + "modelarts-maas.com": ("glm-5.3",), +} + class LLMProvider(LLMProviderBase): def __init__(self, config): @@ -99,11 +104,18 @@ class LLMProvider(LLMProviderBase): return parsed_url = urlparse(self.base_url) domain = parsed_url.netloc + model_name = (self.model_name or "").lower() for disabled_domain, params in THINKING_DISABLED_DOMAINS.items(): - if disabled_domain in domain: - request_params.setdefault("extra_body", {}).update(params) - logger.bind(tag=TAG).info(f"为域名 {domain} 禁用思考模式,参数: {params}") + if disabled_domain not in domain: + continue + exclusions = THINKING_DISABLED_MODEL_EXCLUSIONS.get(disabled_domain, ()) + if any(ex in model_name for ex in exclusions): + logger.bind(tag=TAG).info( + f"域名 {domain} 命中禁思考规则, 但模型 {self.model_name} 强制思考且拒绝该参数, 跳过注入") break + request_params.setdefault("extra_body", {}).update(params) + logger.bind(tag=TAG).info(f"为域名 {domain} 禁用思考模式,参数: {params}") + break def response(self, session_id, dialogue, **kwargs): dialogue = self.normalize_dialogue(dialogue)