Skip to content

arpit-sutariya/opsbrainLLM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏭 OpsBrain — Multi-Agent AI System for Manufacturing Analytics

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.

🎯 Features

  • 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

🏗️ Architecture

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)

📁 Project Structure

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

🚀 Quick Start

1. Clone & Install

git clone https://github.com/ArpitSutariya/opsbrain.git
cd opsbrain
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

2. Configure Environment

cp .env.example .env
# Edit .env with your API keys

3. Load Sample Data

python -c "from tools.db_tools import init_db; init_db()"

4. Run the App

streamlit run ui/app.py

💬 Example Queries

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

🛠️ Tech Stack

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

📊 Sample Dataset

The included sample_manufacturing.csv simulates a factory floor with columns:

  • timestamp, machine_id, station, shift
  • temperature, pressure, vibration, rpm
  • defect_flag, downtime_minutes, units_produced, defect_rate

📝 License

MIT License

About

Multi-agent AI system for manufacturing analytics : 5 specialized LangGraph agents for NL-to-SQL querying, statistical analysis, predictive modeling & auto-visualization with Streamlit

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages