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

Method add_memory

memoryos-pypi/memoryos.py:222–244  ·  view source on GitHub ↗

Adds a new QA pair (memory) to the system. meta_data is not used in the current refactoring but kept for future use.

(self, user_input: str, agent_response: str, timestamp: str = None, meta_data: dict = None)

Source from the content-addressed store, hash-verified

220 pass # No action if below threshold
221
222 def add_memory(self, user_input: str, agent_response: str, timestamp: str = None, meta_data: dict = None):
223 """
224 Adds a new QA pair (memory) to the system.
225 meta_data is not used in the current refactoring but kept for future use.
226 """
227 if not timestamp:
228 timestamp = get_timestamp()
229
230 qa_pair = {
231 "user_input": user_input,
232 "agent_response": agent_response,
233 "timestamp": timestamp
234 # meta_data can be added here if it needs to be stored with the QA pair
235 }
236 self.short_term_memory.add_qa_pair(qa_pair)
237 print(f"Memoryos: Added QA to short-term. User: {user_input[:30]}...")
238
239 if self.short_term_memory.is_full():
240 print("Memoryos: Short-term memory full. Processing to mid-term.")
241 self.updater.process_short_term_to_mid_term()
242
243 # After any memory addition that might impact mid-term, check for profile updates
244 self._trigger_profile_and_knowledge_update_if_needed()
245
246 def get_response(self, query: str, relationship_with_user="friend", style_hint="", user_conversation_meta_data: dict = None) -> str:
247 """

Callers 2

simple_demoFunction · 0.95
get_responseMethod · 0.95

Calls 5

get_timestampFunction · 0.90
add_qa_pairMethod · 0.45
is_fullMethod · 0.45

Tested by 1

simple_demoFunction · 0.76