使用 Fast-Agent 构建链式工作流(Chain Workflow)的步骤如下:
- Generate workflow templates: Run
fast-agent bootstrap workflow
生成包含链式工作流示例的目录。 - Defining Intelligence:编辑生成的
chaining.py
文件,定义链式工作流中的智能体。例如:@fast.agent("url_fetcher", "Given a URL, provide a summary", servers=["fetch"]) @fast.agent("social_media", "Write a 280 character post for the text.") async def main(): async with fast.run() as agent: result = await agent.social_media(await agent.url_fetcher("http://example.com")) print(result)
- Configuring the MCP Server: in
fastagent.config.yaml
中配置 MCP 服务器的端点,例如:servers: fetch: type: "fetch" endpoint: "https://api.example.com"
- Running a workflow: Implementation
uv run chaining.py
,智能体将从指定 URL 获取内容并生成社交媒体帖子。
链式工作流适合需要按顺序执行任务的场景,如数据提取→处理→输出。
This answer comes from the articleFast-Agent: Declarative Grammar and MCP Integration for Rapidly Building Multi-Intelligent Body WorkflowsThe