Inspired by Mem0: Building Production-Ready AI Agents with Scalable Long-Term Memory and Mem0 repo
This educational repository demonstrates an agentic memory system implementation based on the research from Mem0: Building Production-Ready AI Agents with Scalable Long-Term Memory. The system provides scalable, long-term memory capabilities for AI agents with intelligent fact extraction, semantic search, and memory consolidation.
The agentic memory system follows the Mem0 architecture with the following key components:
- Vector Database: Qdrant for semantic similarity search
- Embedding Model: OpenAI text-embedding-3-small for vector representations
- Metadata Indexing: filtering by user
- CRUD Operations: Complete create, read, update, delete capabilities
- Fact Extraction: AI-powered extraction of factual information from conversations
- Memory Consolidation: Merging and updating of existing memories
- Semantic Search: Context-aware retrieval of relevant memories
- CRUD Operations: Full create, read, update, delete capabilities
- Memory Actions: ADD, UPDATE, DELETE, UNCHANGED operations
- Extracts factual information from natural language input
- Identifies personal preferences, plans, goals, and key information
- Compares new facts with existing memories
- Determines appropriate actions (ADD/UPDATE/DELETE/UNCHANGED)
- Preserves important historical information
- Updates outdated information intelligently
- Vector-based similarity search using embeddings
- Configurable similarity thresholds
await memory.add("I'm a software engineer at Akieni and I prefer TypeScript", {
userId: "user123",
});
const results = await memory.search("What programming languages do I know?", {
userId: "user123",
});
await memory.update("memory_id", "Updated memory content");
await memory.delete("memory_id");
The main interface for memory operations:
add()
: Extract facts and consolidate with existing memoriessearch()
: Semantic search with natural language queriesget()
: Retrieve specific memory by IDupdate()
: Update specific memory contentdelete()
: Remove specific memories
Complete storage implementation with:
- Vector Database Management: Qdrant integration with proper indexing
- Embedding Generation: OpenAI embedding model integration
- CRUD Operations: Full create, read, update, delete capabilities
AI-powered processing:
extractFactsPrompt
: Extracts factual information from inputupdateMemoryPrompt
: Determines memory consolidation actions
QDRANT_URL=your_qdrant_url
QDRANT_API_KEY=your_qdrant_api_key
OPENAI_API_KEY=your_openai_api_key
MEMORY_COLLECTION_NAME=agentic_memory
const storage = createMemoryStorage({
url: process.env.QDRANT_URL!,
apiKey: process.env.QDRANT_API_KEY,
collectionName: "memory",
});
await storage.initialize();
The repository includes comprehensive examples:
- Basic Operations: Core memory operations
- Memory Consolidation: Memory merging
Run the examples:
npm run dev