第11章 AI框架与平台选型

选框架就像选工具。没有最好的,只有最适合你的。

这一章帮你根据自己的需求,选对框架和平台。


11.1 从一个选型错误说起

我选型时会先画数据流,再挑框架名字。

一个团队想做一个AI客服Agent。他们选了CrewAI作为框架,因为听说它”上手快”。

做到一半发现:他们的客服流程有很多条件分支(用户投诉→转人工、用户咨询→自动回复、用户退货→调用退款API),CrewAI的线性流程处理不了这些分支。

他们不得不换到LangGraph,之前写的代码大部分要重写。

如果一开始就根据需求选对框架,这些返工是可以避免的。


11.2 编排框架:LangGraph vs CrewAI vs AutoGen

LangGraph

LangChain团队出品。用有向图建模Agent工作流。

2026年的最新特性

  • 子图模块化:团队可独立开发、测试子图
  • Pydantic v3集成:高性能、类型安全的状态定义
  • 增强的Human-in-the-loop API

优势:灵活性最高。支持任意复杂的流程——循环、分支、并行、子图。状态管理和持久化做得好。社区活跃,文档齐全。

劣势:学习曲线较陡。概念多(State、Node、Edge、Checkpoint),新手需要时间理解。

适合:需要高度定制化的复杂Agent。有技术基础的团队。

CrewAI

专注于多Agent协作的框架。

优势:上手快。用角色(Role)、任务(Task)、团队(Crew)的概念组织Agent,直觉好理解。内置了常见的Agent模式。

劣势:灵活性不如LangGraph。复杂的自定义流程可能实现不了。

适合:需要多个Agent协作的场景。想快速上手的团队。

Microsoft AutoGen 2.0

2026年重构,专注于企业级异步Agent对话。

优势:微软背书,和Azure深度集成。企业级支持好。

劣势:社区不如LangChain活跃。

适合:已经在用Azure的团队。需要企业级支持的场景。

怎么选

需求推荐
高度定制化LangGraph
多Agent快速上手CrewAI
Azure生态AutoGen 2.0
不确定LangGraph(生态最大,资料最多)

框架对比

  • LangGraph:用有向图建模Agent工作流,支持复杂条件分支、循环、并行
  • CrewAI:用角色(Role)、任务(Task)、团队(Crew)的概念组织Agent协作

11.3 模型平台

海外平台

OpenAI:GPT-5.5系列。综合能力最强。API稳定,文档齐全。价格较高。

Anthropic:Claude 4系列。长文本处理、代码生成、安全性做得好。API设计简洁。

Google:Gemini 3系列。多模态能力强。价格有竞争力。

国产平台

DeepSeek:V4系列(2026年4月发布)。推理能力强,价格极低(V4-Flash $0.14/百万token)。兼容OpenAI和Anthropic API格式。开源可部署。

通义千问(阿里):Qwen系列。中文效果好。DashScope API兼容OpenAI格式。价格便宜。

Kimi(月之暗面):长文本处理能力强。API简单易用。

怎么选

需求推荐
综合能力最强OpenAI GPT-5.5
代码+安全Anthropic Claude 4
多模态Google Gemini 3
性价比极高DeepSeek V4-Flash
中文+便宜通义千问
长文本Kimi
离线/隐私DeepSeek(本地部署)

模型路由代码示例:


11.4 低代码平台

Dify

开源的AI应用开发平台。拖拽式界面,可视化编排。

适合:不想写代码但想构建AI应用的团队。快速原型验证。

Coze(扣子)

字节跳动出品。低代码Agent构建平台。

适合:想快速搭建聊天机器人和简单Agent的用户。中文生态好。

n8n

开源的自动化工作流平台。支持AI节点。

适合:需要把AI集成到现有业务流程中的团队。自动化场景。

怎么选

需求推荐
开源+灵活Dify
中文+简单Coze
业务自动化n8n
全定制化不用低代码,直接用框架

11.5 本地 vs 云端

本地部署

模型运行在你自己的服务器或电脑上。

优点:数据不离开本地,隐私好。不依赖网络。长期使用成本低。

缺点:需要强大的硬件(GPU)。配置复杂。模型选择受限于硬件能力。

云端调用

通过API调用云服务商的模型。

优点:开箱即用,不需要硬件。模型选择多。按需付费。

缺点:数据经过第三方。有网络延迟。长期使用成本高。

怎么选

需求推荐
数据隐私敏感本地
快速上手云端
高频调用+成本敏感本地
需要最新模型云端
混合方案核心逻辑本地,非敏感任务云端

本章小结

框架和平台选型的核心原则:

  1. 没有最好的,只有最适合的。根据你的需求、预算、技术能力选择。
  2. 先简单后复杂。能用低代码就不用框架,能用框架就不用自研。
  3. 模型趋同,Harness拉开差距。模型选择的影响在缩小,框架和工具选择的影响在增大。

下一章讲生产化——从Demo到可用的Agent。

Ch11 AI Frameworks & Platform Selection

Choosing a framework is like choosing a tool. There’s no “best”—only what’s best for you.

This chapter helps you choose the right framework and platform based on your needs.


11.1 Starting with a Selection Mistake

A team wanted to build an AI customer service Agent. They chose CrewAI as their framework because they heard it was “easy to get started with”.

