Skip to main content
Defines the core memory instance for a specific conversational context. This module provides the 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 managed by the EpisodicMemoryManager.

Class EpisodicFilter

Callable protocol representing an episode filter predicate.
def EpisodicFilter()

Class EpisodicMemoryParams

Parameters for configuring the EpisodicMemory. Attributes: session_key (str): The unique identifier for the session. metrics_factory (MetricsFactory): The metrics factory. long_term_memory (LongTermMemory): The long-term memory. short_term_memory (ShortTermMemory): The short-term memory. enabled (bool): Whether the episodic memory is enabled.
def EpisodicMemoryParams()

validate_memory_params

def validate_memory_params()
Parameters
NameTypeDescription

Class EpisodicMemory

Represents a single, isolated memory instance for a specific session. This class orchestrates the interaction between short-term (session) memory and long-term (declarative) memory. It manages the lifecycle of the memory, handles adding new information (episodes), and provides methods to retrieve contextual information for queries. Each instance is tied to a unique session key
def EpisodicMemory(params: EpisodicMemoryParams)
Parameters
NameTypeDescription
paramsEpisodicMemoryParams-

short_term_memory

Get the short-term memory of the episodic memory instance.
def short_term_memory()
Parameters
NameTypeDescription
Returns The short-term memory of the episodic memory instance.

short_term_memory

Set the short-term memory of the episodic memory instance. This makes the short term memory can be injected.
def short_term_memory(value: ShortTermMemory | None)
Parameters
NameTypeDescription
value`ShortTermMemoryNone`The new short-term memory of the episodic memory instance.

long_term_memory

Get the long-term memory of the episodic memory instance.
def long_term_memory()
Parameters
NameTypeDescription
Returns The long-term memory of the episodic memory instance.

long_term_memory

Set the long-term memory of the episodic memory instance. This makes the long term memory can be injected.
def long_term_memory(value: LongTermMemory | None)
Parameters
NameTypeDescription
value`LongTermMemoryNone`The new long-term memory of the episodic memory instance.

session_key

Get the session key of the episodic memory instance.
def session_key()
Parameters
NameTypeDescription
Returns The session key of the episodic memory instance.