SqlBIAgent
SQL BI Agent is a Streamlit app that allows users to ask natural language questions about their BigQuery data and instantly receive SQL queries with visualizations. It uses LangGraph workflows, LLM-based query generation, and automatic validation to ensure accurate results.
Install / Use
/learn @claudiocmm/SqlBIAgentREADME
SQL BI Agent
Overview
SQL BI Agent is a powerful Streamlit application that allows users to ask natural language questions about their data in BigQuery and receive instant SQL queries with visualizations. It leverages LangGraph workflows, LLM-based query generation, and automatic validation to ensure accuracy.
For a detailed explanation, check out my Medium post: Medium Article
Features
- Natural Language to SQL: Converts user questions into SQL queries.
- Automated Query Validation: Uses BigQuery dry-run validation.
- Interactive Data Visualization: Generates and validates Python visualization code.
- Streamlit UI: User-friendly interface for asking questions and viewing results.
Create datasets bigquery
Once your GCP account is set up and the environment variables in settings.py are properly configured, you can upload the datasets to BigQuery by running the following command:
python upload_datasets_in_bq.py
This script will automatically load the datasets into BigQuery, ensuring they are ready for use.
Installation
To run the SQL BI Agent locally, follow these steps:
Steps
- Clone the repository:
git clone <repository-url> cd SqlBIAgent - Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` - Install dependencies:
pip install -r requirements.txt - Set up Google Cloud authentication (necessary Google Cloud SDK):
gcloud auth application-default login - Run the Streamlit app:
streamlit run streamlit.py
Usage
- Enter a question in natural language (e.g., "Show sales trends by month").
- Click the Run button.
- The application will:
- Retrieve relevant table schemas.
- Generate an SQL query using an LLM.
- Validate and execute the query in BigQuery.
- Generate a data visualization.
- View the SQL query and visualization output in the Streamlit UI.
Project Structure
├── upload_datasets_in_bq.py # Script to upload Datasets in BQ
├── prompts.py # Prompt templates for LLM
├── settings.py # Configuration settings
├── workflow.py # LangGraph workflow definitions
├── streamlit.py # Streamlit UI implementation
├── bq_functions.py # BigQuery helper functions
├── utils.py # Utility functions
├── requirements.txt # Python dependencies
├── README.md # Project documentation
Author
Cláudio César
Related Skills
oracle
339.3kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
prose
339.3kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
Command Development
83.9kThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
Plugin Structure
83.9kThis skill should be used when the user asks to "create a plugin", "scaffold a plugin", "understand plugin structure", "organize plugin components", "set up plugin.json", "use ${CLAUDE_PLUGIN_ROOT}", "add commands/agents/skills/hooks", "configure auto-discovery", or needs guidance on plugin directory layout, manifest configuration, component organization, file naming conventions, or Claude Code plugin architecture best practices.
