Learning Timeline
Key Insights
Core Concepts of the Agent Development Kit (ADK)
To build an agent with ADK, you need to understand several key components:
- **Agent**: Your application's core logic. ADK provides various agent types, the most fundamental being the 'LLM Agent'.
- **Tools**: These give your agent 'skills,' such as accessing external APIs or custom functions.
- **Runner**: The component that ties everything (agent, tools) together and manages interaction sessions.
- **Session**: Stores conversation history, allowing the agent to 'remember' previous interactions.
Claude Integration Options with ADK
There are two main ways to use Claude models with ADK:
1. **Via LiteLLM**: The standard method if you are already familiar with the LiteLLM ecosystem.
2. **Via LLM Registry Vertex**: A pre-built integration provided by the Vertex AI team. It offers a cleaner way to connect models to your agent, as shown in this tutorial.
Step by Step
Setting Up the File Structure for Your Agent
- In your project directory, create a Python file named `agent.py`. This file will contain your agent's core logic.
- Create a file for environment variables (e.g., `.env`). This file will store your configurations and API keys.
- Create an empty file named `__init__.py`. This turns your directory into a Python package that ADK can recognize.
Defining a Basic Agent in agent.py
- Open your `agent.py` file.
- Import the `LLMAgent` class and the model class you want to use (e.g., `Claude`) from the ADK library.
- Create an instance of the `LLMAgent` class to start defining your agent.
- Inside the `LLMAgent` parentheses, set the following parameters:
- - `name`: Give your agent a unique name (e.g., 'birthday-planner').
- - `model`: Specify the LLM model to be used (e.g., `Claude(model: 'claude-3-sonnet@20240229')`).
- - `description`: Write a short description of your agent's function.
- - `instructions`: Provide detailed instructions or a system prompt on how the agent should behave.
Running and Interacting with Your Agent
- Open your terminal or command prompt.
- Navigate to the root directory of your agent project.
- Execute the command `adk run <agent_name>`, for example: `adk run birthday-planner`.
- The system will start an interactive session in the terminal.
- You can now start 'chatting' or giving instructions directly to your agent to test its functionality.