feat: 添加调试日志追踪KB匹配和OCR连续性问题
- gui.py: _search_and_log() 添加KB搜索输入/结果/相关性检查详细日志 - monitor.py: _has_user_colors() 添加像素检测初始化/统计/绿色检测日志 - monitor.py: QQ OCR路径添加截图信息日志 - 目的: 诊断牛头不对马嘴和连续消息OCR中断问题
This commit is contained in:
@@ -333,17 +333,29 @@ class MsgBotApp(ctk.CTk):
|
||||
def _search_and_log(self, platform: str, msg: str, msg_hash: str):
|
||||
"""搜索知识库并输出结果,匹配成功时队列自动回复到主线程"""
|
||||
try:
|
||||
# 详细调试日志:记录发送给KB搜索的完整消息
|
||||
logger.debug(f"[{platform}] KB搜索输入: msg={msg!r} (长度={len(msg)})")
|
||||
|
||||
results = self.kb.search(msg, top_k=3)
|
||||
lines = [f"[{platform.upper()}] {msg}"]
|
||||
|
||||
if results:
|
||||
answer_title = results[0][0]["title"]
|
||||
answer_score = results[0][1]
|
||||
lines.append(f" 🔍 找到 {len(results)} 条相关结果:")
|
||||
|
||||
for i, (doc, score) in enumerate(results):
|
||||
title = doc["title"]
|
||||
heading = doc.get("heading", "")
|
||||
body = doc.get("body", "")
|
||||
content = doc.get("content", "")
|
||||
|
||||
# 详细调试日志:记录每个搜索结果的详细信息
|
||||
logger.debug(f"[{platform}] KB结果[{i}]: 标题={title!r}, 匹配度={score:.2f}")
|
||||
logger.debug(f"[{platform}] KB结果[{i}] heading={heading[:80]!r}")
|
||||
logger.debug(f"[{platform}] KB结果[{i}] body={body[:120]!r}")
|
||||
logger.debug(f"[{platform}] KB结果[{i}] content={content[:150]!r}")
|
||||
|
||||
# 显示更详细的信息
|
||||
lines.append(f" 📄 [{title}] (匹配度 {score:.2f})")
|
||||
lines.append(f" 标题: {heading[:60]}")
|
||||
@@ -359,6 +371,12 @@ class MsgBotApp(ctk.CTk):
|
||||
else:
|
||||
# 检查内容相关性
|
||||
has_relevance = self.ar._has_content_relevance(msg, results[0][0], answer_score)
|
||||
|
||||
# 详细调试日志:记录内容相关性检查结果
|
||||
logger.debug(f"[{platform}] 内容相关性检查: msg={msg!r}, has_relevance={has_relevance}")
|
||||
logger.debug(f"[{platform}] 内容相关性检查: doc标题={results[0][0].get('title', '')!r}")
|
||||
logger.debug(f"[{platform}] 内容相关性检查: doc heading={results[0][0].get('heading', '')[:50]!r}")
|
||||
|
||||
if not has_relevance:
|
||||
heading = results[0][0].get("heading", "")[:40]
|
||||
lines.append(f" ⚠ 内容相关性检查失败 (heading={heading!r}),跳过")
|
||||
|
||||
Reference in New Issue
Block a user