Halfway through development, they discovered: their customer service workflow had many conditional branches (user complaint → transfer to human, user inquiry → auto-reply, user return → call refund API). CrewAI’s linear workflow couldn’t handle these branches.

They had to switch to LangGraph, and most of the code they’d written had to be rewritten.

If they’d chosen the right framework from the start based on their requirements, this rework could have been avoided.


11.2 Orchestration Frameworks: LangGraph vs CrewAI vs AutoGen

LangGraph

From the LangChain team. Uses directed graphs to model Agent workflows.

Latest features in 2026:

  • Subgraph modularity: Teams can independently develop and test subgraphs
  • Pydantic v3 integration: High-performance, type-safe state definition
  • Enhanced Human-in-the-Loop API

Advantages: Highest flexibility. Supports arbitrarily complex workflows—loops, branches, parallelism, subgraphs. State management and persistence are well-done. Active community, comprehensive documentation.

Disadvantages: Steeper learning curve. Many concepts (State, Node, Edge, Checkpoint) that beginners need time to understand.

Suitable for: Complex Agents requiring high customization. Teams with technical foundation.

CrewAI

A framework focused on multi-Agent collaboration.

Advantages: Quick to get started. Uses concepts of Role, Task, and Crew to organize Agents, intuitively understandable. Built-in common Agent patterns.

Disadvantages: Less flexible than LangGraph. Complex custom workflows might not be implementable.

Suitable for: Scenarios requiring multiple Agents to collaborate. Teams wanting to get started quickly.

Microsoft AutoGen 2.0

Refactored in 2026, focused on enterprise-grade asynchronous Agent dialogue.

Advantages: Backed by Microsoft, deeply integrated with Azure. Good enterprise-grade support.

Disadvantages: Community not as active as LangChain’s.

Suitable for: Teams already using Azure. Scenarios requiring enterprise-grade support.

How to Choose

NeedRecommendation
Highly customizedLangGraph
Multi-Agent, quick startCrewAI
Azure ecosystemAutoGen 2.0
Not sureLangGraph (largest ecosystem, most resources)

Framework comparison:

  • LangGraph: Uses directed graphs to model Agent workflows, supports complex conditional branches, loops, parallelism
  • CrewAI: Uses concepts of Role, Task, and Crew to organize Agent collaboration

11.3 Model Platforms

Overseas Platforms

OpenAI: GPT-5.5 series. Strongest comprehensive capabilities. Stable API, comprehensive documentation. Higher price.

Anthropic: Claude 4 series. Long-text processing, code generation, and safety are well-done. Clean API design.

Google: Gemini 3 series. Strong multimodal capabilities. Competitive pricing.

Domestic Platforms

DeepSeek: V4 series (released April 2026). Strong reasoning capabilities, extremely low price ($0.14/million tokens). Compatible with OpenAI and Anthropic API formats. Open-source and deployable.

Qwen (Alibaba): Qwen series. Good Chinese performance. DashScope API compatible with OpenAI format. Cheap price.

Kimi (Moonshot): Strong long-text processing capabilities. Simple and easy-to-use API.

How to Choose

NeedRecommendation
Strongest comprehensive capabilityOpenAI GPT-5.5
Code + SafetyAnthropic Claude 4
MultimodalGoogle Gemini 3
Extremely high cost-performanceDeepSeek V4-Flash
Chinese + CheapQwen
Long textKimi
Offline/PrivacyDeepSeek (local deployment)

11.4 Low-Code Platforms

Dify

Open-source AI application development platform. Drag-and-drop interface, visual orchestration.

Suitable for: Teams that don’t want to write code but want to build AI applications. Rapid prototype validation.

Coze (字节跳动)

From ByteDance. Low-code Agent building platform.

Suitable for: Users wanting to quickly build chatbots and simple Agents. Good Chinese ecosystem.

n8n

Open-source automation workflow platform. Supports AI nodes.

Suitable for: Teams needing to integrate AI into existing business processes. Automation scenarios.

How to Choose

NeedRecommendation
Open-source + FlexibleDify
Chinese + SimpleCoze
Business automationn8n
Fully customizedDon’t use low-code, use frameworks directly

11.5 Local vs Cloud

Local Deployment

Models run on your own server or computer.

Advantages: Data doesn’t leave the local machine, good privacy. No dependency on network. Low long-term usage cost.

Disadvantages: Requires powerful hardware (GPU). Complex configuration. Model selection limited by hardware capabilities.

Cloud API Calls

Call model APIs from cloud service providers.

Advantages: Works out of the box, no hardware needed. Many model choices. Pay-as-you-go.

Disadvantages: Data passes through third parties. Has network latency. High long-term cost.

How to Choose

NeedRecommendation
Data privacy sensitiveLocal
Quick startCloud
High-frequency calls + cost-sensitiveLocal
Need latest modelsCloud
Hybrid solutionCore logic local, non-sensitive tasks cloud

Chapter Summary

Core principles of framework and platform selection:

  1. No “best”, only “most suitable”. Choose based on your needs, budget, and technical capability.
  2. Simple first, complex later. Use low-code if possible, use frameworks if necessary, build custom only if needed.
  3. Models converging, Harness makes the difference. The impact of model choice is shrinking; the impact of framework and tool choice is growing.

The next chapter covers productionization—from Demo to usable Agent.