38 lines
2.5 KiB
Markdown
38 lines
2.5 KiB
Markdown
# ChatModel + Embedding 解耦 Tasks
|
||
|
||
## 需求追踪
|
||
|
||
| 需求 | 状态 | 备注 |
|
||
| --- | --- | --- |
|
||
| ChatService 解耦 DashScopeChatModel | ✅ 已完成 | 改为注入 ChatModel |
|
||
| ChatController 解耦 DashScope | ✅ 已完成 | 删除手动构建逻辑 |
|
||
| AiOpsService 解耦 DashScopeChatModel | ✅ 已完成 | 方法签名改为 ChatModel |
|
||
| VectorEmbeddingService 解耦 DashScope SDK | ✅ 已完成 | 改为注入 EmbeddingModel |
|
||
| RagService 解耦 DashScope Generation | ✅ 已完成 | 改为 ChatModel.stream() |
|
||
| VECTOR_DIM 配置化 | ✅ 已完成 | 从 yml 读取 |
|
||
| 混合厂商路由 | ✅ 已完成 | ModelRoutingConfig + @Primary |
|
||
| SiliconFlow Embedding | ✅ 已完成 | SiliconFlowEmbeddingConfig + BGE-M3 |
|
||
|
||
## 实现任务
|
||
|
||
- [x] T1: MilvusProperties 新增 vectorDim 字段 + getter/setter,application.yml 新增 `milvus.vector-dim: 1024`
|
||
- [x] T2: MilvusConstants.VECTOR_DIM 改为从 MilvusProperties 动态读取(MilvusClientFactory 传入)
|
||
- [x] T3: ChatService — 删除 createDashScopeApi/createChatModel/createStandardChatModel,新增 @Autowired ChatModel;createReactAgent 参数改为 ChatModel
|
||
- [x] T4: ChatController — 删除 DashScope import 和手动构建(行83-84, 171-172, 292-301),改为使用注入 ChatModel 或 ChatService 传入
|
||
- [x] T5: AiOpsService — executeAiOpsAnalysis/buildPlannerAgent/buildExecutorAgent 参数类型 DashScopeChatModel → ChatModel
|
||
- [x] T6: VectorEmbeddingService — 删除 DashScope SDK import + TextEmbedding 字段 + @PostConstruct init(),改为 @Autowired EmbeddingModel;generateEmbedding 改为调用 EmbeddingModel.embed()
|
||
- [x] T7: RagService — 删除 DashScope SDK import + Generation 字段 + Constants.apiKey,改为 @Autowired ChatModel;generateAnswerStream 改为 ChatModel.stream(Prompt) + Flux 适配 StreamCallback
|
||
- [x] T8: 新增 ModelRoutingConfig — @Configuration + @Primary ChatModel / EmbeddingModel Bean,集中管理模型路由(List<T> 自检 + 类名筛选)
|
||
- [x] T9: 新增 SiliconFlowEmbeddingConfig — 独立 OpenAiApi → SiliconFlow,BGE-M3 1024 维
|
||
|
||
## 最终状态
|
||
|
||
| 模型 | 厂商 | Spring AI 实现 | Bean |
|
||
|---|---|---|---|
|
||
| Chat | DeepSeek V4 Flash | `DeepSeekChatModel` (原生) | `deepSeekChatModel` |
|
||
| Embedding | BGE-M3 | `OpenAiEmbeddingModel` → SiliconFlow | `siliconFlowEmbeddingModel` |
|
||
| 路由 | — | `ModelRoutingConfig` | `chatModel` + `embeddingModel` @Primary |
|
||
|
||
### 验证
|
||
- `ChatAndEmbeddingSmokeTest`: 5/5 ✅
|
||
- `FullPipelineSmokeTest`: 5/5 ✅ (Chat + Embedding + Milvus 全链路) |