fix(kb): 修正语义意图验证,php查询要求heading含php

之前规则:'php'+'管理'时允许heading含'管理'→ beibao通过
修正:'php'查询时heading必须含'php'→ 正确返回phpadmin
This commit is contained in:
youpaishidifu
2026-08-13 16:05:34 +08:00
parent 256935d70c
commit 8d0670ce81
+7 -6
View File
@@ -170,14 +170,15 @@ class AutoReply:
# ⭐ 语义意图验证:OCR查询可能含错字(如"录"→"登"、"php"→"pHp"),
# 需要结合heading确认查询意图,防止"云背包管理员密码"压过"php管理员后端"
# 查询含"php"+"后端"时,heading必须含"php"或"管理"
if 'php' in query.lower() and ('后端' in query or '管理' in query):
if 'php' not in heading_clean and '管理' not in heading_clean:
# 查询含"php"时,heading必须含"php"(而非仅"管理",因为beibao也有管理员)
if 'php' in query.lower():
if 'php' not in heading_clean:
logger.debug(f"php查询意图不匹配: query={query[:40]!r} heading={heading[:30]!r}")
return False
# 查询含"管理员密码"时,heading必须含"密码"或"管理"或"php"
if '管理员' in query and '密码' in query:
if '密码' not in heading_clean and '管理' not in heading_clean and 'php' not in heading_clean:
# 查询含"管理员密码"且不含"php"时,heading必须含"密码"或"php"
# (防止beibao的"管理员密码qweasd"被误选,应返回phpadmin的"ypshidifu2026")
if '管理员' in query and '密码' in query and 'php' not in query.lower():
if '密码' not in heading_clean and 'php' not in heading_clean:
logger.debug(f"管理员密码查询意图不匹配: query={query[:40]!r} heading={heading[:30]!r}")
return False