Spaces:
Paused
Paused
A newer version of the Gradio SDK is available:
6.4.0
metadata
title: InsightPilot - Autonomous Analytics Agent
emoji: ๐
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 4.16.0
app_file: app.py
pinned: false
license: mit
python_version: 3.1
InsightPilot โ Autonomous Analytics Agent
InsightPilot is a production-ready AI analyst that transforms natural language questions into validated SQL queries, interactive visualizations, comprehensive insights, and executive-ready PDF reports.
๐ Features
- ๐ค Agentic LangGraph Pipeline โ Deterministic tool-calling workflow (intent โ schema โ NL2SQL โ execution โ diagnostics โ visualization โ PDF)
- ๐ Advanced Analytics โ Automated trend detection and anomaly analysis with statistical insights
- ๐ PDF Report Generation โ Executive-ready reports with branded title pages, charts, and SQL appendix
- ๐ Multi-table Support โ Easy CSV upload and dataset catalog management
- โก Real-time Streaming โ Live insights streamed to the UI as they're generated
- ๐ Groq Llama-3 Powered โ Low-latency NLโSQL and narrative insight generation
๐ Quick Start on Hugging Face Spaces
Set Environment Variables (Required)
- Go to Settings โ Repository Secrets
- Add
GROQ_API_KEYwith your Groq API key (Get one here)
Upload Your Data (Optional)
- Use the "Upload Dataset" tab to add your CSV files
- Or work with the pre-loaded sample sales dataset
Ask Questions
- Use the Analytics Dashboard to ask natural language questions
- Example: "What were the total sales by category last quarter?"
- Get SQL, visualizations, insights, and downloadable PDF reports
๐๏ธ Architecture
| Component | Technology | Purpose |
|---|---|---|
| LLM Orchestration | LangGraph + Groq Llama-3 70B | Deterministic agent workflow with tool calling |
| API & Backend | FastAPI + SQLAlchemy | RESTful API, database management |
| Analytics | Pandas, NumPy, SciPy | Trend detection, anomaly analysis |
| Visualization | Matplotlib, ReportLab | Charts and PDF report generation |
| Database | SQLite | Lightweight, persistent data storage |
| Frontend | React + Vite (optional) | Modern interactive dashboard |
| Interface | Gradio | HF Spaces integration |
๐ Advanced Analytics Modules
- Trend Detection: Time series regression analysis with slope quantification and % change metrics
- Anomaly Detection: Z-score based statistical outlier identification
- Insight Generation: Context-aware narrative summaries powered by Groq LLM
๐ ๏ธ Tech Stack
Backend: FastAPI + LangGraph + LangChain + Groq
Data: SQLite + SQLAlchemy + Pandas
Viz: Matplotlib + ReportLab/Platypus
Frontend: React + Vite (embedded in Gradio)
Deploy: Hugging Face Spaces (Gradio SDK)
๐ Project Structure
.
โโโ app.py # Gradio wrapper for HF Spaces
โโโ requirements.txt # Python dependencies
โโโ backend/
โ โโโ app/
โ โ โโโ main.py # FastAPI application
โ โ โโโ agents/graph.py # LangGraph workflow
โ โ โโโ api/routes.py # API endpoints
โ โ โโโ core/config.py # Settings & environment
โ โ โโโ db/database.py # Database engine & seeding
โ โ โโโ services/ # Analytics, PDF, CSV modules
โ โโโ static/ # Generated charts & PDFs
โ โโโ requirements.txt # Backend-specific deps
โโโ frontend/ # React dashboard (optional)
โโโ data/ # Sample datasets
๐ Environment Variables
| Variable | Description | Required |
|---|---|---|
GROQ_API_KEY |
Groq API key for LLM access | โ Yes |
DATABASE_URL |
Database connection string | โช Optional (defaults to SQLite) |
๐ Usage Examples
Question: "What were the top 5 products by revenue last year?"
InsightPilot will:
- โ Analyze your database schema
- โ Generate optimized SQL query
- โ Execute query and validate results
- โ Create visualizations (bar charts, trends)
- โ Perform trend & anomaly analysis
- โ Generate narrative insights
- โ Build downloadable PDF report
๐ฏ Use Cases
- Business Analytics: Ad-hoc reporting without SQL knowledge
- Executive Briefings: Automated PDF reports with insights
- Data Exploration: Quick analysis of uploaded CSV datasets
- Trend Analysis: Automated time-series analytics
- Anomaly Detection: Statistical outlier identification
๐ง Limitations & Notes
- Free HF Spaces: CPU-only tier; suitable for moderate traffic
- Database: SQLite with persistent storage (50GB limit)
- File Cleanup: Old PDFs/charts should be periodically removed
- Concurrent Users: May need rate limiting for production use
๐ฎ Future Enhancements
- Multi-tenant workspaces with authentication
- Postgres/Supabase adapter for production databases
- Real-time collaborative dashboards
- Forecast & prediction modules
- Custom visualization templates
๐ License
MIT License - see LICENSE file for details
๐ค Contributing
Contributions welcome! Please open an issue or submit a PR.
๐ Links
- Repository: GitHub
- Documentation: See original README in repo
- Groq Platform: Get API Key
Built with โค๏ธ using LangGraph, FastAPI, and Groq