MCPcopy Create free account
hub / github.com/BAI-LAB/MemoryOS / update_user_profile

Method update_user_profile

memoryos-pypi/long_term.py:24–40  ·  view source on GitHub ↗
(self, user_id, new_data, merge=True)

Source from the content-addressed store, hash-verified

22 self.load()
23
24 def update_user_profile(self, user_id, new_data, merge=True):
25 if merge and user_id in self.user_profiles and self.user_profiles[user_id].get("data"): # Check if data exists
26 current_data = self.user_profiles[user_id]["data"]
27 if isinstance(current_data, str) and isinstance(new_data, str):
28 updated_data = f"{current_data}\n\n--- Updated on {get_timestamp()} ---\n{new_data}"
29 else: # Fallback to overwrite if types are not strings or for more complex merge
30 updated_data = new_data
31 else:
32 # If merge=False or no existing data, replace with new data
33 updated_data = new_data
34
35 self.user_profiles[user_id] = {
36 "data": updated_data,
37 "last_updated": get_timestamp()
38 }
39 print(f"LongTermMemory: Updated user profile for {user_id} (merge={merge}).")
40 self.save()
41
42 def get_raw_user_profile(self, user_id):
43 return self.user_profiles.get(user_id, {}).get("data", "None") # Return "None" string if not found

Calls 2

saveMethod · 0.95
get_timestampFunction · 0.90

Tested by

no test coverage detected