MCPcopy Create free account
hub / github.com/MemTensor/MemOS / update

Method update

src/memos/mem_os/core.py:997–1034  ·  view source on GitHub ↗

Update a textual memory in a MemCube by text_memory_id and text_memory_id. Args: mem_cube_id (str): The identifier of the MemCube to update the memory in. memory_id (str): The identifier of the textual memory to update. text_memory_item (TextualM

(
        self,
        mem_cube_id: str,
        memory_id: str,
        text_memory_item: TextualMemoryItem | dict[str, Any],
        user_id: str | None = None,
    )

Source from the content-addressed store, hash-verified

995 return result
996
997 def update(
998 self,
999 mem_cube_id: str,
1000 memory_id: str,
1001 text_memory_item: TextualMemoryItem | dict[str, Any],
1002 user_id: str | None = None,
1003 ) -> None:
1004 """
1005 Update a textual memory in a MemCube by text_memory_id and text_memory_id.
1006
1007 Args:
1008 mem_cube_id (str): The identifier of the MemCube to update the memory in.
1009 memory_id (str): The identifier of the textual memory to update.
1010 text_memory_item (TextualMemoryItem | dict[str, Any]): The updated textual memory item.
1011 """
1012 assert mem_cube_id in self.mem_cubes, (
1013 f"MemCube with ID {mem_cube_id} does not exist. please regiester"
1014 )
1015 target_user_id = user_id if user_id is not None else self.user_id
1016 # Validate user has access to this cube
1017 self._validate_cube_access(target_user_id, mem_cube_id)
1018 if mem_cube_id is None:
1019 # Try to find a default cube for the user
1020 accessible_cubes = self.user_manager.get_user_cubes(target_user_id)
1021 if not accessible_cubes:
1022 raise ValueError(
1023 f"No accessible cubes found for user '{target_user_id}'. Please register a cube first."
1024 )
1025 mem_cube_id = accessible_cubes[0].cube_id # TODO not only first
1026 else:
1027 self._validate_cube_access(target_user_id, mem_cube_id)
1028 if self.mem_cubes[mem_cube_id].config.text_mem.backend != "tree_text":
1029 self.mem_cubes[mem_cube_id].text_mem.update(memory_id, memories=text_memory_item)
1030 logger.info(f"MemCube {mem_cube_id} updated memory {memory_id}")
1031 else:
1032 logger.warning(
1033 f" {self.mem_cubes[mem_cube_id].config.text_mem.backend} does not support update memory"
1034 )
1035
1036 def delete(self, mem_cube_id: str, memory_id: str, user_id: str | None = None) -> None:
1037 """

Callers 15

contentHashFunction · 0.45
approveUserMethod · 0.45
ensureBootstrapAdminMethod · 0.45
signFunction · 0.45
authenticateMethod · 0.45
hashPasswordMethod · 0.45
runMigrationMethod · 0.45
contentHashFunction · 0.45
approveUserMethod · 0.45
ensureBootstrapAdminMethod · 0.45
signFunction · 0.45
authenticateMethod · 0.45

Calls 3

_validate_cube_accessMethod · 0.95
infoMethod · 0.65
get_user_cubesMethod · 0.45

Tested by 14

unitFromSeedFunction · 0.36
vectorForFunction · 0.36
_make_add_reqFunction · 0.36
tearDownMethod · 0.36
test_type_conversionMethod · 0.36
update_nodeMethod · 0.36
test_updateMethod · 0.36
test_update_dictMethod · 0.36
test_update_memoryMethod · 0.36