๐ The Magical Memory Vault: SQLite Storageยถ
CellMage provides a powerful SQLite-based storage system - think of it as your magical memory vault where all your conversations with the AI wizard are preserved with perfect clarity! This enchanted storage offers:
๐ Crystal Ball Search: Find any past conversation with full-text search
๐ท๏ธ Magic Tags: Label and organize your conversations with custom tags
๐ Wizard Analytics: Track your LLM usage with detailed statistics
๐ Spell Archives: Export conversations to Markdown scrolls (and import them back)
๐ช Quick Startยถ
To begin using the magical SQLite storage:
# Load the extension with the SQLite vault
%load_ext cellmage.integrations.sqlite_magic
# Check the status of your storage vault
%sqlite --status
๐ฌ Casting Spells with SQLite Storageยถ
The SQLite storage automatically captures all your magical conversations. Use it just like regular CellMage:
# Cast a spell (sends to LLM and stores in SQLite)
%%llm
Explain how wizards might use databases in magical societies.
๐งโโ๏ธ SQLite Magic Commandsยถ
The %sqlite line magic gives you special powers:
Magical Command |
What It Does |
|---|---|
|
Reveals the current state of your memory vault |
|
Shows statistics about your stored conversations |
|
Unrolls a scroll listing all stored conversations |
|
Begins a fresh conversation in a new vault |
|
Retrieves a specific conversation by ID |
|
Banishes a conversation from the vault |
|
Marks a conversation with a magical tag |
|
Searches for specific words in your conversations |
|
Transforms a conversation into a markdown scroll |
|
Absorbs a markdown scroll into your vault |
๐ Examples of Magical Storageยถ
# Start a new conversation
%sqlite --new
# Tag your current conversation as "potions"
%sqlite --tag current potions
# Search for conversations about "dragons"
%sqlite --search dragons
# Export your current conversation to share with other wizards
%sqlite --export ~/my_dragon_research.md
# Load a specific conversation by ID
%sqlite --load 42
๐งช Programmatic Alchemyยถ
For advanced wizards who wish to control the storage vault directly:
from cellmage.storage.sqlite_store import SQLiteStore
# Create a custom storage vault
store = SQLiteStore(db_path="~/.cellmage/my_special_vault.db")
# Store a magical conversation
conversation_id = store.save_conversation(
messages=[{"role": "user", "content": "What is magic?"}],
metadata={"tags": ["philosophy", "beginners"]}
)
# Retrieve conversations with specific tags
philosophical_convos = store.get_conversations_with_tag("philosophy")
๐งญ Migrating from Scroll-based Storageยถ
If you have old conversations stored in markdown files:
# Import a specific markdown conversation
%sqlite --import-md path/to/conversation.md
# Or import all conversations from a directory
import glob
from pathlib import Path
for file_path in glob.glob("path/to/conversations/*.md"):
!ipython -c "%sqlite --import-md {file_path}"
โจ Benefits of the Magical Vaultยถ
โก Speed: Access conversations instantly, even when you have thousands
๐ก๏ธ Security: Your conversations are safely locked in a single file
๐ Discovery: Easily find past conversations when you need them
๐ Insights: Track how you use your magical powers over time
๐ฐ Vault Architectureยถ
The magic behind the vault consists of these components:
SQLiteStore: The core enchantment instorage/sqlite_store.pyConversationManager: The high wizard interface inconversation_manager.pysqlite_magic.py: The magical bridge to IPythonMagic command modules in the
magic_commands/chamber