nl2sql-copilot / README.md
Melika Kheirieh
docs: update README with project overview
8e92467
|
raw
history blame
2.4 kB

🧩 NL2SQL Copilot

A modular Text-to-SQL Copilot that converts natural language questions into safe and verified SQL queries.
Built with FastAPI, LangGraph, and SQLAlchemy, designed for read-only databases and evaluation on Spider/Dr.Spider benchmarks.


πŸš€ Quick Start

1️⃣ Clone the repo

git clone https://github.com/melika-kheirieh/nl2sql-copilot.git
cd nl2sql-copilot

2️⃣ Build and run with Docker

docker build -t nl2sql-copilot .
docker run --rm -p 8000:8000 nl2sql-copilot

Then open http://localhost:8000/docs πŸš€


🧱 Project Structure

nl2sql-copilot/
β”‚
β”œβ”€β”€ app/                 # FastAPI app, routers, schemas
β”œβ”€β”€ nl2sql/              # Core pipeline (planner β†’ generator β†’ safety β†’ executor β†’ verifier)
β”œβ”€β”€ adapters/            # Database and LLM adapters
β”œβ”€β”€ benchmarks/          # Evaluation scripts and results
β”œβ”€β”€ ui/                  # Streamlit dashboard
β”‚
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ requirements.in
β”œβ”€β”€ requirements.txt
└── README.md

πŸ§ͺ Development

Install dependencies

(Recommended: Python 3.12+ and virtualenv)

pip install -r requirements.txt

Run tests

pytest -q

Lint and type-check

ruff check .
mypy .

🧠 Features

  • βœ… Modular multi-stage pipeline (Planner β†’ Generator β†’ Safety β†’ Executor β†’ Verifier β†’ Repair)
  • πŸ›‘οΈ SQL safety filters (SELECT-only, forbidden keywords)
  • πŸ” Self-repair loop on failed executions
  • πŸ“Š Streamlit benchmark dashboard (latency, accuracy, cost)
  • 🧩 PostgreSQL + SQLite adapters
  • 🧠 Powered by pydantic-ai and LangGraph

🧰 Tech Stack

Layer Tools
Backend API FastAPI, Uvicorn
Pipeline Core Python 3.12, Pydantic, SQLGlot
LLM Interface pydantic-ai (OpenAI, Anthropic, Ollama)
Database SQLite (default), PostgreSQL
Evaluation Spider / Dr.Spider
UI Streamlit + Plotly
Containerization Docker / Docker Compose

πŸ“„ License

MIT Β© 2025 Melika Kheirieh