> [!NOTE] > 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。 > [English](./README.en.md) · [原始项目](https://github.com/google/adk-python) · [上游 README](https://github.com/google/adk-python/blob/HEAD/README.md) > 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。 # Agent Development Kit (ADK) 2.0 [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE) [![PyPI version](https://img.shields.io/pypi/v/google-adk.svg)](https://pypi.org/project/google-adk/) [![Python versions](https://img.shields.io/pypi/pyversions/google-adk.svg)](https://pypi.org/project/google-adk/) [![PyPI downloads](https://static.pepy.tech/badge/google-adk/month)](https://pepy.tech/project/google-adk) [![Unit Tests](https://github.com/google/adk-python/actions/workflows/python-unit-tests.yml/badge.svg)](https://github.com/google/adk-python/actions/workflows/python-unit-tests.yml) [![Docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://google.github.io/adk-docs/)

一个开源、代码优先(code-first)的 Python 框架,用于以灵活性和可控性构建、评估和部署复杂的 AI 智能体。

重要链接: DocsSamplesADK Web

______________________________________________________________________ > **⚠️ 与 1.x 相比的重大变更(BREAKING CHANGES)** > > 本版本对智能体 API、事件模型和会话 schema 包含破坏性变更。**ADK 2.0 生成的会话可被 ADK 1.28+ 读取(额外字段将被忽略),但与更早的 1.x 版本不兼容。** ______________________________________________________________________ ## 🔥 2.0 新特性 - **Workflow Runtime(工作流运行时)**:基于图的执行引擎,用于为智能体应用编排确定性执行流程,支持路由、扇出/扇入(fan-out/fan-in)、循环、重试、状态管理、动态节点、人机协同(human-in-the-loop)以及嵌套工作流。 - **Task API(任务 API)**:结构化的智能体间委托,支持多轮任务模式、单轮受控输出、混合委托模式、人机协同,以及将任务智能体作为工作流节点。 ## 🚀 安装 ```bash pip install google-adk ``` **要求:** Python 3.10+。 要安装可选集成,可使用以下命令: ```bash pip install "google-adk[extensions]" ``` 发布节奏大约每两周一次。 ## 快速开始 > **新手提示:** ADK 应用使用两个主要类构建: > **`Agent`**(定义 AI 的指令、工具和行为)以及 > **`Workflow`**(在基于图的流程中编排智能体与任务)。 ### Agent ```python from google.adk import Agent root_agent = Agent( name="greeting_agent", model="gemini-2.5-flash", instruction="You are a helpful assistant. Greet the user warmly.", ) ``` ### Workflow ```python from google.adk import Agent, Workflow generate_fruit_agent = Agent( name="generate_fruit_agent", instruction="Return the name of a random fruit. Return only the name.", ) generate_benefit_agent = Agent( name="generate_benefit_agent", instruction="Tell me a health benefit about the specified fruit.", ) root_agent = Workflow( name="root_agent", edges=[("START", generate_fruit_agent, generate_benefit_agent)], ) ``` ### 本地运行 ```bash # Interactive CLI adk run path/to/my_agent # Web UI (supports multi-agent directories or pointing directly to a single agent folder) adk web path/to/agents_dir ``` ## 📚 文档 - **入门指南(Getting Started)**:https://google.github.io/adk-docs/ - **示例(Samples)**:请参阅 `contributing/workflow_samples/` 和 `contributing/task_samples/`,了解工作流与任务 API 示例。 ## 🤝 贡献 详情请参阅 [CONTRIBUTING.md](CONTRIBUTING.md)。 ## 📄 许可证 本项目采用 Apache 2.0 License 许可 — 详情请参阅 [LICENSE](LICENSE) 文件。