修复2问题: KB误匹配+返回全文 / Ctrl+C无法停止

1. KB匹配与返回全文
   - _poll中过滤纯时间/日期格式文本(OCR时间戳分割残留)->不入KB搜索
   - knowledge_base.py子串fallback要求query>=4字符,避免"19:15"等短时间戳误匹配
   - auto_reply._get_answer: 非Q&A文档只返回content前500字符,不返回整篇文件
   - 时间戳文本不进入KB + 短query不子串匹配 + 非Q&A截取 = 三层兜底

2. Ctrl+C无法停止
   - ThreadPoolExecutor创建非daemon线程->进程无法退出->必须杀CMD
     改用daemon thread + Event.wait(timeout): daemon线程不阻塞进程退出
   - main.py注册signal.signal(SIGINT) handler: 收到Ctrl+C后stop监控+quit窗口
   - 移除from concurrent.futures导入,替换为import signal
This commit is contained in:
youpaishidifu
2026-07-26 15:30:55 +08:00
parent 6d0974ea8f
commit 7bdc7ad637
16 changed files with 58 additions and 21 deletions
+12
View File
@@ -3,6 +3,7 @@
import logging
import os
import sys
import signal
# 确保在项目目录
os.chdir(os.path.dirname(os.path.abspath(__file__)))
@@ -42,6 +43,17 @@ def main():
sys.exit(1)
app = MsgBotApp()
# Ctrl+C 信号处理:Windows Tkinter mainloop 不响应 KeyboardInterrupt
# 需 signal handler 强制停止监控 + 退出
def _sigint_handler(sig, frame):
logger.info("收到 Ctrl+C,正在关闭...")
app.monitor.stop()
app.quit()
sys.exit(0)
signal.signal(signal.SIGINT, _sigint_handler)
app.mainloop()