createse Augmentic Development Kit agent000
This Bash script automates the initial setup for a basic Google Agent Development Kit (ADK) agent project. It's designed to get you up and running quickly by:
- Creating a dedicated Python virtual environment.
- Installing the
google-adk
library and necessary dependencies (tzdata
). - Generating a standard directory structure for your ADK agent.
- Populating the structure with essential template files, including:
* `__init__.py`: To make the agent directory a Python package.
* `agent.py`: A sample multi-tool agent (Weather & Time for New York City) using `LlmAgent` and `FunctionTool`.
* `.env`: A template for configuring your Google API Key (for AI Studio) or Vertex AI settings.
The example agent is configured to provide weather and time information, but only for New York City, showcasing how to define tools and instruct the LLM.
- Automated Environment Setup: Creates a Python virtual environment to isolate project dependencies.
- ADK Installation: Installs
google-adk
andtzdata
(for timezone support in the example agent). - Project Scaffolding: Generates a clean directory structure:
. ├── augmentic_adk_env/ # Python virtual environment ├── adk_agent_project/ # Parent project directory │ └── multi_tool_agent/ # Agent-specific code │ ├── __init__.py │ ├── agent.py │ └── .env └── setup_adk_agent.sh # This script
- Sample Agent Code: Provides a working
agent.py
with:- An
LlmAgent
(configured forgemini-1.5-flash-latest
). - Two
FunctionTool
examples:get_weather
andget_current_time
. - Basic logging within the agent and tools.
- Clear instructions to the LLM about its capabilities and limitations (NYC only).
- An
- Configuration Template: Creates an
.env
template file with instructions for setting up API access via Google AI Studio API Key or Vertex AI. - User-Friendly Prompts: Guides the user through the setup process.
Before running this script, ensure you have the following installed on your system:
- Bash Shell: (Standard on Linux and macOS, available on Windows via WSL or Git Bash).
- Python 3: Version 3.8 or higher is recommended. The script uses
python3
command by default.- The
venv
module must be available (usually included with Python 3).
- The
- pip: The Python package installer (usually comes with Python).
- Internet Connection: Required to download packages from PyPI.
The script operates in two main phases:
-
Phase 1: Environment & Dependencies Setup
- Virtual Environment Creation: Uses
python3 -m venv augmentic_adk_env
to create an isolated Python environment. - Activation (Subshell): Activates the venv within the script's subshell to install packages into it.
- Package Installation: Installs
google-adk
andtzdata
usingpip install --quiet
.tzdata
is needed byzoneinfo
for timezone lookups in the sample agent. - ADK Verification: Runs
pip show google-adk
to confirm the installation (optional check).
- Virtual Environment Creation: Uses
-
Phase 2: Agent Project Files Creation
- Directory Structure: Creates
./adk_agent_project/multi_tool_agent/
usingmkdir -p
. __init__.py
: Creates an empty__init__.py
file in themulti_tool_agent
directory, making it a discoverable Python package for the ADK.agent.py
: Populatesmulti_tool_agent/agent.py
with a complete example:- Imports necessary ADK components (
LlmAgent
,FunctionTool
) and standard libraries (datetime
,logging
,zoneinfo
). - Sets up basic logging.
- Defines two tool functions:
get_weather(city: str)
: Simulates fetching weather for a city (hardcoded for "New York").get_current_time(city: str)
: Simulates fetching the current time for a city usingzoneinfo
(hardcoded for "New York").
- Wraps these functions in
FunctionTool
. - Defines a
root_agent
usingLlmAgent
, configured with:- A name (
weather_time_agent
). - A model (
gemini-1.5-flash-latest
). - A description and specific instructions guiding the LLM's behavior, emphasizing its NYC-only capabilities.
- The list of defined tools.
- A name (
- Imports necessary ADK components (
.env
Template: Createsmulti_tool_agent/.env
with commented-out sections for:- Option 1: Google AI Studio API Key (
GOOGLE_API_KEY
). - Option 2: Vertex AI configuration (
GOOGLE_CLOUD_PROJECT
,GOOGLE_CLOUD_LOCATION
). This file is crucial for authenticating with Google's generative AI services.
- Option 1: Google AI Studio API Key (
- Directory Structure: Creates
augmentic_adk_env/
: The Python virtual environment directory.adk_agent_project/multi_tool_agent/__init__.py
: Marks themulti_tool_agent
directory as a Python package, allowing ADK to discover the agent defined within.adk_agent_project/multi_tool_agent/agent.py
: Contains the core logic of your ADK agent. The provided template demonstrates how to define tools, configure an LLM agent, and set its behavior.adk_agent_project/multi_tool_agent/.env
: Stores sensitive configuration like API keys and project IDs. This file should be added to.gitignore
if you are using version control.
-
Download the Script: Save the script content to a file, for example,
setup_adk_agent.sh
. -
Make it Executable: Open your terminal and navigate to the directory where you saved the script.
chmod +x setup_adk_agent.sh
-
Run the Script:
./setup_adk_agent.sh
The script will display what it intends to do and ask for confirmation before proceeding.
-
❗ CRITICAL: Configure
.env
File ❗ After the script finishes, you MUST configure the API access:- Navigate to the agent directory:
cd adk_agent_project/multi_tool_agent
- Open the
.env
file in a text editor (e.g.,nano .env
,vim .env
, or using VS Code). - Choose ONE option:
- Option 1 (AI Studio API Key):
- Get an API key from Google AI Studio.
- Uncomment the lines for
GOOGLE_GENAI_USE_VERTEXAI="False"
andGOOGLE_API_KEY
. - Replace
PASTE_YOUR_ACTUAL_API_KEY_HERE
with your actual key.
- Option 2 (Vertex AI):
- Ensure you have a Google Cloud Project with the Vertex AI API enabled.
- Authenticate your local environment:
gcloud auth application-default login
. - Uncomment the lines for
GOOGLE_GENAI_USE_VERTEXAI="True"
,GOOGLE_CLOUD_PROJECT
, andGOOGLE_CLOUD_LOCATION
. - Replace
YOUR_PROJECT_ID
andYOUR_LOCATION
(e.g.,us-central1
) with your details.
- Option 1 (AI Studio API Key):
- Ensure the other option remains commented out.
- Save and close the
.env
file.
- Navigate to the agent directory:
-
Activate Virtual Environment & Run ADK Web UI:
- Open a new terminal window/tab or use your current one.
- Activate the virtual environment:
(Your terminal prompt should now be prefixed with
source augmentic_adk_env/bin/activate
(augmentic_adk_env)
) - Navigate to the parent project directory (the one containing
multi_tool_agent
):(If you are already incd adk_agent_project
adk_agent_project/multi_tool_agent
, go up one level:cd ..
) - Launch the ADK Development Web UI:
adk web
-
Use the Agent in the Web UI:
- The
adk web
command will output a URL, usuallyhttp://localhost:8000
. - Open this URL in your web browser.
- In the top-left dropdown menu, you should see and be able to select the agent:
multi_tool_agent
. - Try interacting with the agent in the chat input box:
- "What time is it in New York?"
- "How's the weather in New York?"
- "What is the weather like in London?" (This will test the agent's stated limitation)
- The
This script provides a convenient way to bootstrap a Google ADK project with a functional, albeit simple, example agent. It handles the creation of the virtual environment, installation of ADK, and generation of boilerplate code, allowing you to focus on developing your agent's logic and tools.
The generated agent demonstrates:
- Using
LlmAgent
with a specified Gemini model. - Defining tools using
FunctionTool
. - Instructing the agent on how and when to use its tools, and its limitations.
- Basic logging for debugging.
- Modify
agent.py
:- Change the
model
inLlmAgent
to other compatible Gemini models (e.g.,gemini-pro
). - Update the
description
andinstruction
for the agent. - Add new tools by defining Python functions and wrapping them with
FunctionTool
. - Implement actual API calls in your tool functions (e.g., use a real weather API instead of the simulation).
- Remove the "New York only" limitation by making your tools more robust.
- Change the
- Explore ADK Features: Dive deeper into the Google ADK documentation to learn about more advanced features like agent composition, state management, and different tool types.
- Version Control: Initialize a Git repository in your
adk_agent_project
directory and remember to addaugmentic_adk_env/
andadk_agent_project/multi_tool_agent/.env
to your.gitignore
file.
ModuleNotFoundError
orcommand not found: adk
: Ensure your virtual environment (augmentic_adk_env
) is activated:source augmentic_adk_env/bin/activate
.- Agent
multi_tool_agent
not found inadk web
UI dropdown: Make sure you are runningadk web
from theadk_agent_project
directory (the parent directory ofmulti_tool_agent
), not from insidemulti_tool_agent
itself. - API Errors / Authentication Issues (e.g., 401, 403, permission denied):
- Double-check your
adk_agent_project/multi_tool_agent/.env
file. - Ensure only ONE option (AI Studio Key or Vertex AI) is uncommented and correctly filled.
- Verify your API key is valid and has the necessary permissions.
- If using Vertex AI, confirm your
gcloud auth application-default login
was successful and your project/location are correct. - Ensure the Vertex AI API is enabled in your GCP project.
- Double-check your
- "Failed to create virtual environment":
- Ensure
python3
is correctly installed and in your PATH. - Ensure the
venv
module is available for your Python 3 installation. You might need to install it separately depending on your OS/Python distribution (e.g.,sudo apt install python3-venv
on Debian/Ubuntu).
- Ensure
tzdata
orzoneinfo
issues: The script installstzdata
. If you still encounter issues withZoneInfo
, ensure your system has timezone data accessible. This is usually not a problem on modern systems.
Happy Agent Building!