fix(rag): 移除 service 未用参数 + 引擎构建加锁 + 修正文档措辞

This commit is contained in:
lhl
2026-08-30 00:31:18 +08:00
parent f77fab707d
commit 9a02fcd00f
2 changed files with 8 additions and 10 deletions
+1 -1
View File
@@ -1930,6 +1930,6 @@ Document(注入后 Word 文档)
- **scope = session_id**:每个会话的既有系统源码独立索引到 `RagStore` 的同一 scope,互不串扰。
- **上传即索引(D1**`GenesisService.upload_file` 在 `file_type == "existing_system"` 且 `self.rag is not None` 时,解压完成后立即调用 `self.rag.index_dir(session_id, path)`;索引异常仅记录日志(`_LOGGER.warning`)不阻断上传。
- **`use_rag` 默认关闭**`GenesisService` 构造参数 `use_rag` 默认 `False``rag=None` 表示不启用(向后兼容)。`run_impact(session_id, use_rag=None)` 中 `eff = self.use_rag if use_rag is None else use_rag`;仅当 `eff 且 self.rag is not None` 时走 LLM+RAG 路径,否则走原确定性 `ImpactAgent().run(...)` 路径(行为不变)。
- **异步链路**`run_impact` 为 `async def`RAG 路径 `await ImpactAgent(engine=..., rag=..., use_rag=True).run_impact(...)``app.start_impact` 端点同步改为 `async def` 并 `await service.run_impact(sid, use_rag=use_rag)``chat/agent.py` 调用处以 `asyncio.run(...)` 包裹以兼容同步消息处理。
- **异步链路**`run_impact` 为 `async def`RAG 路径 `await ImpactAgent(engine=..., rag=..., use_rag=True).run_impact(...)``app.start_impact` 端点改为 `async def` 并 `await service.run_impact(sid, use_rag=use_rag)``chat/agent.py` 调用处以 `asyncio.run(...)` 包裹以兼容同步消息处理。
- **线程安全(D2**`RagStore` 构造使用 `sqlite3.connect(db_path, check_same_thread=False)` 并加 `threading.Lock`,读写均加锁串行化,适配 Web 服务端 worker 线程复用连接。
- **向后兼容**`use_rag=False` 时 prompt 不含 RAG 小节标题(`_RAG_CONTEXT_TITLE`),影响报告为确定性 `impact-report.json`,不调用 LLM。