memory_dao
Memory data access object (DAO) for the Eleanor backend.
Attributes
Classes
MemoryDao
Bases: BaseDao
Agent Memory data access object (DAO)
Attributes
Functions
get_agent_memories_by_pkids
get_agent_memories_by_pkids(
agent_pkid: str, memory_pkids: List[str]
) -> List[Memory]
Retrieve memories for a specific agent. Soft deleted memories are excluded.
Parameters:
-
agent_pkid
(str
) –The pkid of the agent.
-
memory_pkids
(List[str]
) –The pkids of the memories to retrieve.
Returns:
-
List[Memory]
–List[Memory]: The retrieved memories.
get_collections_memories
get_collections_memories(
collection_pkids: list[str], limit: int | None = None
) -> List[Memory]
Given a list of collection pkids, this method leverages SQLAlchemy’s yield_per()
method to stream up to limit
memory memories back to the caller in chunk_size
chunks.
Memories are returned in descending order according to the memory’s accessed
.
Parameters:
-
collection_pkids
(list[str]
) –A list of collection primary keys.
-
limit
(int | None
, default:None
) –The maximum number of memories to retrieve. Defaults to None.
Returns:
-
List[Memory]
–List[Memory]: A list of Memory objects.
get_memories
get_memories(
agent_pkid: str,
memory_collection_pkids: Optional[
Union[str, List[str]]
] = None,
activity_session_pkids: Optional[
Union[str, List[str]]
] = None,
accessed_after: Optional[datetime] = None,
type_filter: Optional[MemoryType] = None,
deleted: Optional[bool] = None,
order_by: Literal[
"ACCESSED", "CREATED", "UPDATED"
] = "ACCESSED",
ordering: Literal["ASC", "DESC"] = "DESC",
limit: int = 100,
) -> List[Memory]
get_memories_by_pkids
get_memories_by_pkids(
memory_pkids: List[str],
) -> List[Memory]
Retrieve memories. Soft deleted memories are excluded.
Parameters:
-
memory_pkids
(List[str]
) –The pkids of the memories to retrieve.
Returns:
-
List[Memory]
–List[Memory]: The retrieved memories.
hard_delete_by_agent_pkid
Hard delete memories for a specific agent.
Parameters:
-
agent_pkid
(str
) –The pkid of the agent.
Returns:
-
int
(int
) –The number of deleted rows.