commit
This commit is contained in:
+3
-1
@@ -22,6 +22,8 @@
|
||||
| RagService | RAG 流式对话 | DashScope Generation → ChatModel.stream() |
|
||||
| MilvusConstants | Milvus 常量 | VECTOR_DIM 改为配置化 |
|
||||
| MilvusProperties | Milvus 配置 | 新增 vectorDim 字段 |
|
||||
| ModelRoutingConfig | 模型路由 | 新增:yml 关键字驱动的 @Primary 路由(Bean 名 > 类名 > 回退) |
|
||||
| SiliconFlowEmbeddingConfig | Embedding | 新增:独立 OpenAiApi → SiliconFlow, BGE-M3 |
|
||||
| application.yml | 配置 | 新增 vector-dim 配置项 |
|
||||
|
||||
## 接口影响
|
||||
@@ -35,6 +37,6 @@
|
||||
- RagService 流式适配最复杂:DashScope Generation 返回 Flowable<GenerationResult>,Spring AI ChatModel.stream() 返回 Flux<ChatResponse>,需适配 StreamCallback 接口
|
||||
- 缓解:Spring AI 的 Flux 与项目已有的 SSE 推送逻辑天然兼容
|
||||
- ChatModel Bean 冲突:多 starter 并存时需 @Primary 或条件注解区分默认实现
|
||||
- 缓解:当前只保留 DashScope starter,不引入多 starter;未来切换时删除旧 starter 即可
|
||||
- 缓解:通过 ModelRoutingConfig 集中管理,@Primary 声明默认 Bean;跨厂商时只改 `@Qualifier` 名
|
||||
- DashScopeConfig 通用性:`spring.ai.dashscope.chat.options.timeout` 是厂商绑定配置键
|
||||
- 缓解:本次保留该配置(只做解耦不换实现);换模型时改配置键
|
||||
+1
@@ -29,6 +29,7 @@
|
||||
- RagService:DashScope SDK `Generation` → Spring AI `ChatModel` stream
|
||||
- DashScopeConfig:通用化配置(保留 DashScope starter 配置,但代码层不再硬编码 DashScope 类)
|
||||
- application.yml:保持现有 DashScope 配置,增加模型切换说明
|
||||
- ModelRoutingConfig:新增 `@Configuration` + `@Primary` 集中路由,支持 Chat/Embedding 跨厂商混合
|
||||
|
||||
- 本次不做:
|
||||
- 不替换 DashScope 为其他提供商(只做解耦,不换实现)
|
||||
+7
-1
@@ -21,4 +21,10 @@
|
||||
|
||||
### S5: RagService 流式对话行为不变
|
||||
- queryStream 方法签名和 StreamCallback 接口不变
|
||||
- 内部实现从 DashScope Generation 切换到 Spring AI ChatModel.stream()
|
||||
- 内部实现从 DashScope Generation 切换到 Spring AI ChatModel.stream()
|
||||
|
||||
### S6: 混合厂商路由支持(yml 驱动)
|
||||
- `model-routing.chat` / `model-routing.embedding` 声明启用哪个模型
|
||||
- ModelRoutingConfig 按关键字匹配 Bean:Bean 名优先 → 类名兜底 → 回退第一个
|
||||
- 切换示例:`chat: deepseek` → `chat: openai`,只改 yml
|
||||
- Service 代码零改动
|
||||
@@ -0,0 +1,38 @@
|
||||
# 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 全链路)
|
||||
@@ -1,22 +0,0 @@
|
||||
# ChatModel + Embedding 解耦 Tasks
|
||||
|
||||
## 需求追踪
|
||||
|
||||
| 需求 | 状态 | 备注 |
|
||||
| --- | --- | --- |
|
||||
| ChatService 解耦 DashScopeChatModel | 待处理 | 改为注入 ChatModel |
|
||||
| ChatController 解耦 DashScope | 待处理 | 删除手动构建逻辑 |
|
||||
| AiOpsService 解耦 DashScopeChatModel | 待处理 | 方法签名改为 ChatModel |
|
||||
| VectorEmbeddingService 解耦 DashScope SDK | 待处理 | 改为注入 EmbeddingModel |
|
||||
| RagService 解耦 DashScope Generation | 待处理 | 改为 ChatModel.stream() |
|
||||
| VECTOR_DIM 配置化 | 待处理 | 从 yml 读取 |
|
||||
|
||||
## 实现任务
|
||||
|
||||
- [ ] T1: MilvusProperties 新增 vectorDim 字段 + getter/setter,application.yml 新增 `milvus.vector-dim: 1024`
|
||||
- [ ] T2: MilvusConstants.VECTOR_DIM 改为从 MilvusProperties 动态读取(MilvusClientFactory 传入)
|
||||
- [ ] T3: ChatService — 删除 createDashScopeApi/createChatModel/createStandardChatModel,新增 @Autowired ChatModel;createReactAgent 参数改为 ChatModel
|
||||
- [ ] T4: ChatController — 删除 DashScope import 和手动构建(行83-84, 171-172, 292-301),改为使用注入 ChatModel 或 ChatService 传入
|
||||
- [ ] T5: AiOpsService — executeAiOpsAnalysis/buildPlannerAgent/buildExecutorAgent 参数类型 DashScopeChatModel → ChatModel
|
||||
- [ ] T6: VectorEmbeddingService — 删除 DashScope SDK import + TextEmbedding 字段 + @PostConstruct init(),改为 @Autowired EmbeddingModel;generateEmbedding 改为调用 EmbeddingModel.embed()
|
||||
- [ ] T7: RagService — 删除 DashScope SDK import + Generation 字段 + Constants.apiKey,改为 @Autowired ChatModel;generateAnswerStream 改为 ChatModel.stream(Prompt) + Flux 适配 StreamCallback
|
||||
Reference in New Issue
Block a user