fix: #1448 相关性短查询放行 + #1449 严格300s报废

#1448 auto_reply: _has_content_relevance() 不再对≤2token短查询无条件放行
- 短查询必须整个query作为子串出现在文档中才放行
- 修复下载→前置依赖误匹配(无任何共同token/token交集)

#1449 monitor: 严格300s报废策略
- stage splitting: 继承时间戳>300s一律丢弃,移除新鲜内容/提问豁免
- 区块级: 硬截止从1800s→300s,移除CJK内容/新鲜特征bypass
- 修复16:07消息在21:08仍被处理的问题
This commit is contained in:
youpaishidifu
2026-08-07 22:42:14 +08:00
parent 5c4a17043a
commit 7fc737d80f
2 changed files with 165 additions and 105 deletions
+12 -2
View File
@@ -85,8 +85,9 @@ class AutoReply:
"""
import re
q_tokens = set(t for t in jieba.cut(query) if len(t) >= 2)
if len(q_tokens) <= 2:
return True # 短查询不拦截
# ⭐ 修复:短查询不再无条件放行,改为必须有子串命中才放行
# 原逻辑导致"下载"(1 token)→"前置依赖"误匹配(无任何共同token却放行)
_is_short_query = len(q_tokens) <= 2
# 1. 检查 heading + title(排除链接文本)
heading = doc.get("heading", "")
@@ -130,9 +131,18 @@ class AutoReply:
# 3. 子串回退:jieba分词可能产生"包是""还是"等碎片token,
# 导致token交集为空但文档确实包含查询核心词(如"资源包")。
# 检查查询中任意2~6字子串是否出现在文档文本中。
# ⭐ 短查询(≤2 token):检查整个query是否出现在文档中("下载"必须在文档中出现)
# ⭐ 使用清理后的文本(排除链接文本)
full_text = doc_text + " " + body_no_link[:500] if body else doc_text
stripped_query = re.sub(r'[??!!。,,\s]', '', query)
# 短查询特殊处理:整个query必须作为子串出现在文档中
if _is_short_query and len(stripped_query) >= 2:
if stripped_query in full_text:
logger.debug(f"短查询子串命中: query={stripped_query!r} in doc={doc.get('heading','')[:30]!r}")
return True
else:
logger.debug(f"短查询子串未命中: query={stripped_query!r} 不在文档中,拒绝")
return False
if len(stripped_query) >= 4:
for qlen in range(min(len(stripped_query), 6), 1, -1):
for start in range(len(stripped_query) - qlen + 1):