SQLite 持久连接 — sandbox 不再每次查询开关连接,改为 __init__ 时建连、close() 时释放

Explorer 的 system prompt 明确告知 sandbox 规则 — "每条 SQL 必须包含聚合函数或 LIMIT",减少 LLM 生成违规 SQL 浪费轮次
LLM 客户端单例 — 所有组件共享一个 openai.OpenAI 实例,不再各建各的
sanitize 顺序修复 — 小样本抑制放在 float round 之前,避免被 round 干扰
quick_detect 从 O(n²) 改为 O(n) — 按列聚合一次,加去重,不再对每行重复算整列统计
历史上下文实际生效 — get_context_for 的结果现在会注入到 Explorer 的初始 prompt 里,多轮分析时 LLM 能看到之前的发现
This commit is contained in:
2026-03-20 13:20:31 +08:00
parent 96927a789d
commit b7a27b12bd
39 changed files with 2637 additions and 1133 deletions

View File

@@ -9,7 +9,7 @@ from datetime import datetime, timedelta
sys.path.insert(0, os.path.dirname(__file__))
from config import DB_PATH, LLM_CONFIG
from core.config import DB_PATH, LLM_CONFIG
from agent import DataAnalysisAgent
@@ -129,7 +129,8 @@ def main():
print("\n" + "=" * 60)
print(" ⬆️ AI 只看到 Schema表结构 + 数据画像")
print(" ⬇️ 四层架构分析:规划 → 探索 → 洞察 → 报告")
print(" ⬇️ 四层架构分析:规划 → 预设匹配 → 探索 → 洞察 → 报告")
print(f" 📋 已加载 {len(agent.playbook_mgr.playbooks)} 个预设剧本")
print("=" * 60)
questions = [