factories • AI Agent SDK
Memory Adapter Factory Functions
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:
- Lazy imports the required dependencies
- Creates and returns an adapter instance that implements MemoryProtocol
- 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
from praisonaiagents.memory.adapters import factoriesClasses
Memory adapter that wraps mem0.Memory to implement MemoryProtocol.
ChromaMemoryAdapterMemory adapter that uses ChromaDB to implement MemoryProtocol.
MongoDBMemoryAdapterMemory adapter that uses MongoDB to implement MemoryProtocol.
DakeraMemoryAdapterMemory adapter that wraps the Dakera SDK to implement `MemoryProtocol`.
Functions
Sanitize metadata for ChromaDB – convert to acceptable types.
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.