deepakvish001/sql-repair-env-new
0
SQL Query Repair Lab ๐ง
An OpenEnv-compliant reinforcement learning environment where AI agents learn to identify and fix broken SQL queries โ with a full interactive dashboard for human users too.
๐ Features (8 Advanced)
1. ๐จ Interactive SQL Editor
- macOS-style code editor with syntax-aware textarea
- Load original broken query, clear, character/line count
- Keyboard shortcut:
Ctrl+Enterto submit
2. ๐ Task Dashboard & Sidebar
- 3 tasks (Easy/Medium/Hard) with color-coded difficulty badges
- Real-time progress bars showing best scores per task
- One-click task switching with visual active state
3. ๐ Real-time Query Grading
- Submit fixes and get instant scoring with partial credit
- Success / Partial / Fail states with animated result panels
- Progressive hints revealed after failed attempts
4. ๐ Score Breakdown Visualization
- Per-criterion partial scores (syntax, columns, row count, ordering, etc.)
- Color-coded +/- indicators for each grading criterion
- Clear feedback on exactly what's right and what needs fixing
5. ๐ Step History Timeline
- Visual timeline with green/yellow/red dot indicators
- Score, feedback message, and submitted query for each step
- SVG score progression chart across attempts
6. ๐๏ธ Database Schema Explorer
- Interactive table view with columns, types, constraints, notes
- Sample data preview for each table
- Parsed directly from DDL schema definitions
7. ๐ Diff Viewer
- Side-by-side comparison: broken query vs. your fix
- Unified diff view with color-coded additions/removals
- Toggleable live diff in workspace
8. โถ๏ธ Query Runner & Analytics
- Execute any SELECT query against the database (no scoring)
- Validate SQL syntax without submitting
- Performance analytics: average score, tasks completed, best score
- Session timeline tracking all attempts
HTTP API
Setup & Usage
Local (Python)
pip install -r requirements.txt
# Start the server
uvicorn main:app --host 0.0.0.0 --port 7860
# Open browser to http://localhost:7860Docker
docker build -t sql-repair-lab .
docker run -p 7860:7860 sql-repair-lab
# Open browser to http://localhost:7860Run Baseline Agent
export HF_TOKEN=your_hf_token
export MODEL_NAME=meta-llama/Llama-3.3-70B-Instruct
export API_BASE_URL=https://router.huggingface.co/v1
python inference.pyProject Structure
sql-repair-lab/
โโโ Dockerfile
โโโ README.md
โโโ openenv.yaml
โโโ requirements.txt
โโโ pyproject.toml
โโโ app.py โ HF Spaces entry point
โโโ main.py โ FastAPI server (enhanced with 6 new endpoints)
โโโ inference.py โ Baseline RL agent
โโโ static/
โ โโโ index.html โ Full frontend dashboard (single-file, no build step)
โโโ server/
โ โโโ __init__.py
โ โโโ app.py
โโโ env/
โโโ __init__.py
โโโ models.py โ Pydantic models
โโโ database.py โ SQLite setup + seed data
โโโ tasks.py โ Task definitions + graders
โโโ environment.py โ Core environment (reset/step/state)Tasks
License
MIT
