Metadata-Version: 2.4
Name: chatsorter
Version: 0.1.0
Summary: Memory processing system for chat applications with fact extraction and summarization
Author-email: ChatSorter Team <info@chatsorter.com>
Project-URL: Homepage, https://github.com/yourusername/chatsorter
Project-URL: Documentation, https://chatsorter.readthedocs.io/
Project-URL: Repository, https://github.com/yourusername/chatsorter.git
Project-URL: Issues, https://github.com/yourusername/chatsorter/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: flask>=2.0.0
Requires-Dist: flask-cors>=3.0.0
Requires-Dist: waitress>=2.0.0
Requires-Dist: gunicorn>=20.0.0
Requires-Dist: numpy>=1.21.0
Requires-Dist: firebase-admin>=5.0.0
Requires-Dist: faiss-cpu>=1.7.0
Requires-Dist: sentence-transformers>=2.0.0
Requires-Dist: torch>=1.9.0
Requires-Dist: pdfplumber>=0.7.0
Requires-Dist: PyPDF2>=2.0.0
Requires-Dist: pinecone-client>=2.0.0
Requires-Dist: chromadb>=0.3.0
Requires-Dist: weaviate-client>=3.0.0
Requires-Dist: requests>=2.25.0
Requires-Dist: openai>=1.0.0
Requires-Dist: python-dotenv>=0.19.0

# ChatSorter

Memory processing system for chat applications with automatic fact extraction, summarization, and intelligent memory retrieval.

## Installation

### From PyPI
```bash
pip install chatsorter
```

### From Source (Development)
```bash
git clone https://github.com/yourusername/chatsorter.git
cd chatsorter
pip install -e .
```

## Quick Start

### Python API

```python
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

```bash
# 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

```bash
# 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:**
```python
{
    "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
```bash
pip install -r requirements.txt
python api.py  # Start API server
```

### Testing
```bash
python example.py  # Run example script
python quicktest.py  # Run diagnostic tests
```

### Building Package
```bash
python -m build
pip install dist/chatsorter-0.1.0.tar.gz
```

## License

MIT License
