Asynchronous memory for Mem0
AsyncMemory
class is a direct asynchronous interface to Mem0’s in-process memory operations. Unlike the memory, which interacts with an API, AsyncMemory
works directly with the underlying storage systems. This makes it ideal for applications where you want to embed Mem0 directly into your codebase.
AsyncMemory
, import it from the mem0.memory
module:
asyncio
to avoid blocking the event loopAsyncMemory
have the same parameters as the synchronous Memory
class but are designed to be used with async/await
.
user_id
, agent_id
, or run_id
:
AsyncMemory
can be effectively combined with other async operations. Here’s an example showing how to use it alongside OpenAI API calls in separate threads: