All projects

AI-assisted petroleum review

Controlled text-to-SQL

Make the query visible, check it against approved views, then summarize the rows it actually returns.

Offline query demonstration

A question with a checkable path to the data

The demonstration builds an in-memory SQLite database from compact public Y1-style context files. A question maps to a candidate query using schema context. The SQL validator checks the candidate before execution, and the answer is derived from the returned rows.

The supplied notebook and core module use deterministic generation so reviewers can inspect the workflow without API credentials or paid model calls. They demonstrate the validation boundary for an LLM-assisted workflow; connecting a live model provider remains future work.

Public demo screen showing a reservoir-count question, validated SELECT query and returned rows
Representative workflow image from the public repository. The example shows the offline deterministic fallback. Open full-size image.

Checks before execution

The example validator restricts reads to AI-visible views, rejects write/admin statements and multiple statements, checks hidden-table access, and applies a default row limit. A result-only summary keeps the answer tied to the actual query output.

Schema context is built from the database views so query generation uses the available tables and columns. A standalone diagnostic checks the schema, query patterns and validator.

The included sample data and deterministic query generator let readers explore the workflow offline. The example is intended for experimentation and technical review.

Inspect the example

Start with the notebook and read the database, SQL guard and text-to-SQL modules together. The repository includes the public context files and a diagnostic that can be rerun after schema or query changes.