-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path01_basic_agent.py
More file actions
74 lines (57 loc) · 1.96 KB
/
Copy path01_basic_agent.py
File metadata and controls
74 lines (57 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# /// script
# requires-python = ">=3.11"
# dependencies = ["band-sdk[google_adk]"]
#
# [tool.uv.sources]
# band-sdk = { git = "https://github.com/band-ai/band-sdk-python.git" }
# ///
"""
Basic Google ADK agent example.
This is the simplest way to create a Band agent using the Google Agent
Development Kit (ADK) with Gemini models. The adapter handles conversation
history, tool calling, and platform integration via ADK's built-in Runner.
Requires Band credentials plus one of:
- GOOGLE_API_KEY or GOOGLE_GENAI_API_KEY environment variable (Gemini Developer API)
- gcloud CLI with Application Default Credentials (Vertex AI):
gcloud auth application-default login
export GOOGLE_GENAI_USE_VERTEXAI=true
export GOOGLE_CLOUD_PROJECT=your-project-id
Run with:
uv run examples/google_adk/01_basic_agent.py
"""
from __future__ import annotations
import asyncio
import logging
import os
import sys
from dotenv import load_dotenv
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from setup_logging import setup_logging
from band import Agent
from band.adapters import GoogleADKAdapter
setup_logging()
logger = logging.getLogger(__name__)
async def main() -> None:
load_dotenv()
ws_url = os.getenv("BAND_WS_URL")
rest_url = os.getenv("BAND_REST_URL")
if not ws_url:
raise ValueError("BAND_WS_URL environment variable is required")
if not rest_url:
raise ValueError("BAND_REST_URL environment variable is required")
# Create adapter with Google ADK settings
adapter = GoogleADKAdapter(
model="gemini-2.5-flash",
custom_section="You are a helpful assistant. Be concise and friendly.",
)
# Create and start agent
agent = Agent.from_config(
"google_adk_agent",
adapter=adapter,
ws_url=ws_url,
rest_url=rest_url,
)
logger.info("Starting Google ADK agent...")
await agent.run()
if __name__ == "__main__":
asyncio.run(main())