tsellm

Interactive SQLite shell with LLM support

Usage | Installation | How

tsellm is an interactive SQLite shell with LLM Support. Available as pip install tsellm .

Usage

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