๐พ Managing Conversations: Saving, Loading, and Searching Your LLM Chatsยถ
One of CellMageโs most powerful features is its ability to save, load, and search your LLM conversations. This tutorial will guide you through managing your conversation history effectively.
๐ Understanding Conversation Storageยถ
CellMage offers two primary storage backends:
SQLite Storage (default): Fast, searchable database storage
Markdown Storage: Human-readable file-based storage
Tip: You can control where CellMage stores all working files (including conversation history) by setting the
CELLMAGE_BASE_DIRenvironment variable. See the README for details.
Letโs explore both options and see how to manage your conversations.
๐ Basic Conversation Managementยถ
Viewing Your Current Conversationยถ
To see whatโs in your current conversation:
# Show the full conversation history
%llm_config --show-history
This displays all messages in the current session, including:
System messages (from personas)
User messages (your prompts)
Assistant messages (LLM responses)
Metadata like timestamps and token counts
Clearing Historyยถ
To start fresh without any previous context:
# Clear the conversation history but keep the system prompt
%llm_config --clear-history
# For a completely fresh start, also reset the persona
%llm_config --clear-history --persona default
๐ฝ Saving Conversationsยถ
Quick Saveยถ
The simplest way to save your current conversation:
# Save with an automatically generated name
%llm_config --save
This creates a conversation named with a timestamp and the first few words of your conversation.
Named Saveยถ
For better organization, name your conversations:
# Save with a descriptive name
%llm_config --save "data_analysis_project"
The full name will include your provided name plus a timestamp: data_analysis_project_20250507_...
Auto-Saveยถ
CellMage can automatically save your conversations:
# Enable auto-saving
%llm_config --auto-save
# Disable auto-saving
%llm_config --no-auto-save
When auto-save is enabled, your conversation is saved after each interaction.
๐ Loading Conversationsยถ
Listing Saved Conversationsยถ
To see what conversations youโve saved:
# List all saved conversations
%llm_config --list-sessions
This shows all your saved conversations with their IDs, names, and timestamps.
Loading a Specific Conversationยถ
To load a previously saved conversation:
# Load by full ID
%llm_config --load "data_analysis_project_20250507_123456"
# You can also use just enough of the ID to be unique
%llm_config --load "data_analysis_project"
The loaded conversation replaces your current conversation history.
๐ Searching Your Conversations with SQLiteยถ
SQLite storage (the default) provides powerful search capabilities:
# First, load the SQLite extension
%load_ext cellmage.integrations.sqlite_magic
# Search for conversations containing specific text
%sqlite --search "machine learning"
# Show detailed statistics about your conversations
%sqlite --stats
Advanced SQLite Operationsยถ
The %sqlite magic command offers many useful features:
# View the status of your storage
%sqlite --status
# Create a new conversation
%sqlite --new
# Tag a conversation for better organization
%sqlite --tag current "project_x"
# Find all conversations with a specific tag
%sqlite --search-tag "project_x"
# Export a conversation to Markdown
%sqlite --export "~/exports/my_conversation.md"
# Import a conversation from Markdown
%sqlite --import-md "~/exports/my_conversation.md"
๐ Using Markdown Storageยถ
If you prefer file-based storage instead of SQLite:
# Configure CellMage to use Markdown storage
%llm_config --set-override storage_type file
Markdown storage saves each conversation as a separate .md file in your llm_conversations directory (by default). These files:
Are human-readable
Can be version-controlled
Include all conversation messages and metadata
Can be imported back into CellMage
๐๏ธ Best Practices for Conversation Managementยถ
Use descriptive names when saving conversations to find them easily later
Add tags to group related conversations (e.g., โproject_xโ, โresearchโ, โdebuggingโ)
Export important conversations as backups or for sharing with others
Clear history when switching to a new topic to avoid context confusion
Use SQLite storage for larger projects with many conversations
Use Markdown storage when you want to read or edit conversations outside of CellMage
๐ Managing Multiple Projectsยถ
For different projects, you can use separate conversation stores:
# Set a custom SQLite database path
%llm_config --set-override sqlite_path ~/projects/project_a/conversations.db
This allows you to maintain separate conversation histories for different projects.
๐ Next Stepsยถ
Now that you know how to manage your conversations, you might want to explore:
Creating Custom Personas to shape LLM behavior
Using Snippets to provide reusable context
Advanced Configuration for customizing CellMage