Skip to content

Save Memory Schema

Contains Pydantic data models that are used to ease memory storage in stores (e.g. vector and graph databases).

memora.schema.storage_schema.MemoryToStore

Bases: BaseModel

Attributes

memory instance-attribute

memory: str

source_msg_block_pos class-attribute instance-attribute

source_msg_block_pos: list[int] = Field(
    description="The position of the message block that resulted in this memory."
)

memora.schema.storage_schema.ContraryMemoryToStore

Bases: MemoryToStore

Attributes

existing_contrary_memory_id class-attribute instance-attribute

existing_contrary_memory_id: str = Field(
    description="The memory_id of the existing memory that was contradicted."
)

memora.schema.storage_schema.MemoriesAndInteraction

Bases: BaseModel

Contains both the interaction, its date and the associated memories to store in memory stores.

Attributes

contrary_memories class-attribute instance-attribute

contrary_memories: list[ContraryMemoryToStore] = Field(
    default=[],
    description="The memory extracted from the interaction with the above but also the memory id of the existing memory they contradicted.",
)

interaction class-attribute instance-attribute

interaction: list[dict[str, str]] = Field(
    default=[],
    description="The messages in the interaction [{'role': 'user', 'content': 'hello'}, ...]",
)

interaction_date class-attribute instance-attribute

interaction_date: datetime = Field(
    default=now(),
    description="The date and time the interaction occurred.",
)

memories class-attribute instance-attribute

memories: list[MemoryToStore] = Field(
    default=[],
    description="The memories extracted from the interaction with their source messages position.",
)