-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path01_basic_agent.py
More file actions
65 lines (49 loc) · 1.63 KB
/
Copy path01_basic_agent.py
File metadata and controls
65 lines (49 loc) · 1.63 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
# /// script
# requires-python = ">=3.11"
# dependencies = ["band-sdk[gemini]"]
#
# [tool.uv.sources]
# band-sdk = { git = "https://github.com/band-ai/band-sdk-python.git" }
# ///
"""
Basic Gemini agent example.
This is the simplest way to create a Band agent with the Gemini SDK.
The adapter handles tool registration and function-calling loops automatically.
Requires:
- agent_config.yaml with gemini_agent credentials
- Authentication via one of:
- GOOGLE_API_KEY or GEMINI_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/gemini/01_basic_agent.py
"""
from __future__ import annotations
import asyncio
import logging
import os
import sys
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 GeminiAdapter
setup_logging()
logger = logging.getLogger(__name__)
async def main() -> None:
# Create adapter with Gemini settings
# Requires GEMINI_API_KEY environment variable or pass provider_key explicitly
adapter = GeminiAdapter(
model="gemini-2.5-flash",
prompt="You are a helpful assistant. Be concise and friendly.",
)
# Create and start agent
agent = Agent.from_config(
"gemini_agent",
adapter=adapter,
)
logger.info("Starting Gemini agent...")
await agent.run()
if __name__ == "__main__":
asyncio.run(main())