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

22
core/__init__.py Normal file
View File

@@ -0,0 +1,22 @@
"""
iov_ana 核心包
项目结构:
core/
config.py - 配置
utils.py - 公共工具JSON 提取、LLM 客户端)
schema.py - Schema 提取
sandbox.py - SQL 沙箱执行器
layers/
planner.py - Layer 1: 意图规划
playbook.py - Layer 1.5: 预设剧本
explorer.py - Layer 2: 自适应探索
insights.py - Layer 3: 异常洞察
context.py - Layer 4: 上下文记忆
output/
reporter.py - 单次报告生成
consolidator.py - 多次报告整合
chart.py - 图表生成
agent.py - Agent 编排层
cli.py - 交互式 CLI
"""