Utilities to build text-to-SQL prompts from DDL and evaluate SQL executability for fietSQL
Project description
FietSQL Prompt & Eval Toolkit
Utilities for building high-quality prompts and validating SQL produced by the cwolff/fietSQL text-to-SQL model (also packaged for Ollama as cowolff/fietSQL). Supply your database schema plus a natural-language question, and this package will both format the chat prompt expected by the model and sanity-check the SQL it returns by running it inside an in-memory SQLite database.
Features
- Prompt builder: creates the
<|im_start|>style prompt template used to steer the fietSQL model. - Schema-aware evaluation: applies your DDL to SQLite and runs the generated SQL to verify executability.
- Lightweight footprint: pure-Python utilities that work in notebooks, batch jobs, or services.
Installation
pip install fietSQL
Or install straight from source:
pip install git+https://github.com/trl-lab/FietSQL-Package.git
Quick start
from fietSQL import build_prompt, evaluate_executability
SCHEMA = '''
CREATE TABLE customers (
id INTEGER PRIMARY KEY,
name TEXT,
city TEXT
);
CREATE TABLE orders (
id INTEGER PRIMARY KEY,
customer_id INTEGER,
total NUMERIC
);
'''
question = "Which city has the highest total sales?"
prompt = build_prompt(SCHEMA, question)
# send `prompt` to cwolff/fietSQL via Hugging Face or Ollama
sql = '''
SELECT c.city, SUM(o.total) AS total_sales
FROM customers c
JOIN orders o ON o.customer_id = c.id
GROUP BY c.city
ORDER BY total_sales DESC
LIMIT 1;
'''
report = evaluate_executability(SCHEMA, sql)
assert report.is_executable, report.details
Related resources
- Hugging Face model card: https://huggingface.co/cwolff/fietSQL
- Pulling the Ollama build:
ollama pull cowolff/fietSQL - Issues and discussions: https://github.com/trl-lab/FietSQL-Package/issues
License
Released under the MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fietsql-0.1.0.tar.gz.
File metadata
- Download URL: fietsql-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5af5651413a0bc375c69bac457b6184d43827404acd9a7f4c1cca5139aa251cc
|
|
| MD5 |
c1094e637824a0dfde3f9f56f01c0799
|
|
| BLAKE2b-256 |
27d9d9430b3a13063f419e0b04d68df3d7ae9a9b80538b986ab60f9e823a0cda
|
File details
Details for the file fietsql-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fietsql-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e975ffb9fe91d2f19ddd980835eda91468867ceb570865ea0ca2efe50210274
|
|
| MD5 |
d19bfb8fbb1f7a0de5dce0e0f0a03e37
|
|
| BLAKE2b-256 |
8d429d2aab129a7225ef38fd1d8a88ebb3a33428522cf4f5d5a91bb659b420ca
|