Audrey M. Roy Greenfeld

Quietly building the future.

LLM, Datasette, and Conversation Deletion

2024-06-14

After installing the Python llm package, downloading Orca Mini 3B, and using it to generate cheesecake and cow names, I did what most people do the first time they try out a language model: they ask the sorts of questions that commercial LLMs can't answer:

pipx install llm
llm -m orca-mini-3b-gguf2-q4_0 '3 names for a pet cow'
llm -m orca-mini-3b-gguf2-q4_0 '3 names for a pet cheesecake'
llm -m orca-mini-3b-gguf2-q4_0 '10 types of strawberries'
llm -m orca-mini-3b-gguf2-q4_0 'How to <redacted> ...'

Then they realize it's all logged in a SQLite database.

Fortunately, it's just a file on your system, and it's easy to delete the database or specific conversations.

Option 1: Delete the Database

If you want to delete the entire database, you can simply delete the file:

$ llm logs path
/Users/me/Library/Application Support/io.datasette.llm/logs.db
$ rm "/Users/me/Library/Application Support/io.datasette.llm/logs.db"

Then you'll see it's gone and you can start fresh:

$ datasette "$(llm logs path)"
Error: Invalid value for '[FILES]...': Path '/Users/drg/Library/Application Support/io.datasette.llm/logs.db' does not exist.
$ llm -m orca-mini-3b-gguf2-q4_0 '3 names for a pet cheesecake'
 1. Rocky Road Cheesecake
2. Chocolate-Covered Strawberry Cheesecake
3. Vanilla Bean Cheesecake
$ datasette "$(llm logs path)"
INFO:     Started server process [20436]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8001 (Press CTRL+C to quit)

Option 2: Delete Specific Conversations

Using the SQLite shell, you can manually delete specific conversations and responses:

$ sqlite3 "$(llm logs path)"
SQLite version 3.37.0 2021-12-09 01:34:53
Enter ".help" for usage hints.

sqlite> .tables
_llm_migrations        responses_fts          responses_fts_docsize
conversations          responses_fts_config   responses_fts_idx    
responses              responses_fts_data   

sqlite> .schema conversations
CREATE TABLE [conversations] (
   [id] TEXT PRIMARY KEY,
   [name] TEXT,
   [model] TEXT
);

sqlite> SELECT * FROM conversations;
01j0bkegay8sjt721jwqaz5jag|3 names for a pet cheesecake|orca-mini-3b-gguf2-q4_0
01j0bkp3hw5wn5sgetq0adg7r6|How to <redacted> …|orca-mini-3b-gguf2-q4_

sqlite> DELETE FROM conversations WHERE name LIKE '%redacted%';
sqlite> DELETE FROM responses WHERE prompt LIKE '%redacted%';

sqlite> .quit