Memory System for AI Conversations
Project description
AIMemo
Memory System for AI Conversations
AIMemo is a lightweight memory layer that enables AI agents to remember context across conversations. Build AI applications that truly understand and remember your users.
🚀 Features
- Automatic Memory: Intercepts LLM calls and injects relevant context
- Multiple Backends: SQLite, PostgreSQL support out of the box
- Zero Config: Works with sensible defaults, configure when needed
- LLM Agnostic: Supports OpenAI, Anthropic, and more
- Namespace Isolation: Perfect for multi-user applications
- Full-Text Search: Fast memory retrieval with FTS5/PostgreSQL search
📦 Installation
pip install aimemo
For PostgreSQL support:
pip install aimemo[postgres]
⚡ Quick Start
from aimemo import AIMemo
from openai import OpenAI
# Initialize AIMemo
aimemo = AIMemo()
aimemo.enable()
# Use OpenAI normally - memory is automatic!
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "I'm building a FastAPI project"}]
)
# Later conversation - context is automatically injected
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "How do I add authentication?"}]
)
# The model remembers your FastAPI project!
💡 Use Cases
- Personal AI Assistants: Remember user preferences and history
- Customer Support Bots: Maintain context across support sessions
- Research Assistants: Keep track of research topics and findings
- Multi-Agent Systems: Share memory between multiple AI agents
- Learning Apps: Track student progress and learning patterns
🔧 Configuration
Database Options
SQLite (default):
from aimemo import AIMemo
aimemo = AIMemo() # Uses aimemo.db by default
PostgreSQL:
from aimemo import AIMemo, PostgresStore
store = PostgresStore("postgresql://user:pass@localhost/aimemo")
aimemo = AIMemo(store=store)
Environment Variables
export AIMEMO_DB_PATH="./my_memory.db"
export AIMEMO_MAX_CONTEXT=10
Manual Memory Management
from aimemo import AIMemo
aimemo = AIMemo(namespace="user_123")
# Add memories manually
aimemo.add_memory(
content="User prefers dark mode",
tags=["preference", "ui"],
metadata={"priority": "high"}
)
# Search memories
results = aimemo.search("dark mode", limit=5)
# Get formatted context
context = aimemo.get_context("user interface preferences")
Multi-User Applications
from aimemo import AIMemo
# Each user gets their own namespace
user_memory = AIMemo(namespace=f"user_{user_id}")
user_memory.enable()
# Memories are isolated per user
📚 Examples
Check out the examples/ directory:
- basic_usage.py - Simple conversation with memory
- manual_memory.py - Manual memory management
- postgres_example.py - Using PostgreSQL backend
- context_manager.py - Context manager pattern
🧪 Testing
pip install pytest
pytest tests/
🛠️ Development
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black aimemo tests examples
📖 Documentation
Full documentation is available in the docs/ directory:
- Quick Start Guide - Get started in 5 minutes
- Configuration Guide - Configure AIMemo for your needs
- Architecture Overview - How AIMemo works under the hood
- API Reference - Complete API documentation
- Storage Backends - Database configuration details
- Examples - More code examples and use cases
- Troubleshooting - Common issues and solutions
Development & Planning
- ROADMAP.md - Strategic roadmap and future plans
- TODO.md - Actionable tasks and sprint planning
- IMPLEMENTATION_GUIDE.md - Implementation guide for contributors
- SUMMARY.md - Development summary and quick overview
Core API
AIMemo
enable()- Start intercepting LLM callsdisable()- Stop interceptingadd_memory(content, metadata, tags)- Add memory manuallysearch(query, limit)- Search memoriesget_context(query, limit)- Get formatted contextclear(namespace)- Clear memories
Storage Backends
SQLiteStore(db_path)- SQLite storagePostgresStore(connection_string)- PostgreSQL storage
Architecture
AIMemo works by intercepting LLM API calls:
- Pre-call: Searches relevant memories based on user query
- Injection: Adds context to the conversation
- Post-call: Stores the conversation for future reference
All automatically, with zero code changes!
🤝 Contributing
We love contributions! ❤️ AIMemo is an open-source project and we welcome contributions of all kinds:
- 🐛 Bug Reports: Found a bug? Open an issue
- 💡 Feature Requests: Have an idea? Share it with us
- 📝 Documentation: Help improve our docs
- 🔧 Code: Submit a Pull Request
How to Contribute
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run tests:
pytest tests/ - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
Development Setup
# Clone the repository
git clone https://github.com/gianghungtien/aimemo.git
cd aimemo
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black aimemo tests examples
First time contributing? Check out issues labeled good first issue to get started!
Contributors
Thanks to all the amazing people who have contributed to AIMemo! 🙏
📄 License
MIT License - see LICENSE file for details.
🙋 Support & Community
Need help? We're here for you!
- 💬 GitHub Discussions: Ask questions and share ideas
- 🐛 GitHub Issues: Report bugs or request features
- 📧 Email: gianghungtien@gmail.com
Show Your Support
If you find AIMemo helpful, please consider:
- ⭐ Star this repository to show your support
- 🐦 Share it with your friends and colleagues
- 📝 Write about it in your blog or social media
- 🤝 Contribute to make it even better
Built with ❤️ by Jason
⭐ Star on GitHub • 📖 Documentation • 🐛 Report Bug • 💡 Request Feature
Project details
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 aimemo-1.1.1.tar.gz.
File metadata
- Download URL: aimemo-1.1.1.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
048816f8f12a10fb181391eb620fbe917c4c95e92689f96f7f796188bf653e4f
|
|
| MD5 |
f83c155dd7cf93ef75a33c03de6c29f6
|
|
| BLAKE2b-256 |
a232dd598023b097ba4588fb915d3f20f47513846c2f283addedbaf143354376
|
File details
Details for the file aimemo-1.1.1-py3-none-any.whl.
File metadata
- Download URL: aimemo-1.1.1-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea270d8cba742affd6317299c6fe10ab4a445f5a4131d4beeac721a351e3b65d
|
|
| MD5 |
eb3265b78c094a466b75a68ed48b42ca
|
|
| BLAKE2b-256 |
60628ff8924d8289db5ffd53a07d8d2a0a42c9d5e0f0768917c1107e096ed5f3
|