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
)
| 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, |