docs: consolidate rag refactor issues
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
# RAG 迁移到 Spring AI VectorStore 检索抽象
|
||||
|
||||
**状态**:待规划
|
||||
**严重程度**:高
|
||||
**发现时间**:2026-07-05
|
||||
**范围**:向量检索、Milvus 接入、RAG 框架化改造
|
||||
|
||||
---
|
||||
|
||||
## 背景
|
||||
|
||||
当前系统的向量检索链路主要由项目手写实现:
|
||||
|
||||
- `VectorIndexService` 负责向量化和写入 Milvus。
|
||||
- `VectorSearchService` 直接使用 Milvus SDK 查询。
|
||||
- `LookupKnowledgeTool` 自己组织 L0/L1 检索结果。
|
||||
|
||||
这能满足 MVP 打通链路,但继续扩展 RAG 能力时,容易把项目变成自研搜索框架。
|
||||
|
||||
项目当前已引入 Spring AI / Spring AI Alibaba 依赖,可以考虑迁移到 Spring AI 的 `VectorStore`、`VectorStoreDocumentRetriever` 等标准抽象。
|
||||
|
||||
---
|
||||
|
||||
## 问题
|
||||
|
||||
当前手写 Milvus 检索存在几个成本:
|
||||
|
||||
1. topK、similarity threshold、metadata filter 等逻辑分散在业务代码中。
|
||||
2. 检索结果结构和 Spring AI RAG Advisor 生态不兼容。
|
||||
3. 后续接入 query transformer、post processor、advisor 时需要重复适配。
|
||||
4. Milvus SDK 直接调用让业务层承担了过多基础设施细节。
|
||||
|
||||
---
|
||||
|
||||
## 改造方向
|
||||
|
||||
优先引入 Spring AI 的 Milvus VectorStore 能力:
|
||||
|
||||
```text
|
||||
当前:
|
||||
VectorSearchService -> Milvus SDK
|
||||
|
||||
目标:
|
||||
LookupKnowledgeTool / RAG Service
|
||||
-> VectorStoreDocumentRetriever
|
||||
-> Spring AI VectorStore
|
||||
-> Milvus
|
||||
```
|
||||
|
||||
业务层保留:
|
||||
|
||||
- `lookup_knowledge` 工具入口
|
||||
- `tool_invocation` 记录
|
||||
- sessionId / category / domain 等业务上下文
|
||||
|
||||
底层检索交给框架:
|
||||
|
||||
- topK
|
||||
- similarity threshold
|
||||
- metadata filter
|
||||
- vector search options
|
||||
|
||||
---
|
||||
|
||||
## 验收标准
|
||||
|
||||
- `VectorSearchService` 不再直接散落 Milvus 查询细节,至少封装到 Spring AI `VectorStore` 适配层。
|
||||
- 支持按 `category` 或其他 metadata filter 检索。
|
||||
- 检索结果仍能记录到 `tool_invocation`。
|
||||
- 现有 AIOps / Chat 检索链路行为保持兼容。
|
||||
|
||||
---
|
||||
|
||||
## 相关文件
|
||||
|
||||
- `pom.xml`
|
||||
- `src/main/java/com/superbiz/agent/service/VectorSearchService.java`
|
||||
- `src/main/java/com/superbiz/agent/service/VectorIndexService.java`
|
||||
- `src/main/java/com/superbiz/agent/tool/LookupKnowledgeTool.java`
|
||||
- `src/main/resources/application.yml`
|
||||
Reference in New Issue
Block a user