Memory processing system for chat applications with fact extraction and summarization
Project description
ChatSorter
Memory processing system for chat applications with automatic fact extraction, summarization, and intelligent memory retrieval.
Installation
From PyPI
pip install chatsorter
From Source (Development)
git clone https://github.com/yourusername/chatsorter.git
cd chatsorter
pip install -e .
Quick Start
Python API
from chatsorter import ChatSorter
# Initialize with your API key
cs = ChatSorter(api_key="cs_demo_xxxx")
# Remember a message
cs.remember(chat_id="user123", message="Hi, I'm John from Boston working at TechCorp")
# Recall memories
memories = cs.recall(chat_id="user123", query="where does John work?")
print(memories['memories']) # Related memories from conversation history
Command Line
# Remember a message
chatsorter --api-key cs_demo_xxxx "Hi, I'm John from Boston" --chat-id user123
# Recall memories
chatsorter --api-key cs_demo_xxxx --recall "where does John work" --chat-id user123
# Check API health
chatsorter --api-key cs_demo_xxxx --health
Command Line Interface
# Process a message
chatsorter "Hello, my name is Alice" --chat-id alice_chat
# Search memories
chatsorter --search "what is my name" --chat-id alice_chat
# Show all facts
chatsorter --facts --chat-id alice_chat
# Clear chat
chatsorter --clear --chat-id alice_chat
Features
- Automatic Fact Extraction: Extracts names, locations, jobs, preferences, and more
- Memory Summarization: Creates narrative summaries of conversations
- Intelligent Search: Vector-based semantic search through conversation history
- Importance Scoring: Rates message importance for better memory management
- Multi-Chat Support: Handle multiple conversations simultaneously
- Background Processing: Asynchronous extraction and summarization
API Reference
ChatSorter Class
__init__(data_dir="data", api_key=None, company_id=None, user_id="default_user")
Initialize ChatSorter instance.
process(message, chat_id, retrieve_memories=True, clear_chat=False)
Process a message and return extracted information.
Returns:
{
"facts": {...}, # Extracted facts
"importance": 0.0, # Importance score
"memories": [...], # Related memories
"response": "...", # Processing status
"analysis": {...} # Additional metadata
}
search(query, chat_id, max_results=5)
Search for memories related to a query.
get_facts(chat_id)
Get all extracted facts for a conversation.
clear_chat(chat_id)
Clear all memories and facts for a conversation.
Configuration
Set these environment variables:
OPENAI_API_KEY: Your OpenAI API key (for LLM-powered features)OLLAMA_BASE_URL: Ollama server URL (optional, for local LLM)
Development
Local Development
pip install -r requirements.txt
python api.py # Start API server
Testing
python example.py # Run example script
python quicktest.py # Run diagnostic tests
Building Package
python -m build
pip install dist/chatsorter-0.1.0.tar.gz
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chatsorter-0.1.0.tar.gz.
File metadata
- Download URL: chatsorter-0.1.0.tar.gz
- Upload date:
- Size: 119.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
533dd0ee927a33135e9703a5debd396f2a4d82e167e46a0ec64079416b8fe104
|
|
| MD5 |
8f9ca5fc605e8b769adbe46933b91a81
|
|
| BLAKE2b-256 |
8dae241b9b64873b1d66d8e8ae7cfa3298d137dc254f1a15b774958c25bd97f1
|
File details
Details for the file chatsorter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: chatsorter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 143.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f56a9dfce1e6cbd332d4b22298f9f2568d1eab5c585525887c1db90d077442b7
|
|
| MD5 |
208172b669aff11d3d6164955675148d
|
|
| BLAKE2b-256 |
132e53925e6c7e2dae4c323b20c0076bb4daeeb98d3dc10e51222bb8c547eb37
|