Skip to main content

factories

AI Agent Memory Adapter Factory Functions Provides factory functions for heavy memory adapters that replace hardcoded imports in memory/memory.py. These enable lazy loading of heavy dependencies while maintaining the protocol-driven architecture. Each factory function:
  1. Lazy imports the required dependencies
  2. Creates and returns an adapter instance that implements MemoryProtocol
  3. Raises clear ImportError with installation instructions if dependencies missing
This approach follows the protocol-driven core principle by moving heavy implementations out of the core Memory class while preserving backward compatibility.

Import

Classes

Mem0MemoryAdapter

Memory adapter that wraps mem0.Memory to implement MemoryProtocol.

ChromaMemoryAdapter

Memory adapter that uses ChromaDB to implement MemoryProtocol.

MongoDBMemoryAdapter

Memory adapter that uses MongoDB to implement MemoryProtocol.

DakeraMemoryAdapter

Memory adapter that wraps the Dakera SDK to implement MemoryProtocol.

Functions

safe_mem0_search()

Defensive wrapper for mem0.search() to handle MongoDB vector store compatibility.

create_mem0_memory_adapter()

Factory function to create Mem0 memory adapter.

create_chroma_memory_adapter()

Factory function to create ChromaDB memory adapter.

create_mongodb_memory_adapter()

Factory function to create MongoDB memory adapter.

create_dakera_memory_adapter()

Factory function to create a Dakera memory adapter.