Skip to main content
Loading navigation
Back to prompt library

Agent Initialization and Tool Definition

Linked challenge: Gemini-powered Voice Navigator Agent

Prompt source

implementation16 lines6 sectionsNo variables1 code block
Using Google ADK, define the initial agent structure. This should include an agent that can access current location, retrieve map data, and speak. Provide the Python code for initializing the `adk.Agent` and registering a simple `get_current_location` tool and a `speak` tool. Assume you have already set up your Google Cloud project and authenticated.

```python
import adk
from adk import agent_builder
from google.cloud import texttospeech_v1 as tts

def get_current_location():
    # Placeholder for actual location retrieval
    return {"latitude": 34.0195, "longitude": -118.4912}

def speak(text: str):
    # Placeholder for TTS output
    print(f"Agent says: {text}")

builder = agent_builder.AgentBuilder()
builder.add_tool(get_current_location)
builder.add_tool(speak)

# ... continue to build the rest of the agent
```