教程8:简单多智能体研究员(与ADK一起运行)


文档摘要

教程 8:简单多智能体研究员(与 ADK 一起运行) 您将学到的内容 使用协调器智能体与专业子智能体进行多智能体编排 顺序工作流,其中智能体相互依赖、层层递进 集成网络搜索,实现实时研究功能 通过 ADK Web 运行,以交互方式测试多智能体系统 核心概念:多智能体研究流水线 一个协调器 在顺序工作流中编排三个专业智能体:研究 → 总结 → 评论。每个智能体都为构建一份全面的研究报告贡献力量。 项目结构 开始使用 安装依赖项 进入 文件夹,并安装所需的库: 设置环境 创建一个 file in the 文件夹: 重要提示:请将 with your actual Google AI Studio API key from https://aistudio.google.

教程 8:简单多智能体研究员(与 ADK 一起运行)

您将学到的内容

  • 使用协调器智能体与专业子智能体进行多智能体编排
  • 顺序工作流,其中智能体相互依赖、层层递进
  • 集成网络搜索,实现实时研究功能
  • 通过 ADK Web 运行,以交互方式测试多智能体系统

核心概念:多智能体研究流水线

一个协调器 LlmAgent 在顺序工作流中编排三个专业智能体:研究 → 总结 → 评论。每个智能体都为构建一份全面的研究报告贡献力量。

User Query → Coordinator Agent │ ├──▶ Research Agent (web search + analysis) │ │ │ └──▶ Research Findings │ ├──▶ Summarizer Agent (synthesis) │ │ │ └──▶ Key Insights │ └──▶ Critic Agent (quality analysis) │ └──▶ Final Report with Recommendations

项目结构

8_simple_multi_agent/ ├── README.md # This file ├── requirements.txt # Dependencies ├── multi_agent_researcher/ # Main implementation │ ├── agent.py # Multi-agent system (exports root_agent) └── .env # Environment variables (create this)

开始使用

1. 安装依赖项

进入 8_simple_multi_agent 文件夹,并安装所需的库:

cd 8_simple_multi_agent pip install -r requirements.txt

2. 设置环境

创建一个 .env file in the 8_simple_multi_agent 文件夹:

# Create .env file echo "GOOGLE_API_KEY=your_ai_studio_key_here" > .env

重要提示:请将 your_ai_studio_key_here with your actual Google AI Studio API key from https://aistudio.google.com/

From the 8_simple_multi_agent 文件夹替换为:

adk web

ADK Web 设置:

  • 打开终端中打印的本地 URL
  • 在导入部分,使用以下路径:
ai_agent_framework_crash_course.google_adk_crash_course.8_simple_multi_agent.multi_agent_researcher
  • 选择 root_agent 对象
  • 开始与您的多智能体研究员聊天吧!

可试用的示例提示

综合性研究查询:

Research the future of renewable energy integration in smart cities, including current technologies, implementation challenges, economic feasibility, and policy requirements. Provide a critique and suggestions.

其他测试查询:

"Research the current state of AI regulation in the European Union and its impact on business innovation"
"Investigate the latest developments in CRISPR gene editing technology and its potential applications in medicine"
"Research the effectiveness of personalized learning platforms in K-12 education, including current implementations and learning outcomes"

工作原理

研究智能体:

  • 使用 Google 搜索进行全方位网络研究
  • 收集最新信息、趋势和动态
  • 提供结构化的发现结果,附带来源和大纲

总结智能体:

  • 将研究内容提炼成清晰、可操作的见解
  • 制作执行摘要和关键要点
  • 识别关键模式和核心收获

评论智能体:

  • 进行质量分析并识别差距
  • 提供风险评估和机会分析
  • 给出可操作的建议和下一步行动

协调器:

  • 编排整个研究工作流
  • 确保正确顺序:研究 → 总结 → 评论
  • 将所有输出整合到一份连贯的最终报告中

最佳效果小贴士

  • 在研究查询中明确具体,以便更好地协调各智能体
  • 允许完整工作流顺利完成,以获得更全面的结果
  • 系统会自动遵循研究流水线,进行彻底分析
  • 每个智能体都基于前一个智能体的工作成果,从而获得更深入的洞察

下一步

掌握本教程后,您可以探索:

  • 教程 9:工作流智能体(顺序、并行、分支)
  • 高级模式:自定义工具与智能体通信
  • 集成:连接外部数据源和 API

故障排除

  • API 密钥问题:确保您的 .env file is in the correct location and contains a valid GOOGLE_API_KEY
  • Import Errors: Make sure you're using the exact import path shown above
  • Agent Not Found: Verify that root_agent 正确从模块中导出

免责声明
本文档采用基于机器的 AI 翻译服务进行翻译。尽管我们力求准确,但请注意,自动翻译可能存在错误或不准确之处。应以原文语言版本的文档作为权威依据。如需获取关键信息,建议使用专业的人工翻译。对于因使用本翻译而产生的任何误解或误读,我们概不负责。


发布者: 作者: 转发
评论区 (0)
U