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

Method get_all

src/memos/mem_os/core.py:959–995  ·  view source on GitHub ↗

Get all textual memories from a MemCube. Args: mem_cube_id (str, optional): The identifier of the MemCube to get the memories from. If None, all MemCube for the user is used. user_id (str, optional): The identifier of the user to get the memo

(
        self, mem_cube_id: str | None = None, user_id: str | None = None
    )

Source from the content-addressed store, hash-verified

957 return self.mem_cubes[mem_cube_id].text_mem.get(memory_id)
958
959 def get_all(
960 self, mem_cube_id: str | None = None, user_id: str | None = None
961 ) -> MOSSearchResult:
962 """
963 Get all textual memories from a MemCube.
964
965 Args:
966 mem_cube_id (str, optional): The identifier of the MemCube to get the memories from.
967 If None, all MemCube for the user is used.
968 user_id (str, optional): The identifier of the user to get the memories from.
969 If None, the default user is used.
970
971 Returns:
972 MemoryResult: A dictionary containing the search results.
973 """
974 result: MOSSearchResult = {"para_mem": [], "act_mem": [], "text_mem": []}
975 target_user_id = user_id if user_id is not None else self.user_id
976 # Validate user has access to this cube
977 if mem_cube_id is None:
978 # Try to find a default cube for the user
979 accessible_cubes = self.user_manager.get_user_cubes(target_user_id)
980 if not accessible_cubes:
981 raise ValueError(
982 f"No accessible cubes found for user '{target_user_id}'. Please register a cube first."
983 )
984 mem_cube_id = accessible_cubes[0].cube_id # TODO not only first
985 else:
986 self._validate_cube_access(target_user_id, mem_cube_id)
987 if self.config.enable_textual_memory and self.mem_cubes[mem_cube_id].text_mem:
988 result["text_mem"].append(
989 {"cube_id": mem_cube_id, "memories": self.mem_cubes[mem_cube_id].text_mem.get_all()}
990 )
991 if self.config.enable_activation_memory and self.mem_cubes[mem_cube_id].act_mem:
992 result["act_mem"].append(
993 {"cube_id": mem_cube_id, "memories": self.mem_cubes[mem_cube_id].act_mem.get_all()}
994 )
995 return result
996
997 def update(
998 self,

Callers 15

test_get_all_memoriesMethod · 0.95
chatMethod · 0.45
chatMethod · 0.45
handle_get_all_memoriesFunction · 0.45
handle_get_memoriesFunction · 0.45
runMethod · 0.45
test_get_allMethod · 0.45
test_get_all_memoriesMethod · 0.45
test_delete_and_get_allFunction · 0.45

Calls 2

_validate_cube_accessMethod · 0.95
get_user_cubesMethod · 0.45

Tested by 6

test_get_all_memoriesMethod · 0.76
chatMethod · 0.36
test_get_allMethod · 0.36
test_get_all_memoriesMethod · 0.36
test_delete_and_get_allFunction · 0.36
test_get_allFunction · 0.36