Interactive SQLite shell with LLM support
Project description
tsellm: Use LLMs in your SQLite queries
tsellm is the easiest way to access LLMs through your SQLite database.
pip install tsellm
You can then use LLMs in your SQL queries. You can supply your queries through a simple CLI.
tsellm my.sqlite3 "select prompt(p, 'orca-2-7b') from my_table"
You can also enter an interactive REPL shell and try things out.
tsellm my.sqlite3
Examples
Let's create a simple SQLite database with some data.
sqlite3 prompts.db <<EOF
CREATE TABLE [prompts] (
[prompt] TEXT
);
INSERT INTO prompts VALUES('hello world!');
INSERT INTO prompts VALUES('how are you?');
INSERT INTO prompts VALUES('is this real life?');
INSERT INTO prompts VALUES('1+1=?');
EOF
CLI
You can use any of the llm plugins
You can execute LLM-powered SQL queries directly in the CLI, like so:
First, let's install a dummy plugin.
llm install llm-markov
tsellm prompts.db "select prompt(prompt, 'markov') from prompts"
Now let's try a more complex one,
llm install llm-gpt4all
tsellm prompts.db "select prompt(prompt, 'orca-2-7b') from prompts"
Interactive Shell
You can enter an interactive REPL-style shell to manipulate your database.
tsellm prompts.db
There you can do queries the normal way:
ALTER TABLE prompts ADD COLUMN orca;
UPDATE PROMPTS SET orca=prompt(prompt, 'orca-2-7b');
Installation
pip install tsellm
How
tsellm relies on the following facts:
- SQLite is bundled with the standard Python library (
import sqlite3
) - Python 3.12 ships with a SQLite interactive shell
- one can create Python-written user-defined functions to be used in SQLite queries (see create_function)
- Simon Willison has gone through the process of creating the beautiful llm Python library and CLI
Development
pip install -e '.[test]'
pytest
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
File details
Details for the file tsellm-0.1.0a5.tar.gz
.
File metadata
- Download URL: tsellm-0.1.0a5.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d9d9b5552b43178e354df65ae974da708a2836e7078971d53cd8ee643e6eb9a |
|
MD5 | 54e5d76ddfe0eea7559adbe12ca086ee |
|
BLAKE2b-256 | 9591ffd1c7213dd9227b605b25128dcf9d370773f2cd61b0ec3d814a110b8d9c |
File details
Details for the file tsellm-0.1.0a5-py3-none-any.whl
.
File metadata
- Download URL: tsellm-0.1.0a5-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3a938e8ad60f3b8feab9b11f44442cd60aeefed167b5dbb6720402e76cf1986 |
|
MD5 | 1dd684ed73cbbe4938e2a80548289eeb |
|
BLAKE2b-256 | 27001fa680853ec52077a8550be51f76d167813896ec2960b0c23062d211db73 |