A simple conversation logger that stores and browses AI chat histories.
- 📝 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
# Clone the repository
git clone https://github.com/yourusername/chat-keeper.git
cd chat-keeper
# Install dependencies
pip install -r requirements.txtpython -m chat_keeper.apiThe API will be available at http://localhost:5000
streamlit run chat_keeper/dashboard.pyThe dashboard will open in your browser at http://localhost:8501
POST /api/conversations
{
"title": "My Chat Session",
"tags": ["python", "coding"]
}POST /api/conversations/<conversation_id>/messages
{
"role": "user",
"content": "Hello, how are you?"
}GET /api/conversationsGET /api/conversations/<conversation_id>GET /api/search?q=<query>&tags=tag1,tag2&start_date=2024-01-01&end_date=2024-12-31GET /api/export?format=markdown # or format=jsonfrom chat_keeper.storage import ConversationStorage
from chat_keeper.models import Conversation, Message
from chat_keeper.search import SearchEngine
from chat_keeper.utils import export_to_markdown, export_to_json
# Initialize storage
storage = ConversationStorage("./data")
# Create a new conversation
conversation = Conversation(
title="Python Help Session",
tags=["python", "debugging"]
)
# Add messages
conversation.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 conversation
storage.save(conversation)
# Search conversations
search_engine = SearchEngine(storage)
results = search_engine.search("JSON", tags=["python"])
# Export to markdown
markdown_content = export_to_markdown(conversation)
print(markdown_content)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)
Environment variables:
| Variable | Description | Default |
|---|---|---|
CHAT_KEEPER_DATA_DIR |
Directory for storing conversations | ./data |
CHAT_KEEPER_HOST |
API server host | 0.0.0.0 |
CHAT_KEEPER_PORT |
API server port | 5000 |
Conversations are exported as readable markdown files with:
- Title and metadata header
- Timestamps for each message
- Clear role indicators (User/Assistant)
Full data export including:
- All conversation metadata
- Complete message history
- Tags and timestamps
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details.