A RAG (Retrieval-Augmented Generation) system that provides AI agents with both short-term conversation memory and long-term knowledge retrieval capabilities.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Interaction β
β (Query / Document Upload) β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RAG Agent β
β (Dynamic Context Construction) β
ββββββββββββ¬βββββββββββββββββββ¬ββββββββββββββββββββ¬ββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββββββ
β Redis β β Qdrant β β AWS Bedrock β
β (Short-term) β β (Long-term) β β (Embeddings + LLM) β
β β β β β β
β β’ Chat history β β β’ Document β β β’ Titan Embeddings β
β β’ Doc metadata β β vectors β β β’ Claude LLM β
ββββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββββββ
- Short-term Memory (Redis): Maintains conversation history and document metadata within a session
- Long-term Memory (Qdrant): Vector storage for semantic search over uploaded documents
- Runtime Document Ingestion: Upload documents during conversation - no pre-processing required
- Session Scoping: Each session has isolated documents and chat history
- AWS Bedrock Integration: Uses Titan for embeddings and Claude for responses via LiteLLM
- Docker and Docker Compose
- Python 3.10+
- AWS Account with Bedrock access (Claude and Titan models enabled)
cd memory_vault
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# Copy example environment file
cp .env.example .env
# Edit .env with your AWS credentialsRequired environment variables:
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_SESSION_TOKEN=your_session_token # Optional, for temporary credentials
AWS_REGION_NAME=us-east-1 # or your preferred region
docker-compose up -dThis starts:
- Qdrant on port 6333 (HTTP) and 6334 (gRPC)
- Redis on port 6379
python scripts/demo.py| Command | Description |
|---|---|
/upload <path> |
Upload and ingest a document |
/docs |
List uploaded documents |
/context |
Toggle showing retrieved context |
/clear |
Clear session (history + documents) |
/health |
Check Redis and Qdrant status |
/help |
Show help message |
/quit |
Exit the demo |
> /upload ~/docs/poker_rules.txt
π€ Uploading ~/docs/poker_rules.txt...
β
Ingested 'poker_rules.txt' (12 chunks)
> /upload ~/docs/tournament_guide.txt
π€ Uploading ~/docs/tournament_guide.txt...
β
Ingested 'tournament_guide.txt' (8 chunks)
> /docs
π Documents in session (2):
β’ poker_rules.txt (12 chunks)
β’ tournament_guide.txt (8 chunks)
> What is the rake percentage for cash games?
π€ Based on the poker rules document, the rake for cash games is 2.5%
capped at $5 per hand. For tournaments, there's a flat 10% fee...
> /context
π Context display: ON
> What are the blind levels in tournaments?
π Retrieved Context:
[1] tournament_guide.txt (score: 0.89)
Blind levels increase every 15 minutes...
[2] poker_rules.txt (score: 0.72)
Tournament blinds start at 25/50...
π€ According to the tournament guide, blind levels increase every 15 minutes.
The starting blinds are 25/50 as mentioned in the poker rules...
from src.agent import RAGAgent
from src.config import Config
# Initialize
config = Config()
agent = RAGAgent(config=config)
session_id = "user-123"
# Upload documents
result = agent.upload_document(session_id, "path/to/document.txt")
print(f"Ingested {result['chunk_count']} chunks")
# Chat with context
response = agent.chat(session_id, "What does the document say about X?")
print(response["response"])
# List documents
docs = agent.list_documents(session_id)
# Clear session when done
agent.clear_session(session_id)memory_vault/
βββ docker-compose.yml # Qdrant + Redis infrastructure
βββ requirements.txt # Python dependencies
βββ .env.example # Environment template
βββ src/
β βββ __init__.py
β βββ config.py # Configuration management
β βββ embeddings.py # LiteLLM + Bedrock Titan wrapper
β βββ short_term_memory.py # Redis wrapper
β βββ long_term_memory.py # Qdrant wrapper
β βββ agent.py # RAG Agent
βββ scripts/
β βββ demo.py # Interactive CLI demo
βββ README.md
| Variable | Default | Description |
|---|---|---|
REDIS_HOST |
localhost | Redis host |
REDIS_PORT |
6379 | Redis port |
QDRANT_HOST |
localhost | Qdrant host |
QDRANT_PORT |
6333 | Qdrant port |
EMBEDDING_MODEL |
amazon.titan-embed-text-v2:0 | Bedrock embedding model |
LLM_MODEL |
anthropic.claude-3-haiku-20240307-v1:0 | Bedrock LLM model |
MAX_CHAT_HISTORY |
10 | Number of conversation turns to retain |
CHUNK_SIZE |
500 | Max characters per document chunk |
TOP_K_RESULTS |
3 | Number of similar chunks to retrieve |
- User uploads a document via
/upload - Document is read and split into chunks (by paragraphs, max 500 chars)
- Each chunk is embedded using Titan Embeddings
- Vectors are stored in Qdrant with session_id and source metadata
- Document metadata is saved to Redis for quick lookup
- User asks a question
- Chat history is retrieved from Redis
- Question is embedded and searched against Qdrant (filtered by session_id)
- Top 3 relevant chunks are retrieved
- System prompt is constructed with chat history + knowledge context
- Claude generates a response
- Conversation turn is saved to Redis
# Check Docker logs
docker-compose logs qdrant
docker-compose logs redis
# Restart services
docker-compose down && docker-compose up -d- Ensure your AWS account has Bedrock access enabled
- Check that Claude and Titan models are enabled in your region
- Verify credentials in
.envfile
- Make sure Docker containers are running:
docker ps - Check ports 6333 (Qdrant) and 6379 (Redis) are not in use
MIT