Skip to content

Installing ADK

安装 ADK

Create & activate virtual environment

创建并激活虚拟环境

We recommend creating a virtual Python environment using venv:

我们建议使用 venv 创建虚拟 Python 环境:

python -m venv .venv

Now, you can activate the virtual environment using the appropriate command for your operating system and environment:

现在,您可以使用适合您的操作系统和环境的命令来激活虚拟环境:

# Mac / Linux
source .venv/bin/activate

# Windows CMD:
.venv\Scripts\activate.bat

# Windows PowerShell:
.venv\Scripts\Activate.ps1

Install ADK

安装 ADK

pip install google-adk

(Optional) Verify your installation:

(可选)验证您的安装:

pip show google-adk

Install ADK and ADK DevTools

安装 ADK 和 ADK DevTools

npm install @google/adk @google/adk-devtools

Create a new Go module

创建新的 Go 模块

If you are starting a new project, you can create a new Go module:

如果您要开始一个新项目,可以创建一个新的 Go 模块:

go mod init example.com/my-agent

Install ADK

安装 ADK

To add the ADK to your project, run the following command:

要将 ADK 添加到您的项目,请运行以下命令:

go get google.golang.org/adk

This will add the ADK as a dependency to your go.mod file.

这会将 ADK 作为依赖项添加到您的 go.mod 文件中。

(Optional) Verify your installation by checking your go.mod file for the google.golang.org/adk entry.

(可选)通过检查您的 go.mod 文件中的 google.golang.org/adk 条目来验证您的安装。

You can either use maven or gradle to add the google-adk and google-adk-dev package.

您可以使用 Maven 或 Gradle 来添加 google-adkgoogle-adk-dev 包。

google-adk is the core Java ADK library. Java ADK also comes with a pluggable example SpringBoot server to run your agents seamlessly. This optional package is present as part of google-adk-dev.

google-adk 是核心 Java ADK 库。Java ADK 还附带了一个可插拔的示例 SpringBoot 服务器,可以无缝运行您的智能体。这个可选包作为 google-adk-dev 的一部分提供。

If you are using maven, add the following to your pom.xml:

如果您使用 Maven,请将以下内容添加到您的 pom.xml 中:

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example.agent</groupId>
    <artifactId>adk-agents</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!-- Specify the version of Java you'll be using -->
    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- The ADK core dependency -->
        <dependency>
            <groupId>com.google.adk</groupId>
            <artifactId>google-adk</artifactId>
            <version>0.5.0</version>
        </dependency>
        <!-- The ADK dev web UI to debug your agent -->
        <dependency>
            <groupId>com.google.adk</groupId>
            <artifactId>google-adk-dev</artifactId>
            <version>0.5.0</version>
        </dependency>
    </dependencies>

</project>

Here's a complete pom.xml file for reference.

这里有一个完整的 pom.xml 文件供参考。

If you are using gradle, add the dependency to your build.gradle:

如果您使用 Gradle,请将依赖项添加到您的 build.gradle 中:

build.gradle
dependencies {
    implementation 'com.google.adk:google-adk:0.5.0'
    implementation 'com.google.adk:google-adk-dev:0.5.0'
}

You should also configure Gradle to pass -parameters to javac. (Alternatively, use @Schema(name = "...")).

您还应该配置 Gradle 以将 -parameters 传递给 javac。(或者,使用 @Schema(name = "..."))。

Next steps

下一步