ContentType Objects

class ContentType(Enum)
This Enum specifies the type of data stored within an Episode. While it currently supports a single content type, it is designed to be extensible to accommodate other types like vectors or images in the future.
  • STRING: Denotes that the content is a standard string.

SessionInfo Objects

class SessionInfo()
The SessionInfo dataclass holds essential information about a single conversation session. It’s typically used to manage and retrieve session details from a database.

init

def __init__(id: int,
             user_ids: list[str],
             session_id: str,
             group_id: str | None = None,
             agent_ids: list[str] | None = None,
             configuration: dict | None = None)
Initializes a new SessionInfo instance. Arguments:
  • id (int) - The unique database identifier for the session.
  • user_ids (list[str]) - A list of user identifiers participating in the session.
  • session_id (str) - A unique string identifier for the session.
  • group_id (str | None) - The identifier for a group conversation, if applicable.
  • agent_ids (list[str] | None) - A list of agent identifiers participating in the session.
  • configuration (dict | None) - A dictionary containing any custom configuration for this session.

MemoryContext Objects

class MemoryContext()
The MemoryContext dataclass defines the unique context for a memory instance. It’s used to isolate memories for different conversations, users, and agents, ensuring that data from one session doesn’t interfere with another. It also includes a pre-computed hash string for efficient lookup.

init

def __init__(group_id: str,
             agent_id: set[str],
             user_id: set[str],
             session_id: str,
             hash_str: str)
Initializes a new MemoryContext instance. Arguments:
  • group_id (str) - The identifier for the group context.
  • agent_id (set[str]) - A set of agent identifiers for the context.
  • user_id (set[str]) - A set of user identifiers for the context.
  • session_id (str) - The identifier for the session context.
  • hash_str (str) - A pre-computed string representation of the context for hashing.

hash

def __hash__(self)
Computes the hash of the context based on the hash_str. Returns: The integer hash of the context.

Episode Objects

class Episode()
An Episode represents a single, atomic event or piece of data in the memory system. This dataclass uses the kw_only=True flag to ensure that all fields must be specified by keyword arguments during instantiation, improving code clarity.

init

def __init__(uuid: UUID,
             episode_type: str,
             content_type: ContentType,
             content: Any,
             timestamp: datetime,
             group_id: str,
             session_id: str,
             producer_id: str,
             produced_for_id: str | None = None,
             user_metadata: JSONValue = None)
Initializes a new Episode instance. Arguments:
  • uuid (UUID) - A unique identifier (UUID) for the episode.
  • episode_type (str) - A string indicating the type of the episode (e.g., ‘message’, ‘thought’, ‘action’).
  • content_type (ContentType) - The type of the data stored in the ‘content’ field.
  • content (Any) - The actual data of the episode.
  • timestamp (datetime) - The date and time when the episode occurred.
  • group_id (str) - Identifier for the group.
  • session_id (str) - Identifier for the session to which this episode belongs.
  • producer_id (str) - The identifier of the user or agent that created this episode.
  • produced_for_id (str | None) - The identifier of the intended recipient, if any.
  • user_metadata (JSONValue) - A dictionary for any additional, user-defined metadata.