๐Ÿ’พ 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:

  1. SQLite Storage (default): Fast, searchable database storage

  2. 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_DIR environment 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ยถ

  1. Use descriptive names when saving conversations to find them easily later

  2. Add tags to group related conversations (e.g., โ€œproject_xโ€, โ€œresearchโ€, โ€œdebuggingโ€)

  3. Export important conversations as backups or for sharing with others

  4. Clear history when switching to a new topic to avoid context confusion

  5. Use SQLite storage for larger projects with many conversations

  6. 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: