EpisodicMemory
class, which acts as the primary
orchestrator for an individual memory session. It integrates short-term
(session) and long-term (declarative) memory stores to provide a unified
interface for adding and retrieving conversational data.
Key responsibilities include:
- Managing the lifecycle of the memory instance through reference counting.
- Adding new conversational
Episode
objects to both session and declarative memory. - Retrieving relevant context for a query by searching both memory types.
- Interacting with a language model for memory-related tasks.
- Each instance is uniquely identified by a
MemoryContext
and managed by theEpisodicMemoryManager
.
Initialization
To get started, you’ll need to initialize theMemMachineClient
with your API key.
Creating an Episode
To create a new episode, use thecreate_episode
method.
EpisodicMemory Objects
MemoryContext
(defined by group, agent,
user, and session IDs) and is managed by a central
EpisodicMemoryManager
.
__init__
manager
- The EpisodicMemoryManager that created this instance.config
- A dictionary containing the configuration for this memory instance.memory_context
- The unique context for this memory instance.
reference
add_memory_episode
producer
- The ID of the user or agent that created the episode.produced_for
- The ID of the intended recipient.episode_content
- The content of the episode (string or vector).episode_type
- The type of the episode (e.g., ‘message’, ‘thought’).content_type
- The type of the content (e.g., STRING).timestamp
- The timestamp of the episode. Defaults to now().metadata
- Optional dictionary of user-defined metadata.
close
delete_data
query_memory
query
- The query string to find context for.limit
- The maximum number of episodes to return.filter
- A dictionary of properties to filter the search in declarative memory.
formalize_query_with_context
query
- The original query string.limit
- The maximum number of episodes to include in the context.filter
- A dictionary of properties to filter the search.