fix: 修复KB搜索回复内容不对和历史消息重复处理问题
问题1:回复内容不对 - protect.md的section heading包含整个section内容(含<br>和列表标记),导致下载意图加权检查误匹配 - 修复:增加检查,如果heading含<br>或列表标记,说明是复合标题,需检查下载是否出现在标题主体部分 问题2:历史消息重复处理 - 基线轮处理后seen.discard(item)从持久化集合中移除,但未重新加入_seen_messages - 修复:基线轮处理后增加self._seen_messages.add(item),确保下次轮询不再处理此消息
This commit is contained in:
@@ -270,7 +270,18 @@ class AutoReply:
|
||||
# 修复"在哪儿能下到那登录插件啊?"——原文无"下载"二字(口语"下到"),
|
||||
# q_mean 不含"下载","## 4. 下载地址"heading 虽有"下载"仍被相关性拒绝,
|
||||
# 导致误回"插件设置"(body 恰含"登录超时秒数")
|
||||
# ⚠ 只检查真正的标题行:如果heading含<br>或列表标记,说明是复合标题,
|
||||
# 需检查"下载"是否出现在标题主体部分(<br>之前),而非列表项内容
|
||||
_download_match = False
|
||||
if any(w in query for w in ('下载', '下到', '哪下', '在哪下', '怎么下')) and '下载' in heading_clean:
|
||||
if '<br>' not in heading and '- [' not in heading and '|-' not in heading:
|
||||
_download_match = True
|
||||
else:
|
||||
# 复合标题:检查标题主体部分(<br>或列表之前)是否含"下载"
|
||||
_title_part = re.split(r'<br>|- |\|-', heading_clean)[0]
|
||||
if '下载' in _title_part:
|
||||
_download_match = True
|
||||
if _download_match:
|
||||
logger.debug(f"下载意图放行: query={query[:30]!r} heading={heading[:30]!r}")
|
||||
return True
|
||||
|
||||
|
||||
+14
-2
@@ -875,8 +875,20 @@ class KnowledgeBase:
|
||||
# 修复"在哪儿能下到那登录插件啊?"被"插件设置"(body含"登录")压过,
|
||||
# 而真正的"## 4. 下载地址"section(3.93)排不进top3的问题
|
||||
# ⚠ 排除heading含"皮肤"的section(皮肤教程非插件下载)
|
||||
if (any(w in query_stripped for w in ('下载', '下到', '哪下', '怎么下'))
|
||||
and '下载' in heading_no_links and '皮肤' not in heading_no_links):
|
||||
# ⚠ 只检查真正的标题行:如果heading含<br>或列表标记,说明是复合标题,
|
||||
# 需检查"下载"是否出现在标题主体部分(<br>之前),而非列表项内容
|
||||
_download_match = False
|
||||
if any(w in query_stripped for w in ('下载', '下到', '哪下', '怎么下')):
|
||||
if '下载' in heading_no_links and '皮肤' not in heading_no_links:
|
||||
# 检查是否是纯标题(不含<br>或列表标记)
|
||||
if '<br>' not in heading and '- [' not in heading and '|-' not in heading:
|
||||
_download_match = True
|
||||
else:
|
||||
# 复合标题:检查标题主体部分(<br>或列表之前)是否含"下载"
|
||||
_title_part = re.split(r'<br>|- |\|-', heading_no_links)[0]
|
||||
if '下载' in _title_part:
|
||||
_download_match = True
|
||||
if _download_match:
|
||||
bonus += 8.0
|
||||
# ⭐ body 包含查询核心名词(如"密码")→ 巨幅 bonus
|
||||
core_nouns = {'密码', '用户管理', '领地', '商品', 'CDK', '工单', '债券', '在线'}
|
||||
|
||||
+2
-1
@@ -7382,11 +7382,12 @@ class MessageMonitor:
|
||||
# 相同内容 → ts in seen 永久拦截
|
||||
# 2. 清空 _last_sig ——否则下一轮 sig 相同 → 4131 静默跳过,
|
||||
# 用户刚发的新消息被基线误吞后永远等不到回复
|
||||
# 3. 不 seen.add ——防重复由 sig 静默跳过承担
|
||||
# 3. ⭐ 重新加入 _seen_messages 防止下次轮询重复处理(修复历史消息重复问题)
|
||||
# 4. ⭐ 清除截图 hash——否则下次轮询时 hash 相同直接跳过 OCR,
|
||||
# 消息永远等不到回复(截图内容没变但消息需要被处理)
|
||||
logger.info(f"[{platform}] 基线↺(不回复): {item[:60]}")
|
||||
seen.discard(item)
|
||||
self._seen_messages.add(item) # 确保下次轮询不再处理此消息
|
||||
self._last_sig[platform] = ""
|
||||
self._last_screenshot_hash.pop(platform, None)
|
||||
self._last_new_msg_time[platform] = time.time()
|
||||
|
||||
Reference in New Issue
Block a user