2.7 KiB
2.7 KiB
上下文词汇表
术语
ChatModel
- 定义:Spring AI 的聊天模型抽象接口,所有 LLM 提供商(DashScope、OpenAI、Ollama 等)都实现此接口
- 使用场景:所有需要 LLM 推理/生成回答的代码应面向此接口编程
EmbeddingModel
- 定义:Spring AI 的文本向量化抽象接口,将文本转换为向量
- 使用场景:RAG 流程中将文档文本转为向量存入 Milvus
DashScopeChatModel
- 定义:DashScope(阿里云)对 ChatModel 的具体实现
- 使用场景:当前项目硬编码使用,需要改为通过 ChatModel 接口引用
ReactAgent
- 定义:Spring AI Alibaba Agent Framework 的反应式 Agent 实现
- 使用场景:Planner-Executor-Replanner 多 Agent 协作
Spring AI Alibaba Agent Framework
- 定义:基于 Spring AI 的多 Agent 协作框架,提供 ReactAgent、PlannerAgent、ExecutorAgent 等
- 使用场景:项目核心 Agent 逻辑,ReactAgent.builder().model() 接受 ChatModel 接口
DeepSeekChatModel
- 定义:Spring AI 原生 DeepSeek 实现(
spring-ai-starter-model-deepseek),非 OpenAI 兼容模式 - 使用场景:Chat → DeepSeek V4 Flash/Pro,支持 reasoning_content
- 配置前缀:
spring.ai.deepseek.*
ModelRoutingConfig
- 定义:项目自定义配置类,yml 关键字驱动的
@Primary路由 - 使用场景:多厂商 starter 并存时,通过
model-routing.chat/model-routing.embedding声明启用哪个模型 - 路由策略:
Map<String, EmbeddingModel>按 Bean 名匹配List<ChatModel>按类名匹配- 未匹配则回退到第一个
- 示例:
model-routing.chat: deepseek→ 选中类名含DeepSeek的 Bean
SiliconFlow
- 定义:硅基流动 AI 平台,提供 OpenAI 兼容 API,项目用它跑 BGE-M3 embedding
- 配置:
siliconflow.*(自定义配置前缀),base-url =https://api.siliconflow.cn - model:
BAAI/bge-m3,1024 维
BGE-M3
- 定义:BAAI 开源的多语言 embedding 模型,1024 维输出
- 使用场景:通过 SiliconFlow API 调用,替代 DashScope text-embedding-v4
- 维度兼容:1024 = 原 DashScope text-embedding-v4,Milvus 无需重建
业务规则
- ChatModel 是唯一 LLM 调用抽象:替换模型只需更换 Spring Boot starter 和配置
- EmbeddingModel 是唯一向量化抽象:替换向量模型只需更换 starter 和配置
- ReactAgent 已兼容 ChatModel 接口,不绑定 DashScope
- base-url 只写 host(如
https://api.deepseek.com),不写版本路径(如/v1),Spring AI 会自动追加 - 多 starter 并存时,必须通过
@Primary或@Qualifier指定默认 Bean - Milvus collection 启动时必须
loadCollection(),否则搜索报collection not loaded