memoryscope.core.storage.base_memory_store
- class memoryscope.core.storage.base_memory_store.BaseMemoryStore[源代码]
基类:
object
An abstract base class defining the interface for a memory store which handles memory nodes. It outlines essential operations like retrieval, updating, flushing, and closing of memory scopes.
- abstract retrieve_memories(query: str = '', top_k: int = 3, filter_dict: Dict[str, List[str]] | None = None) List[MemoryNode] [源代码]
Retrieves a list of MemoryNode objects that are most relevant to the query, considering a filter dictionary for additional constraints. The number of nodes returned is limited by top_k.
- 参数:
query (str) -- The query string used to find relevant memories.
top_k (int) -- The maximum number of MemoryNode objects to return.
filter_dict (Dict[str, List[str]]) -- A dictionary with keys representing filter fields and values as lists of strings for filtering criteria.
- 返回:
- A list of MemoryNode objects sorted by relevance to the query,
limited to top_k items.
- 返回类型:
List[MemoryNode]
- abstract async a_retrieve_memories(query: str = '', top_k: int = 3, filter_dict: Dict[str, List[str]] | None = None) List[MemoryNode] [源代码]
Asynchronously retrieves a list of MemoryNode objects that best match the query, respecting a filter dictionary, with the result size capped at top_k.
- 参数:
query (str) -- The text to search for in memory nodes.
top_k (int) -- Maximum number of nodes to return.
filter_dict (Dict[str, List[str]]) -- Filters to apply on memory nodes.
- 返回:
A list of up to top_k MemoryNode objects matching the criteria.
- 返回类型:
List[MemoryNode]
- abstract batch_insert(nodes: List[MemoryNode])[源代码]
- abstract batch_update(nodes: List[MemoryNode], update_embedding: bool = True)[源代码]
- abstract batch_delete(nodes: List[MemoryNode])[源代码]