在
路由器
架构中,路由步骤对输入进行分类并将其定向到专门的
智能体
。当您有不同的
垂直领域
——需要各自智能体的独立知识域时,这很有用。
For a complete implementation, see the tutorial below.
主要特点
- 路由器分解查询
- 零个或多个专门的智能体被并行调用
- 结果被综合成连贯的响应
何时使用
当您有不同的垂直领域(需要各自智能体的独立知识域)、需要并行查询多个来源并希望将结果综合成组合响应时,请使用路由器模式。基本实现
路由器对查询进行分类并将其定向到适当的智能体。使用
Command
进行单智能体路由,或使用
Send
进行到多个智能体的并行扇出。
-
Single agent
-
Multiple agents (parallel)
Use
Command
to route to a single specialized agent:
Tutorial: Build a multi-source knowledge base with routing
Build a router that queries GitHub, Notion, and Slack in parallel, then synthesizes results into a coherent answer. Covers state definition, specialized agents, parallel execution with
Send
, and result synthesis.
Stateless vs. stateful
Two approaches:- Stateless routers address each request independently
- Stateful routers maintain conversation history across requests