Repo with example code for building various types of agents using ADK
-
install required Python packages/modules for the example you want to run:
pip install -r requirements.txt
-
.env
file in your agent's folder (Google AI Studio)
GOOGLE_GENAI_USE_VERTEXAI=FALSE
GOOGLE_API_KEY=a1b2c3yourapikeyherex7y8z9
.env
file in your agent's folder (Vertex AI)
GOOGLE_GENAI_USE_VERTEXAI=TRUE
GOOGLE_CLOUD_PROJECT=myproject-123
GOOGLE_CLOUD_LOCATION=us-central1
NOTE: while you can use any location you wish, not all locations supports every Gemini model
-
A very basic agent that leverages Google Search as the tool to help the user find answers. If you're new to programming and/or ADK, I suggest you start here :)
-
Simple Weather and Time agent that uses function tools to find latitude & longitude of a given city, country and its weather and time (timezone-adjusted). Uses sub-agents to handle specific tasks, each with its own persona. You can find a short write-up of it on my Medium. I wrote a follow-up article about Agent Evaluation and added the evalset and instructions to for this particular agent example. I then added a callback function to make the agent a little more robust.
-
Model Context Protocol (MCP) example that uses FastMCP and ngrok to host the MCP server which the math agent connects to get tools to help it perform basic math (add/subtract/multiply/divide). Read about this on my Medium.
-
Another MCP example. This time it is a travel recommendation agent that uses a local Google Maps Platform MCP server (via Stdio) to find attractions and restaurants near a give origin location. In its current form, the directions and travel distance returned can be quite wrong and hence I wouldn't really rely on it for directions. I built my own Google Maps MCP server (in Python) that I'll be using going forward in future examples.
-
Simple Weather agent that uses function tools and callback functions. The example here also uses sessions and state store user preferences which get initialized during session creation. The callback function will look for the presence of a particular key in the state and modify the system instructions accordingly (in this case, whether to provide the response in imperial or metric units).