Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Factory Planning AI

Agentic text-to-SQL backend for a telecommunications manufacturing plant that builds base station transceivers. The stack uses a controlled LangGraph workflow to enforce:

  1. Data dictionary search
  2. Schema probing
  3. Data sampling
  4. SQL generation, checking, execution, and synthesis

The repo ships with a normalized demo factory schema and seed data so you can run the system end to end without external SQL files.

Architecture

  • sql/001_factory_schema.sql: normalized telecom factory schema
  • sql/002_factory_seed.sql: demo production, quality, and sensor data
  • src/factory_planning_ai/agent.py: controlled LangGraph SQL workflow
  • src/factory_planning_ai/tools.py: data dictionary, schema probe, sample, and SQL execution tools
  • src/factory_planning_ai/service.py: application service for UI and CLI
  • app.py: Streamlit interface

Runtime

Use Python 3.11 or newer. Current LangChain and LangGraph releases require Python 3.10+ and this project targets 3.11.

Setup

python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements-base.txt -r requirements-openai.txt
Copy-Item .env.example .env
python scripts\bootstrap_demo_db.py --reset
streamlit run app.py

One Command Start

.\run.ps1

Useful variants:

.\run.ps1 -Mode local-cli -Question "Which production line is most at risk of missing plan based on the last 3 shifts?"
.\run.ps1 -ResetDb
.\run.ps1 -Mode docker-ui

If you want Gemini or Anthropic instead of OpenAI, install the matching provider requirement file and change FACTORY_LLM_MODEL in .env.

CLI

python scripts\ask.py "Which base station model had the highest defect rate over the last 3 shifts?"

Docker

Copy-Item .env.example .env
docker compose up --build

Demo Questions

  • Which production line is most at risk of missing planned units based on the last 3 shifts?
  • Which base station model has the highest defect rate and what defect is driving it?
  • Show average RF output power by model and line.
  • Compare completed units versus planned units by shift date.
  • Which sensor metrics are most associated with failed inspections?

Notes

  • The execution tool is read-only and rejects DDL/DML.
  • The demo database is SQLite for portability, but the backend code accepts any SQLAlchemy URI.
  • In production, connect the service to a least-privilege PostgreSQL or MySQL read-only user.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages