Spaces:
Paused
Paused
| 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.10 | |
| # InsightPilot โ Autonomous Analytics Agent | |
| <div align="center"> | |
| [](https://github.com/langchain-ai/langgraph) | |
| [](https://fastapi.tiangolo.com/) | |
| [](https://groq.com/) | |
| </div> | |
| 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 | |
| 1. **Set Environment Variables** (Required) | |
| - Go to Settings โ Repository Secrets | |
| - Add `GROQ_API_KEY` with your Groq API key ([Get one here](https://console.groq.com/)) | |
| 2. **Upload Your Data** (Optional) | |
| - Use the "Upload Dataset" tab to add your CSV files | |
| - Or work with the pre-loaded sample sales dataset | |
| 3. **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:** | |
| 1. โ Analyze your database schema | |
| 2. โ Generate optimized SQL query | |
| 3. โ Execute query and validate results | |
| 4. โ Create visualizations (bar charts, trends) | |
| 5. โ Perform trend & anomaly analysis | |
| 6. โ Generate narrative insights | |
| 7. โ 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](https://github.com/zenitsu0509/InsightPilot) | |
| - **Documentation**: See original README in repo | |
| - **Groq Platform**: [Get API Key](https://console.groq.com/) | |
| --- | |
| **Built with โค๏ธ using LangGraph, FastAPI, and Groq** | |