Back to demos

Case study

PROJECT / CASE STUDY

ChatBI

Natural language → SQL → results, with every step auditable

A real retrieval → generate → validate → execute → verify pipeline for text-to-SQL, not a thin 'LLM writes SQL' wrapper — schema-linking retrieval, dynamic few-shot, and an AST-based SQL safety gate.

What this demo does

ChatBI first uses schema linking (table-name/column/synonym scoring plus join expansion) to pick the actually-relevant tables out of 8, pulls the most similar few-shot SQL examples, and has DeepSeek generate SQL from only that narrowed schema; the generated SQL passes an AST-level safety gate via sqlglot (read-only SELECT, table whitelist, no DDL/DML, single statement, row cap) before it ever runs against the in-memory SQLite database, and the result is checked for emptiness/truncation/all-NULL columns before being interpreted. The retrieval and safety logic (ragbi.py) is fully Streamlit-free and unit-testable. Database-agnostic — swap the connection string to point at BigQuery, Snowflake, or Redshift.

Use cases

Self-serve sales and ops queries

Ask for key metrics in plain language without waiting for BI bandwidth.

Cross-team data access

Let non-technical teams explore data while reducing repeated data requests.

Text-to-SQL in a controlled environment

The AST safety gate and table whitelist make generated SQL safe to point at a real database, not just a demo toy.