An intelligent multi-agent system built with LangGraph and LangChain that enables natural language querying, statistical analysis, predictive modeling, and interactive visualization of manufacturing/operations data.
- Natural Language Querying — Ask questions in plain English, get SQL-powered answers
- Multi-Agent Architecture — Supervisor orchestrates 5 specialized agents via LangGraph
- Statistical Analysis — Regression, clustering, hypothesis testing on production data
- Predictive Modeling — Time series forecasting for equipment failures & production yield
- Interactive Visualizations — Auto-selected Plotly charts (bar, line, pie, scatter, heatmap)
- File Upload Support — Upload CSV/Excel or connect to PostgreSQL
- Conversational Memory — Follow-up questions with context retention
- SQL Validation & Error Recovery — Auto-corrects bad queries with retry logic
- LangSmith Observability — Full agent execution tracing and debugging
- CI/CD Pipeline — Automated testing with pytest + GitHub Actions
User (Streamlit UI)
│
▼
┌─────────────────────────────────┐
│ Supervisor Agent (LangGraph) │
│ Routes queries to agents │
├──────────┬──────────┬───────────┤
│ │ │ │
▼ ▼ ▼ ▼
Extractor Analyzer Statistician Predictor Visualizer
Agent Agent Agent Agent Agent
│ │ │ │ │
│ Ingest │ NL→SQL │ Regression │ LSTM/ │ Auto-select
│ CSV/DB │ Execute │ Clustering │ Prophet │ Plotly chart
│ API data │ Validate │ Hypothesis │ Forecast │ Interactive
└──────────┴──────────┴────────────┴───────────┴───────────
│
▼
PostgreSQL / SQLite
(Manufacturing Operations Data)
opsbrain/
├── agents/
│ ├── __init__.py
│ ├── supervisor.py # Supervisor agent - routes to sub-agents
│ ├── extractor.py # Data ingestion agent (CSV, API, DB)
│ ├── analyzer.py # NL-to-SQL query agent with validation
│ ├── statistician.py # Statistical analysis agent
│ ├── predictor.py # ML/forecasting agent
│ └── visualizer.py # Auto-visualization agent
├── tools/
│ ├── __init__.py
│ ├── db_tools.py # Database connection & query tools
│ ├── stats_tools.py # Statistical analysis tools
│ ├── ml_tools.py # ML prediction tools
│ └── viz_tools.py # Plotly visualization tools
├── config/
│ ├── __init__.py
│ └── settings.py # Environment & LLM config
├── data/
│ └── sample_manufacturing.csv # Sample dataset
├── tests/
│ ├── __init__.py
│ ├── test_analyzer.py
│ ├── test_statistician.py
│ ├── test_predictor.py
│ └── test_visualizer.py
├── ui/
│ └── app.py # Streamlit frontend
├── .github/
│ └── workflows/
│ └── ci.yml # GitHub Actions CI pipeline
├── graph.py # LangGraph workflow definition
├── state.py # Shared agent state schema
├── requirements.txt
├── .env.example
└── README.md
git clone https://github.com/ArpitSutariya/opsbrain.git
cd opsbrain
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtcp .env.example .env
# Edit .env with your API keyspython -c "from tools.db_tools import init_db; init_db()"streamlit run ui/app.py| Query | Agent Used |
|---|---|
| "What is the average defect rate by station?" | Analyzer → Visualizer |
| "Show me equipment downtime trends over the last 6 months" | Analyzer → Visualizer |
| "Run a regression analysis on temperature vs defect rate" | Statistician → Visualizer |
| "Cluster machines by their failure patterns" | Statistician → Visualizer |
| "Predict equipment failures for the next 30 days" | Predictor → Visualizer |
| "Upload my production CSV and summarize it" | Extractor → Analyzer |
| Component | Technology |
|---|---|
| Agent Framework | LangGraph, LangChain |
| LLM | OpenAI GPT-4o / Claude |
| Database | PostgreSQL / SQLite |
| ML & Stats | scikit-learn, statsmodels, Prophet |
| Visualization | Plotly |
| Frontend | Streamlit |
| Observability | LangSmith |
| Testing | pytest |
| CI/CD | GitHub Actions |
The included sample_manufacturing.csv simulates a factory floor with columns:
timestamp,machine_id,station,shifttemperature,pressure,vibration,rpmdefect_flag,downtime_minutes,units_produced,defect_rate
MIT License