Files
2026-05-31 21:45:14 +08:00

34 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ChatModel + Embedding 解耦 — Brief
## 背景
项目 5 个 Java 文件硬编码 DashScope 具体实现类(`DashScopeChatModel`、`TextEmbedding`、`Generation`),替换 LLM 或 Embedding 模型需要改代码而非改配置。
## 目标
面向 Spring AI 抽象接口(`ChatModel`、`EmbeddingModel`)编程,通过 Spring Boot Starter + yml 配置切换模型实现。
## 范围
- ChatService/ChatController/AiOpsService → `@Autowired ChatModel`
- VectorEmbeddingService → `@Autowired EmbeddingModel`
- RagService → `ChatModel.stream()` 替代 DashScope `Generation`
- VECTOR_DIM → 配置化(`application.yml`)
- 新增 ModelRoutingConfig(yml 关键字驱动的 @Primary 路由)
- 新增 SiliconFlowEmbeddingConfig(BGE-M3 via SiliconFlow)
## 非目标
- 不替换 DashScope 为其他提供商(只做解耦,不换实现)→ 后期追加了 DeepSeek + SiliconFlow
- 不修改 Agent Framework 本身
- 不改 Milvus 核心逻辑
- 不改 MCP 客户端
## 最终模型
| 角色 | 厂商 | 实现 |
|---|---|---|
| Chat | DeepSeek V4 Flash | `DeepSeekChatModel` (Spring AI 原生) |
| Embedding | SiliconFlow BGE-M3 | `OpenAiEmbeddingModel` (OpenAI 兼容) |
| 向量存储 | Zilliz Cloud (Milvus) | `MilvusServiceClient` |