Skip to content

bytesbeard/chat-keeper

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

from 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)

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:

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

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

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages