1
0
md/MultiAgentOptions.md
liushuang 89d06cb99d add
2025-10-09 17:23:45 +08:00

120 lines
8.1 KiB
Markdown
Raw 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.

# 横评构建企业级 LLM 应用,主流的、开源框架
## 基础能力
| 对比项 | SAA| Spring AI | LangChain4J | LangChain |
|:-----|:-----|:-----|:-----|:-----|
| 语言 | Java | Java | Java | Python |
| 聊天模型 | ✅ | ✅ | ✅ | ✅ |
| 嵌入模型 | ✅ | ✅ | ✅ | ✅ |
| 图片、音视频模型 | ✅ | ✅ | ✅ | **百度千帆、百川智能支持多模态**<br/>**阿里百炼不支持多模态** |
| RAG | ✅ | ✅ | ✅ | ✅ |
| 向量数据库 | **除主流向量数据库外,还支持阿里云:<br/>AnalyticDB (ADB)、OpenSearch** | ✅ | ✅ | ✅ |
| MCP | **支持 Nacos MCP Registry** | ✅ | ✅ | ✅ |
| 函数调用 | ✅ | ✅ | ✅ | ✅ |
| 提示词模板 | **支持通过 Nacos 热更新,无需重启应用** | ✅ | ✅ | ✅ |
| 聊天记忆 | ✅ | ✅ | ✅ | ✅ |
| 模型评估 | ✅ | ✅ | ✅ | ✅ |
> 💡SAA 是 Spring AI Alibaba 的官方简称。**SAA 在对 MCP 工具、提示词模板的管理具有明显优势,尤其适合企业级 LLM 应用的构建。**
## 可观测性OpenTelemetry
**OpenTelemetry** 通常缩写为**OTel**,是一个开源的、厂商中立的可观测性框架,旨在实现遥测数据的标准化生成、收集和管理。遥测数据包括日志、指标和追踪,这些数据对于监控和理解软件系统的行为至关重要。
| Spring AI | SAA | LangChain4J | LangChain |
|:-----|:-----|:-----|:-----|
| ✅ | ✅ | ❌ | ✅ |
**Spring AI**框架定义了一系列endpoint为其核心组件提供了指标和追踪能力例如 ChatClient包括 Advisor、ChatModel、EmbeddingModel、ImageModel 和 VectorStore 等。**SAA**除了拥有**Spring AI**的能力还提供了配套工具无需额外编写代码即可扇出至阿里云ARMS。**LangChain4J**提供了一系列**Listener**,通过 OTel 扇出数据,需要自行实现。**LangChain**自带**LangSmith**并且支持了OTel仅需少量代码即可扇出数据。
#### Spring AI 对于 ChatModel 仅适配了部分模型提供商,未提到的厂商,官方宣称将在未来支持。
| 阿里百炼 | 百度千帆 | 月之暗面 | 智谱 | Anthropic | OpenAI | Ollama | Xinference | GPUStack |
|:-----|:-----|:-----|:-----|:-----|:-----|:-----|:-----|:-----|
| ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
## 云计算平台模型提供商对开源框架的适配
| 对比项 | Open AI | Anthropic | 阿里百炼 | 百度千帆 |
|:-----|:-----|:-----|:-----|:-----|
| SAA | ✅ | ✅ | 深度适配 | ✅ |
| Spring AI | ✅ | ✅ | ✅ | ✅ |
| LangChain4J | ✅ | ✅ | ✅ | ✅ |
| LangChain | ✅ | ✅ | 部分适配 | ✅ |
> 💡阿里百炼对于**LangChain**仅通过 langchain-openai 适配了部分模型:聊天模型、嵌入模型、重排序模型,**不支持多模态模型**。
## 适合用于智能体开发的框架对比
#### 一、LangGraph
- 开源协议MIT
- 语言Python
- 核心使用图结构编排智能体相比LangChain的链式调用能够应对更多场景、更复杂的任务。
- 亮点:内置 Checkpoint 和中断、持久化机制,在执行期间发生中断,恢复时可以从 Checkpoint 继续执行。适合通过**人工干预**保障执行过程的正确性,以及**长时间运行的任务**发生异常中断从 Checkpoint 恢复执行,而不必重新开始,这是
LangGraph 的独到之处
- 补充:官方的 LangGraph Platform 还提供了配套的 LangGraph Studio 用于开发智能体的 IDE它支持可视化、交互和调试还与 LangSmith 集成,以实现追踪、评估和提示工程。
- 模型:参见上文对于 LangChain 支持的模型提供商说明
> 💡LangGraph Platform 是**收费**的,适合企业部署的自托管版本仅支持 AWS。
#### 二、Spring AI Alibaba Graph
- 开源协议Apache 2.0
- 语言Java
- 亮点LangGraph 的核心能力基本上都抄了
- 模型:参见上文对于 SAA 支持的模型提供商说明
官方原话Spring AI Alibaba Graph 是社区核心实现之一,也是整个框架在设计理念上区别于 Spring AI 只做底层原子抽象的地方Spring AI Alibaba 期望帮助开发者更容易的构建智能体应用。基于 Graph 开发者可以构建工作流、多智能体应用。**Spring AI Alibaba Graph 在设计理念上借鉴 LangGraph因此在一定程度上可以理解为是 Java 版的 LangGraph 实现**,社区在此基础上增加了大量预置 Node、简化了 State 定义过程等,让开发者更容易编写对等低代码平台的工作流、多智能体等。
#### 三、AutoGen
- 开源协议MIT
- 语言Python、.NET
- 核心通过智能体运行时环境使用消息作为多智能体之间的通信载体基于发布订阅的模式在智能体之间实现1对1和1对多的传播形式。
- 亮点命令行代码执行器能够将Python代码块打包成1个文件丢到 Docker 容器执行或者在本机开启1个新的进程执行。这种方式更安全也是 LangGraph
不具备的特性。除此之外,官方提供了一系列多智能体的设计模式,来辅助开发者设计与开发多智能体。
- 补充AutoGen 还提供了一个免费的、本地化部署的 AutoGen Studio 可视化工具,旨在帮助开发团队快速原型化多智能体。
- 模型OpenAI API 兼容的模型提供商、托管在 Azure 上的模型、Ollama、Anthropic通过 SKChatCompletionAdapter 已适配的其它 LLM 提供商有Google、MistralAI、AWS、Hugging Face。
官方提供了以下多智能体设计模式
- Concurrent Agents并发智能体
- Sequential Workflow顺序工作流
- Group Chat群聊
- Handoffs交接源自OpenAI Swarm
- Mixture of Agents混合代理
- Multi-Agent Debate多智能体辩论
- Reflection反思
- Code Execution代码执行
#### 四、Crew AI
- 开源协议MIT
- 语言Python
- 核心:
- 亮点:
- 模型CrewAI 通过 LiteLLM 连接到 LLM 提供商,[点击查看 LiteLLM 支持的模型提供商](https://docs.litellm.com.cn/docs/providers)[点击查看对于 Xinference 的支持说明](https://docs.litellm.com.cn/docs/providers/xinference)
## 参考来源
- SAA 官网https://java2ai.com
- Spring AI 官方文档https://docs.springframework.org.cn/spring-ai/reference/index.html
- LangChain4J 官方文档https://docs.langchain4j.info/get-started
- LangChain 官方文档https://python.langchain.ac.cn/docs/introduction
- 使用 OpenTelemetry 跟踪 LangChainhttps://langsmith.langchain.ac.cn/observability/how_to_guides/trace_langchain_with_otel
- 使用 OpenTelemetry 客户端将记录到 LangSmithhttps://langsmith.langchain.ac.cn/observability/how_to_guides/trace_with_opentelemetry
- Spring AI 可观测性https://docs.springframework.org.cn/spring-ai/reference/observability/index.html
- Spring AI 对于聊天模型可观测性的支持说明https://docs.springframework.org.cn/spring-ai/reference/observability/index.html#_chat_model
- 阿里百炼对于 LangChain 的适配https://help.aliyun.com/zh/model-studio/use-bailian-in-langchain
- 百度千帆对于 LangChain 的适配https://cloud.baidu.com/doc/qianfan-docs/s/Mm9cr5bs6
- LangGraph 官方文档https://github.langchain.ac.cn/langgraph/
- LangGraph Platform 官方文档https://github.langchain.ac.cn/langgraphjs/concepts/langgraph_platform/
- LangGraph Platform 定价说明https://langchain.ac.cn/pricing-langgraph-platform
- LangGraph Studio 使用说明https://github.langchain.ac.cn/langgraphjs/concepts/langgraph_studio/
- AutoGen 官方文档https://msdocs.cn/autogen/stable/user-guide/core-user-guide/quickstart.html
- AutoGen 运行时环境https://msdocs.cn/autogen/stable/user-guide/core-user-guide/core-concepts/architecture.html
- AutoGen 主题和订阅消息传递https://msdocs.cn/autogen/stable/user-guide/core-user-guide/core-concepts/topic-and-subscription.html
- AutoGen 多智能体设计模式https://msdocs.cn/autogen/stable/user-guide/core-user-guide/design-patterns/intro.html
- AutoGen Studio 使用教程https://www.aidoczh.com/autogen/stable/user-guide/autogenstudio-user-guide/index.html