Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

6 Commits

Repository files navigation

Chat Keeper 💬

A simple conversation logger that stores and browses AI chat histories.

Features

  • 📝 Save chat conversations with timestamps and tags via Flask API
  • 🔍 Browse and search past conversations through Streamlit dashboard
  • 📤 Export conversation history to markdown or JSON formats

Installation

# Clone the repository
git clone https://github.com/yourusername/chat-keeper.git
cd chat-keeper
# Install dependencies
pip install -r requirements.txt

Quick Start

Starting the API Server

python -m chat_keeper.api

The API will be available at http://localhost:5000

Starting the Dashboard

streamlit run chat_keeper/dashboard.py

The dashboard will open in your browser at http://localhost:8501

API Reference

Create a Conversation

POST /api/conversations
{
"title": "My Chat Session",
"tags": ["python", "coding"]
}

Add a Message

POST /api/conversations/<conversation_id>/messages
{
"role": "user",
"content": "Hello, how are you?"
}

Get All Conversations

GET /api/conversations

Get a Specific Conversation

GET /api/conversations/<conversation_id>

Search Conversations

GET /api/search?q=<query>&tags=tag1,tag2&start_date=2024-01-01&end_date=2024-12-31

Export Conversations

GET /api/export?format=markdown # or format=json

Python Usage

fromchat_keeper.storageimportConversationStoragefromchat_keeper.modelsimportConversation, Messagefromchat_keeper.searchimportSearchEnginefromchat_keeper.utilsimportexport_to_markdown, export_to_json# Initialize storagestorage=ConversationStorage("./data")
# Create a new conversationconversation=Conversation(
title="Python Help Session",
tags=["python", "debugging"]
)
# Add messagesconversation.add_message(Message(
role="user",
content="How do I read a JSON file in Python?"
))
conversation.add_message(Message(
role="assistant",
content="You can use the json module: json.load(open('file.json'))"
))
# Save the conversationstorage.save(conversation)
# Search conversationssearch_engine=SearchEngine(storage)
results=search_engine.search("JSON", tags=["python"])
# Export to markdownmarkdown_content=export_to_markdown(conversation)
print(markdown_content)

Project Structure

chat-keeper/
├── README.md
├── requirements.txt
├── chat_keeper/
│ ├── __init__.py
│ ├── api.py # Flask REST API
│ ├── dashboard.py # Streamlit web dashboard
│ ├── models.py # Data models (Conversation, Message)
│ ├── search.py # Search functionality
│ ├── storage.py # File-based storage
│ └── utils.py # Export utilities
└── data/ # Conversation storage (created automatically)

Configuration

Environment variables:

VariableDescriptionDefault
CHAT_KEEPER_DATA_DIRDirectory for storing conversations./data
CHAT_KEEPER_HOSTAPI server host0.0.0.0
CHAT_KEEPER_PORTAPI server port5000

Export Formats

Markdown Export

Conversations are exported as readable markdown files with:

  • Title and metadata header
  • Timestamps for each message
  • Clear role indicators (User/Assistant)

JSON Export

Full data export including:

  • All conversation metadata
  • Complete message history
  • Tags and timestamps

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

About

A simple conversation logger that stores and browses AI chat histories

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages