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