This commit is contained in:
zhuyongxin
2026-05-29 21:38:16 +08:00
parent 80eada415d
commit d4b5015beb
28 changed files with 3373 additions and 47 deletions
@@ -0,0 +1,24 @@
# ChatModel + Embedding 解耦 Specs
## 可观察行为规格
### S1: Chat 接口不变
- `/api/chat`, `/api/chat_stream`, `/api/ai_ops` 的 HTTP 入参/出参/响应结构完全不变
- 功能行为不变:工具调用、Agent 协作、SSE 流式推送照旧工作
### S2: 模型切换只需改配置
- 替换 DashScope starter 为 OpenAI starter + 改 yml 配置 → ChatModel 自动注入不同实现
- 替换 embedding 模型只需改 yml 的 `dashscope.embedding.model` 和 `milvus.vector-dim`
- 不需要改任何 Java 代码
### S3: VECTOR_DIM 从配置读取
- `MilvusClientFactory.createBizCollection()` 使用 MilvusProperties.getVectorDim() 而非 MilvusConstants.VECTOR_DIM
- 切换 embedding 模型后改 yml 的 `milvus.vector-dim` 即可适配新维度
### S4: VectorEmbeddingService 行为不变
- generateEmbedding/generateEmbeddings/generateQueryVector 的签名和返回类型不变
- 内部实现从 DashScope SDK 切换到 Spring AI EmbeddingModel
### S5: RagService 流式对话行为不变
- queryStream 方法签名和 StreamCallback 接口不变
- 内部实现从 DashScope Generation 切换到 Spring AI ChatModel.stream()