core.memory.types
Types for the memory vector recall feature.
Defines the result and storage shapes used by TurnVectorStore and
the higher-level Memory facade (added in L2).
Types for the memory vector recall feature.
Defines the result and storage shapes used by TurnVectorStore and
the higher-level Memory facade (added in L2).
- class EmbeddingBackend(*args, **kwargs)[source]
Bases:
ProtocolDuck-typed contract for an embedding backend used by
Memory.Embeddingssatisfies this natively; tests can supply any object with matchingembedandaembedsignatures (e.g.,FakeEmbeddings).
- class TurnHit(score, turn, turn_index, text, metadata)[source]
Bases:
objectA single ranked result returned by
TurnVectorStore.search.- Parameters:
- score
Cosine similarity in
[-1.0, 1.0]between the query embedding and the stored turn’s embedding. Sorted descending bysearch().- Type:
- turn
The raw turn dict stored at index time. Mirrors the
PermanentHistoryturn shape:{"role": str, "content": [{"type": "text", "text": str}], "timestamp": float, "metadata": dict}.
- turn_index
Position of the entry in
TurnVectorStoreat the time of the search. Stable within a singlesearch()call for a given store; may shift afterclear().- Type:
- text
Pre-extracted plain text (typically the Q+A pair) that was embedded. Equal to the string passed to
add(text=...).- Type:
- metadata
Caller-provided metadata attached at index time. Always present (possibly empty dict). Tier 2 will populate
user_id/session_id/agent_idhere.
- class Entry(text, embedding, turn, metadata)[source]
Bases:
NamedTupleStorage tuple yielded by
TurnVectorStore.iter_entries.Fields mirror what was passed to
add()at index time. Used byMemory.reindex()(L2) andpersist_store()(L3) to read the store’s full contents without reaching into private state.
Classes
- class EmbeddingBackend(*args, **kwargs)[source]
Bases:
ProtocolDuck-typed contract for an embedding backend used by
Memory.Embeddingssatisfies this natively; tests can supply any object with matchingembedandaembedsignatures (e.g.,FakeEmbeddings).
- class Entry(text, embedding, turn, metadata)[source]
Bases:
NamedTupleStorage tuple yielded by
TurnVectorStore.iter_entries.Fields mirror what was passed to
add()at index time. Used byMemory.reindex()(L2) andpersist_store()(L3) to read the store’s full contents without reaching into private state.- count(value, /)
Return number of occurrences of value.
- index(value, start=0, stop=9223372036854775807, /)
Return first index of value.
Raises ValueError if the value is not present.
- class TurnHit(score, turn, turn_index, text, metadata)[source]
Bases:
objectA single ranked result returned by
TurnVectorStore.search.- Parameters:
- score
Cosine similarity in
[-1.0, 1.0]between the query embedding and the stored turn’s embedding. Sorted descending bysearch().- Type:
- turn
The raw turn dict stored at index time. Mirrors the
PermanentHistoryturn shape:{"role": str, "content": [{"type": "text", "text": str}], "timestamp": float, "metadata": dict}.
- turn_index
Position of the entry in
TurnVectorStoreat the time of the search. Stable within a singlesearch()call for a given store; may shift afterclear().- Type:
- text
Pre-extracted plain text (typically the Q+A pair) that was embedded. Equal to the string passed to
add(text=...).- Type:
- metadata
Caller-provided metadata attached at index time. Always present (possibly empty dict). Tier 2 will populate
user_id/session_id/agent_idhere.