修复三个问题:病句过滤、KB回复内容、截图保存日志
1. 病句过滤改进(monitor.py): - ≤5字短句:必须包含疑问词(什么/怎么/如何/为什么/吗/呢等)才放行 - 无疑问词的短句直接过滤(如'自行修?') - 5-50字病句:增加'过'字匹配(如'修正过后') 2. KB回复内容改进(auto_reply.py + knowledge_base.py): - _get_answer 改为返回 body(纯正文),不含 heading - KB搜索增加heading包含查询关键词的bonus - 文档头部(# 文档名)增加penalty,避免返回错误section 3. 截图保存日志改进(monitor.py): - QQ/微信截图保存失败日志从 debug 升级为 warning - 增加保存路径提示,便于定位问题
This commit is contained in:
+9
-4
@@ -109,16 +109,21 @@ class AutoReply:
|
||||
|
||||
def _get_answer(self, platform: str, msg: str, doc: dict, score: float) -> str or None:
|
||||
"""提取答案 + 防重复检查。
|
||||
优先返回 doc['answer'](Q&A 段),兜底使用 doc['content']。
|
||||
KB 搜索已按 section 切分,doc['content'] 即最相关的片段。
|
||||
优先返回 doc['answer'](Q&A 段),兜底使用 doc['body'](仅正文,不含 heading)。
|
||||
KB 搜索已按 section 切分,doc['body'] 即最相关的片段正文。
|
||||
只需截断到 300 字符避免消息过长。
|
||||
"""
|
||||
answer = doc.get("answer")
|
||||
if answer:
|
||||
answer = answer.strip()
|
||||
else:
|
||||
content = doc.get("content", "").strip()
|
||||
answer = content[:297] + "..." if len(content) > 300 else content
|
||||
# 优先用 body(纯正文),兜底用 content(heading+正文)
|
||||
body = doc.get("body", "").strip()
|
||||
if body and len(body) > 20:
|
||||
answer = body[:297] + "..." if len(body) > 300 else body
|
||||
else:
|
||||
content = doc.get("content", "").strip()
|
||||
answer = content[:297] + "..." if len(content) > 300 else content
|
||||
|
||||
if not answer:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user