Skip to main content

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

License

Released under the MIT License. See LICENSE for details.

Release files for fietSQL 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fietSQL 0.1.0
File Size Uploaded
fietsql-0.1.0.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fietSQL 0.1.0
File Interpreter ABI Platform
fietsql-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.5 kB

Release files / fietsql-0.1.0.tar.gz

Download URL fietsql-0.1.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5af5651413a0bc375c69bac457b6184d43827404acd9a7f4c1cca5139aa251cc
BLAKE2b-256 checksum
How to use checksums
27d9d9430b3a13063f419e0b04d68df3d7ae9a9b80538b986ab60f9e823a0cda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.8

Release files / fietsql-0.1.0-py3-none-any.whl

Download URL fietsql-0.1.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e975ffb9fe91d2f19ddd980835eda91468867ceb570865ea0ca2efe50210274
BLAKE2b-256 checksum
How to use checksums
8d429d2aab129a7225ef38fd1d8a88ebb3a33428522cf4f5d5a91bb659b420ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.8

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page