From 06bdbb526322d780d3e9094e6cc2fee7e9db3efd Mon Sep 17 00:00:00 2001 From: youpaishidifu Date: Fri, 18 Sep 2026 10:05:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DTask=20#1741:=20=E9=97=B2?= =?UTF-8?q?=E8=81=8A=E6=B6=88=E6=81=AF=E8=AF=AF=E8=A7=A6=E5=8F=91KB?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增闲聊消息检测:无疑问词+无查询动词+无话题词 → 跳过 - 过滤"正常打88折"等纯聊天内容 - 避免将无查询意图的陈述句误判为KB查询 --- auto_reply.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/auto_reply.py b/auto_reply.py index 7178086..9cd991e 100644 --- a/auto_reply.py +++ b/auto_reply.py @@ -49,6 +49,25 @@ class AutoReply: f"[{platform}] 匹配度 {score:.2f} < 阈值 {self._min_score},跳过回复" ) return None + + # ⭐ Task #1741: 闲聊消息检测——无查询意图的陈述句直接跳过 + # 特征:无疑问词、无查询动词、无具体主题词(插件名/功能名) + # 例:"正常我们打88折"、"黑奴给1000%折扣" → 纯聊天,无查询意图 + _question_marks = ['?', '?', '吗', '呢', '什么', '怎么', '如何', '哪', '多少', '几', '为什么', '是不是', '有没有', '能否', '可以'] + _query_verbs = ['查', '问', '看', '了解', '咨询', '知道', '怎么', '如何', '在哪', '哪里', '多少'] + _has_question = any(q in msg for q in _question_marks) + _has_query_intent = any(v in msg for v in _query_verbs) + + # 提取核心名词(插件名、功能名等) + import jieba + _words = list(jieba.cut(msg)) + _nouns = [w for w in _words if len(w) >= 2 and not w.strip('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')] + _has_topic = any(n in _nouns for n in ['插件', '游戏', '配置', '绑定', '下载', '安装', '功能', '操作']) + + if not _has_question and not _has_query_intent and not _has_topic: + logger.debug(f"[{platform}] 闲聊消息检测:无查询意图,跳过KB搜索 | msg={msg[:40]!r}") + return None + # 内容相关性检查:查询词与匹配文档至少有一个共同2字+词,防偶然匹配 if not self._has_content_relevance(msg, top_doc, score): heading = top_doc.get("heading", "")[:40]