Skip to content

Memory Extraction Schema

Contains Pydantic data models that are used for structured memory extraction from the model (LLM).

memora.schema.extraction_schema.ExtractedMemory

Bases: BaseModel

Attributes

memory class-attribute instance-attribute

memory: str = Field(
    description="The memory, max 25 words, self-contained, remember use of #user_#id# or #agent_#id#."
)

msg_source_ids class-attribute instance-attribute

msg_source_ids: list[int] = Field(
    description="List with id or ids indicating which message blocks this memory was extracted from."
)

memora.schema.extraction_schema.MemoryExtractionResponse

Bases: BaseModel

Attributes

memories_first_pass class-attribute instance-attribute

memories_first_pass: Optional[list[ExtractedMemory]] = (
    Field(
        default_factory=list,
        description="First pass of useful info written for memory (remember use of #user_#id# or #agent_#id#) with their source message ids.",
    )
)

memories_second_pass class-attribute instance-attribute

memories_second_pass: Optional[list[ExtractedMemory]] = (
    Field(
        default_factory=list,
        description="Second pass containing info missed in first pass with their source message ids, if any.",
    )
)

memories_third_pass class-attribute instance-attribute

memories_third_pass: Optional[list[ExtractedMemory]] = (
    Field(
        default_factory=list,
        description="Third pass containing info missed in first and second passes with their source message ids, if any.",
    )
)

memora.schema.extraction_schema.NewGleanedMemory

Bases: BaseModel

Attributes

memory class-attribute instance-attribute

memory: str = Field(
    description="A new gleaned memory, max 25 words, self-contained."
)

source_candidate_pos_id class-attribute instance-attribute

source_candidate_pos_id: int = Field(
    description="The POS_ID of the candidate memory from which this new memory was gleaned."
)

memora.schema.extraction_schema.ContraryMemory

Bases: BaseModel

Attributes

contradicted_memory_id class-attribute instance-attribute

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

memory class-attribute instance-attribute

memory: str = Field(
    description="The candidate memory that directly contradicting an existing memory, max 25 words, self-contained."
)

source_candidate_pos_id class-attribute instance-attribute

source_candidate_pos_id: int = Field(
    description="The POS_ID of the candidate memory from which this contrary memory was sourced."
)

memora.schema.extraction_schema.MemoryComparisonResponse

Bases: BaseModel

Attributes

contrary_memories class-attribute instance-attribute

contrary_memories: list[ContraryMemory] = Field(
    description="List of candidate memories that contradict existing ones, if any."
)

new_memories class-attribute instance-attribute

new_memories: list[NewGleanedMemory] = Field(
    description="List of newly gleaned memories."
)