Run llm from sqlite
Project description
sqlite-utils-llm
This is a plugin for sqlite-utils that adds a custom SQL function llm(model, prompt) that can be used to call out to an LLM model using the llm command line tool.
Installation
Have sqlite-utils and llm already installed, then install this package with pip:
sqlite-utils install sqlite-utils-llm
Example
Given the following combos.csv file with ice cream flavor combinations we want to complete the suggestion column with a flavor suggestion based on the other two flavors using an LLM.
flavor1,flavor2,suggestion
vanilla,chocolate,
strawberry,vanilla,
chocolate,strawberry,
mint,lemon,
Let's load the data into a SQLite database:
% sqlite-utils insert icecream.db combos combos.csv --csv --empty-null
Now we can use the llm function to update the suggestion column with a flavor suggestion:
% sqlite-utils query icecream.db "UPDATE combos set suggestion=llm('gpt-4o-mini', 'What other flavor would I like if I have choosen ' || flavor1 || ' and ' || flavor2 || '? Return just the name of the flavor.')"
Now we can query the table to see the suggestions:
% sqlite-utils query icecream.db "SELECT * FROM combos" --table
flavor1 flavor2 suggestion
---------- ---------- ------------
vanilla chocolate Strawberry
strawberry vanilla Chocolate
chocolate strawberry Vanilla
mint lemon Basil
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 sqlite_utils_llm-0.3.tar.gz.
File metadata
- Download URL: sqlite_utils_llm-0.3.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d7bf6b8d4dd13e80d0cc674203f6c6e1fe7973b2b75970348879ba66eea7ca0
|
|
| MD5 |
854133b86d0ae58d23d575b4bf32a5a1
|
|
| BLAKE2b-256 |
5162402a0c7c94506366a36e110f13ab2252b0fb12279b68a24bf19ba21b0b37
|
File details
Details for the file sqlite_utils_llm-0.3-py3-none-any.whl.
File metadata
- Download URL: sqlite_utils_llm-0.3-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccc1f4b82df55e9aca0e831b198b394db701ce2eb2ee5d1860073b07df165222
|
|
| MD5 |
6cbe99bcc19fe3b803e55f4606a78d9c
|
|
| BLAKE2b-256 |
d67cc7082ddd3c67b923242f5b9fb72bc97694b8902395c194a8fefdc8aaef59
|