mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-25 04:29:51 +01:00
PR 提供的keep 逃生门要求用户自行发现问题、了解该魔法值并手改 configJson,对普通用户不可达。
调整LLM thinking 域名禁用规则支持按模型名豁免(避免 MaaS glm-5.3 被注入参数后 400)
This commit is contained in:
parent
2cb0562ade
commit
549261fdff
1 changed files with 15 additions and 3 deletions
|
|
@ -19,6 +19,11 @@ THINKING_DISABLED_DOMAINS = {
|
||||||
"modelarts-maas.com": {"thinking": {"type": "disabled"}},
|
"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):
|
class LLMProvider(LLMProviderBase):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
|
|
@ -99,11 +104,18 @@ class LLMProvider(LLMProviderBase):
|
||||||
return
|
return
|
||||||
parsed_url = urlparse(self.base_url)
|
parsed_url = urlparse(self.base_url)
|
||||||
domain = parsed_url.netloc
|
domain = parsed_url.netloc
|
||||||
|
model_name = (self.model_name or "").lower()
|
||||||
for disabled_domain, params in THINKING_DISABLED_DOMAINS.items():
|
for disabled_domain, params in THINKING_DISABLED_DOMAINS.items():
|
||||||
if disabled_domain in domain:
|
if disabled_domain not in domain:
|
||||||
request_params.setdefault("extra_body", {}).update(params)
|
continue
|
||||||
logger.bind(tag=TAG).info(f"为域名 {domain} 禁用思考模式,参数: {params}")
|
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
|
break
|
||||||
|
request_params.setdefault("extra_body", {}).update(params)
|
||||||
|
logger.bind(tag=TAG).info(f"为域名 {domain} 禁用思考模式,参数: {params}")
|
||||||
|
break
|
||||||
|
|
||||||
def response(self, session_id, dialogue, **kwargs):
|
def response(self, session_id, dialogue, **kwargs):
|
||||||
dialogue = self.normalize_dialogue(dialogue)
|
dialogue = self.normalize_dialogue(dialogue)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue