A memory-augmented framework for LLMs
Project description
🦙 Llamate
Llamate is a memory-augmented agent framework for Large Language Models (LLMs) that provides persistent, retrievable memory for AI conversations.
What is Llamate?
Llamate solves a fundamental limitation of current LLMs: their inability to remember past conversations beyond a single context window. It creates a vector database of memories that can be semantically searched and retrieved during conversations, allowing LLMs to maintain continuity and context over extended interactions.
How It Works
- Memory Storage: Llamate stores important pieces of conversation as vector embeddings in a database (either FAISS or PostgreSQL).
- Semantic Retrieval: When new queries come in, Llamate searches for semantically relevant past memories.
- Memory Filtering: The system automatically filters out the current query from search results to prevent echo effects.
- Context Enhancement: Retrieved memories are injected into the conversation context, allowing the LLM to access and utilize past information.
- User Identification: Each user gets a unique memory space, ensuring personalized conversation history.
Key Features
- Multiple Backend Support: Works with FAISS (file-based) or PostgreSQL (with pgvector)
- Persistence: Memories remain available between sessions and application restarts
- Simple API: Easy-to-use Python interface that works with any LLM
- CLI Interface: Command-line tool for quick testing and interaction
- Production Ready: Designed for both development and production environments
Quick Start
Follow these steps to set up, use, and view data in Llamate with PostgreSQL:
1. Install Llamate
pip install llamate
2. OpenAI API Requirements
Llamate requires access to the following OpenAI models in your account:
text-embedding-3-large- Used for vector embeddingsgpt-4- Recommended for high-quality responses
Make sure these models are enabled in your OpenAI account and set your API key:
3. Start PostgreSQL Container
docker run --name llamate-postgres -e POSTGRES_USER=llamate -e POSTGRES_PASSWORD=llamate -e POSTGRES_DB=llamate -p 5432:5432 -d ankane/pgvector
4. Initialize Llamate
llamate --init
# Select 'postgres' as your vector store backend
# Enter connection string: postgresql://llamate:llamate@localhost:5432/llamate
5. Test Llamate locally
from llamate import MemoryAgent, get_vectorstore_from_env
# Set user ID
user_id = "test_user"
# Initialize components
vectorstore = get_vectorstore_from_env(user_id=user_id)
agent = MemoryAgent(user_id=user_id, vectorstore=vectorstore)
# Add memories
agent.chat("The capital of France is Paris.")
agent.chat("The Eiffel Tower is 324 meters tall.")
agent.chat("Python is a programming language created by Guido van Rossum.")
# Test retrieval
response = agent.chat("Tell me about Paris.")
print("Response:", response)
6. View Data in PostgreSQL
Connect to the database:
docker exec -it llamate-postgres psql -U llamate -d llamate
List tables to find your memory table (it will use your user_id):
\dt
View table structure:
\d memory_test_user
Display memory records (omitting the large vector field):
SELECT id, text FROM memory_test_user;
Count records:
SELECT COUNT(*) FROM memory_test_user;
Query specific memories (using text search):
SELECT id, text FROM memory_test_user WHERE text LIKE '%Paris%';
Delete test memories (if needed):
DELETE FROM memory_test_user WHERE text LIKE '%test%';
Exit the PostgreSQL shell:
\q
Features
- Persistent memory for AI using vector embeddings
- Multiple vector store backends (FAISS and PostgreSQL)
- Easy integration into existing applications
- Simple CLI for testing and demonstration
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 llamate-0.1.7.tar.gz.
File metadata
- Download URL: llamate-0.1.7.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b047e18dd26a503996b891329b9ed9386fa294902a054d98cb1cad5b7ab2ea28
|
|
| MD5 |
2cceec7afa0a283a48913f0fd14d3115
|
|
| BLAKE2b-256 |
526542ad8010f8b85723dff6d43dc9993ecefc730466f3f3ee7d1b137bb73ffd
|
File details
Details for the file llamate-0.1.7-py3-none-any.whl.
File metadata
- Download URL: llamate-0.1.7-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f01ac8b7cf924275a3923c706cd963d552d254acfd38d12b74d3390ce3b1e28
|
|
| MD5 |
557c38df3f05a75ffef02dfaefc4a987
|
|
| BLAKE2b-256 |
3e4c249ac27e36679667e3d4c39c90482846b0a018a47a0824c8b9fc83705454
|