Spaces:
Running on Zero
Running on Zero
File size: 1,400 Bytes
03a0e1f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | ---
title: Text to SQL Demo
emoji: 🗃️
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.10.0
app_file: app.py
pinned: false
license: mit
---
# Text-to-SQL Demo
Ask a plain-English question about a sample e-commerce database (customers,
products, orders, order_items) and get back real, generated SQL plus the
actual query results — retrieval, generation, AST validation, safe
execution, and self-healing retries, all live.
This demo runs a fine-tuned Qwen2.5-3B model for SQL generation, paired
with a full retrieval-and-validation pipeline: hybrid schema retrieval
(dense + BM25) narrows down the relevant tables, an AST-level validator
enforces read-only, schema-checked queries before anything executes, and a
self-healing loop retries automatically if a query fails, feeding the
database's own error back to the model. Nothing but a validated `SELECT`
ever reaches the database, regardless of what the model generates.
## Required Space secrets
Set these under Settings → Repository secrets before running:
| Secret | Example |
|---|---|
| `DB_HOST` | `db.yourproject.supabase.co` |
| `DB_PORT` | `5432` |
| `DB_NAME` | `postgres` |
| `DB_USER` | `postgres` |
| `DB_PASSWORD` | *(your database password)* |
Point these at a **read-only** role on a database you're comfortable
exposing publicly — this demo is configured for a small sample dataset, not
production data.
|