A Python CLI agent powered by Google Gemini & Google ADK that queries BigQuery data using natural language.
- 🗣️ Natural Language Queries - Ask questions in plain English, get SQL results
- 🤖 Powered by Gemini 3 Pro - Uses Google's latest LLM for intelligent query generation
- 🔧 Google ADK Integration - Built with Google's Agent Development Kit
- 🎨 Colored CLI Output - Easy-to-read responses with syntax highlighting
- ⏳ Progress Indicator - Spinner shows when queries are processing
- 📊 Usage Stats - See duration and token usage for each query
flowchart LR
User[User CLI] <--> Runner[ADK Runner]
Runner <--> Agent[LlmAgent]
Agent <--> Gemini[Google Gemini]
Agent <--> BQToolset[BigQueryToolset]
BQToolset <--> BQ[(BigQuery)]
subgraph tools [Available Tools]
list_datasets[list_dataset_ids]
get_dataset[get_dataset_info]
list_tables[list_table_ids]
get_table[get_table_info]
execute_sql[execute_sql]
end
BQToolset --> tools
- User CLI → Sends question to ADK Runner
- ADK Runner → Wraps message and sends to LlmAgent
- LlmAgent → Sends question + tool definitions to Gemini
- Google Gemini → Analyzes question, returns tool call (e.g., SQL query)
- LlmAgent → Passes tool call to BigQueryToolset
- BigQueryToolset → Executes query against BigQuery
- BigQuery → Returns query results
- Gemini → Formats results into human-readable response
- CLI → Displays the answer with stats
- Python 3.10+
- Google Cloud account with BigQuery access
- Gemini API key
-
Clone the repository
git clone https://github.com/yourusername/GoogleBigQueryAgent.git cd GoogleBigQueryAgent -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Authenticate with Google Cloud
gcloud auth application-default login
-
Configure environment variables
cp .env.example .env # Edit .env with your settings
Create a .env file with:
# Required
GOOGLE_API_KEY=your-gemini-api-key
# Optional - override defaults
GOOGLE_CLOUD_PROJECT=your-project-id
BIGQUERY_DEFAULT_DATASET=your-dataset-namepython main.pyOr if installed as a package:
bigquery-agent============================================================
BigQuery SQL Agent
============================================================
Google Cloud Project ID: **********568
Default BigQuery Dataset: 3cx_call_data
------------------------------------------------------------
Ask questions about your BigQuery data.
Type 'quit' or 'exit' to stop.
You: What datasets are available?
Agent: I found the following datasets in your project:
- 3cx_call_data
- analytics
- logs
────────────────────────────────────────
Duration: 2.34s | Tokens: 150 in / 89 out
────────────────────────────────────────
- "What Datasets are available?"
- "Show me the schema of the cdroutput table"
- "Show me all calls that happened yesterday"
- "Print all the information about this call"
- "Is there a recording associated with this call?"
- "I had a complaint in the last 30 days. All I know is that the customer name is John and recipient was Sarah"
- "Can you show me all calls in the last 30 days that were abusive or spam related?"
- "How many calls did Sarah answer in the last 30 days? Which ones were with a duration of more than 1 minute?"
- "Based on these calls, how can I help my colleague to do her job better?"
GoogleBigQueryAgent/
├── bigquery_agent/
│ ├── __init__.py # Package exports
│ ├── agent.py # LlmAgent configuration
│ └── cli.py # CLI interface with colors/spinner
├── .env.example # Environment template
├── .gitignore # Git ignore rules
├── LICENSE # MIT License
├── main.py # Entry point
├── pyproject.toml # Package configuration
├── README.md # This file
└── requirements.txt # Dependencies
python main.pypip install -e .MIT License - see LICENSE for details.
- Google ADK - Agent Development Kit
- Google Gemini - Large Language Model
- Google BigQuery - Data Warehouse