nat.plugins.memmachine.memmachine_editor#
Attributes#
Classes#
Wrapper class that implements |
Module Contents#
- logger#
- class MemMachineEditor(memmachine_instance: Any)#
Bases:
nat.memory.interfaces.MemoryEditorWrapper class that implements
natinterfaces forMemMachineintegrations. Uses theMemMachinePython SDK (MemMachineClient) as documented at: MemMachine/MemMachineSupports both episodic and semantic memory through the unified SDK interface.
User needs to add
MemMachineSDK ids as metadata to the MemoryItem:session_idagent_idproject_idorg_id
Initialize class with MemMachine instance.
- Args:
memmachine_instance: Preinstantiated MemMachineClient or Project object.
- _memmachine#
- _is_client#
- _is_project#
- _get_memory_instance(
- user_id: str,
- session_id: str,
- agent_id: str,
- project_id: str | None = None,
- org_id: str | None = None,
Get or create a memory instance for the given context using the MemMachine SDK.
- Args:
user_id: User identifier session_id: Session identifier agent_id: Agent identifier project_id: Optional project identifier (default: “default-project”) org_id: Optional organization identifier (default: “default-org”)
- Returns:
Memory instance from MemMachine SDK
- async add_items(items: list[nat.memory.models.MemoryItem]) None#
Insert Multiple MemoryItems into the memory using the MemMachine SDK. Each MemoryItem is translated and uploaded through the MemMachine API.
All memories are added to both episodic and semantic memory types.
- async search(
- query: str,
- top_k: int = 5,
- \*\*kwargs,
Retrieve items relevant to the given query using the MemMachine SDK.
- Args:
query (str): The query string to match. top_k (int): Maximum number of items to return. kwargs: Other keyword arguments for search.
Keyword arguments must include
user_id. May also includesession_id,agent_id,project_id,org_id.- Returns:
list[MemoryItem]: The most relevant MemoryItems for the given query.
- async remove_items(\*\*kwargs) None#
Remove items using the MemMachine SDK.
- Args:
kwargs (dict): Keyword arguments to pass to the remove-items method.
Should include either
memory_idoruser_id. May also includesession_id,agent_id,project_id,org_id. Formemory_iddeletion, may includememory_type(‘episodic’ or ‘semantic’).