-
Notifications
You must be signed in to change notification settings - Fork 351
Phase 1: ADK Onboarding journey revision #739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6c19f2f
Phase 1: ADK Onboarding journey revision
joefernandez 7228cb1
Updates from first review round and Java research
joefernandez ee34939
further updates from review
joefernandez c1683fd
more review updates
joefernandez f2caba6
Merge branch 'main' into qs-split-rewrite
koverholt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,23 @@ | ||
# Get Started | ||
# Get started | ||
|
||
Agent Development Kit (ADK) is designed to empower developers | ||
to build, manage, evaluate and deploy AI-powered agents. It provides a robust | ||
and flexible environment for creating both conversational and non-conversational | ||
agents, capable of handling complex tasks and workflows. | ||
Agent Development Kit (ADK) is designed to empower developers to quickly build, | ||
manage, evaluate and deploy AI-powered agents. These quick start guides get you | ||
set up and running a simple agent in less than 20 minutes. | ||
|
||
<div class="grid cards" markdown> | ||
|
||
- :material-console-line: **Installation** | ||
- :fontawesome-brands-python:{ .lg .middle } **Python Quickstart** | ||
|
||
--- | ||
Create your first Python ADK agent in minutes. | ||
|
||
Install `google-adk` for Python or Java and get up and running in minutes. | ||
[:octicons-arrow-right-24: Start with Python](/adk-docs/get-started/python) <br> | ||
joefernandez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[:octicons-arrow-right-24: More information](installation.md) | ||
|
||
- :material-console-line: **Quickstart** | ||
|
||
--- | ||
|
||
Create your first ADK agent with tools in minutes. | ||
|
||
[:octicons-arrow-right-24: More information](quickstart.md) | ||
|
||
- :material-console-line: **Quickstart (streaming)** | ||
|
||
--- | ||
|
||
Create your first streaming ADK agent. | ||
|
||
[:octicons-arrow-right-24: More information](streaming/quickstart-streaming.md) | ||
|
||
- :material-console-line: **Tutorial** | ||
- :fontawesome-brands-java:{ .lg .middle } **Java Quickstart** | ||
|
||
--- | ||
Create your first Java ADK agent in minutes. | ||
|
||
Create your first ADK multi-agent. | ||
|
||
[:octicons-arrow-right-24: More information](../tutorials/index.md) | ||
|
||
- :material-rocket-launch-outline: **Discover sample agents** | ||
|
||
--- | ||
|
||
Discover sample agents for retail, travel, customer service, and more! | ||
|
||
[:octicons-arrow-right-24: Discover adk-samples](https://github.com/google/adk-samples){:target="_blank"} | ||
|
||
- :material-graph: **About** | ||
|
||
--- | ||
|
||
Learn about the key components of building and deploying ADK agents. | ||
|
||
[:octicons-arrow-right-24: More information](about.md) | ||
[:octicons-arrow-right-24: Start with Java](/adk-docs/get-started/java.md) <br> | ||
joefernandez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
# Java Quickstart for ADK | ||
|
||
This guide shows you how to get up and running with Agent Development Kit | ||
for Java. Before you start, make sure you have the following installed: | ||
|
||
* Java 17 or later | ||
* Maven 3.9 or later | ||
|
||
## Create an agent project | ||
|
||
Create an agent project with the following files and directory structure: | ||
|
||
```console | ||
my_agent/ | ||
joefernandez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
src/main/java/com/example/agent/ | ||
HelloTimeAgent.java # main agent code | ||
joefernandez marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
pom.xml # project configuration | ||
.env # API keys or project IDs | ||
``` | ||
|
||
??? tip "Create this project structure using the command line" | ||
|
||
=== "Windows" | ||
|
||
```console | ||
mkdir my_agent\src\main\java\com\example\agent | ||
type nul > my_agent\src\main\java\com\example\agent\HelloTimeAgent.java | ||
type nul > my_agent\pom.xml | ||
type nul > my_agent\.env | ||
``` | ||
|
||
=== "MacOS / Linux" | ||
|
||
```bash | ||
mkdir -p my_agent/src/main/java/com/example/agent && \ | ||
touch my_agent/src/main/java/com/example/agent/HelloTimeAgent.java \ | ||
touch my_agent/pom.xml my_agent/.env | ||
``` | ||
|
||
### Define the agent code | ||
|
||
Create the code for a basic agent, including a simple implementation of an ADK | ||
[Function Tool](/adk-docs/tools/function-tools/), called `getCurrentTime()`. | ||
Add the following code to the `HelloTimeAgent.java` file in your project | ||
directory: | ||
|
||
```java title="my_agent/src/main/java/com/example/agent/HelloTimeAgent.java" | ||
package com.example.agent; | ||
|
||
import com.google.adk.agents.BaseAgent; | ||
import com.google.adk.agents.LlmAgent; | ||
import com.google.adk.tools.Annotations.Schema; | ||
import com.google.adk.tools.FunctionTool; | ||
|
||
import java.util.Map; | ||
|
||
public class HelloTimeAgent { | ||
|
||
public static BaseAgent ROOT_AGENT = initAgent(); | ||
|
||
private static BaseAgent initAgent() { | ||
return LlmAgent.builder() | ||
.name("hello-time-agent") | ||
.description("Tells the current time in a specified city") | ||
.instruction(""" | ||
You are a helpful assistant that tells the current time in a city. | ||
Use the 'getCurrentTime' tool for this purpose. | ||
""") | ||
.model("gemini-2.5-flash") | ||
.tools(FunctionTool.create(HelloTimeAgent.class, "getCurrentTime")) | ||
.build(); | ||
} | ||
|
||
/** Mock tool implementation */ | ||
@Schema(description = "Get the current time for a given city") | ||
public static Map<String, String> getCurrentTime( | ||
@Schema(name = "city", description = "Name of the city to get the time for") String city) { | ||
return Map.of( | ||
"city", city, | ||
"forecast", "The time is 10:30am." | ||
); | ||
} | ||
} | ||
``` | ||
|
||
### Configure project and dependencies | ||
|
||
An ADK agent project requires this dependency in your | ||
`pom.xml` project file: | ||
|
||
```xml title="my_agent/pom.xml (partial)" | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.adk</groupId> | ||
<artifactId>adk-core</artifactId> | ||
<version>0.3.0</version> | ||
</dependency> | ||
</dependencies> | ||
``` | ||
|
||
Update the `pom.xml` project file to include this dependency and | ||
addtional settings with the following configuration code: | ||
|
||
??? info "Complete `pom.xml` configuration for project" | ||
The following code shows a complete `pom.xml` configuration for | ||
this project: | ||
|
||
```xml title="my_agent/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.3.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.3.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> | ||
``` | ||
|
||
### Set your API key | ||
|
||
This project uses the Gemini API, which requires an API key. If you | ||
don't already have Gemini API key, create a key in Google AI Studio on the | ||
[API Keys](https://aistudio.google.com/app/apikey) page. | ||
|
||
In a terminal window, write your API key into your `.env` file of your project | ||
to set environment variables: | ||
|
||
=== "Windows" | ||
|
||
```console title="Update: my_agent/.env" | ||
echo 'GOOGLE_API_KEY="YOUR_API_KEY"' > .env | ||
``` | ||
|
||
=== "MacOS / Linux" | ||
|
||
```bash title="Update: my_agent/.env" | ||
echo 'export GOOGLE_API_KEY="YOUR_API_KEY"' > .env | ||
joefernandez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
### Create an agent command-line interface | ||
|
||
For convenience, create a `AgentCliRunner.java` class to allow you to run | ||
and interact with `HelloTimeAgent` from the command line. This code shows | ||
how to create a `RunConfig` object to run the agent and a `Session` object | ||
to interact with the running agent. | ||
|
||
```java title="my_agent/src/main/java/com/example/agent/AgentCliRunner.java" | ||
package com.example.agent; | ||
|
||
import com.google.adk.agents.RunConfig; | ||
import com.google.adk.events.Event; | ||
import com.google.adk.runner.InMemoryRunner; | ||
import com.google.adk.sessions.Session; | ||
import com.google.genai.types.Content; | ||
import com.google.genai.types.Part; | ||
import io.reactivex.rxjava3.core.Flowable; | ||
import java.util.Scanner; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
||
public class AgentCliRunner { | ||
|
||
public static void main(String[] args) { | ||
RunConfig runConfig = RunConfig.builder().build(); | ||
InMemoryRunner runner = new InMemoryRunner(HelloTimeAgent.ROOT_AGENT); | ||
|
||
Session session = runner | ||
.sessionService() | ||
.createSession(runner.appName(), "user1234") | ||
.blockingGet(); | ||
|
||
try (Scanner scanner = new Scanner(System.in, UTF_8)) { | ||
while (true) { | ||
System.out.print("\nYou > "); | ||
String userInput = scanner.nextLine(); | ||
if ("quit".equalsIgnoreCase(userInput)) { | ||
break; | ||
} | ||
|
||
Content userMsg = Content.fromParts(Part.fromText(userInput)); | ||
Flowable<Event> events = runner.runAsync(session.userId(), session.id(), userMsg, runConfig); | ||
|
||
System.out.print("\nAgent > "); | ||
events.blockingForEach(event -> { | ||
if (event.finalResponse()) { | ||
System.out.println(event.stringifyContent()); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Run your agent | ||
|
||
You can run your ADK agent using the interactive command-line interface | ||
`AgentCliRunner` class you defined or the ADK web user interface provided by | ||
the ADK using the `AdkWebServer` class. Both these options allow you to test and | ||
interact with your agent. | ||
|
||
### Run with command-line interface | ||
|
||
Run your agent with the command-line interface `AgentCliRunner` class | ||
using the following Maven command: | ||
|
||
```console | ||
mvn compile exec:java -Dexec.mainClass="com.example.agent.AgentCliRunner" | ||
``` | ||
|
||
 | ||
|
||
### Run with web interface | ||
|
||
Run your agent with the ADK web interface using the following maven command: | ||
|
||
```console | ||
mvn compile exec:java -Dexec.mainClass="com.google.adk.web.AdkWebServer" \ | ||
-Dexec.args="--adk.agents.source-dir=src/main/java/com/example/agent --server.port=8080" | ||
joefernandez marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
``` | ||
|
||
This command starts a web server with a chat interface for your agent. You can | ||
access the web interface at (http://localhost:8080). Select your agent at the | ||
upper right corner and type a request. | ||
|
||
 | ||
|
||
## Next: Build your agent | ||
|
||
Now that you have ADK installed and your first agent running, try building | ||
your own agent with our build guides: | ||
|
||
* [Build your agent](/adk-docs/tutorials/) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.