MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / add

Method add

methods/mem0/memory/graph_memory.py:49–67  ·  view source on GitHub ↗

Adds data to the graph. Args: data (str): The data to add to the graph. filters (dict): A dictionary containing filters to be applied during the addition.

(self, data, filters)

Source from the content-addressed store, hash-verified

47 self.threshold = 0.7
48
49 def add(self, data, filters):
50 """
51 Adds data to the graph.
52
53 Args:
54 data (str): The data to add to the graph.
55 filters (dict): A dictionary containing filters to be applied during the addition.
56 """
57 entity_type_map = self._retrieve_nodes_from_data(data, filters)
58 to_be_added = self._establish_nodes_relations_from_data(data, filters, entity_type_map)
59 search_output = self._search_graph_db(node_list=list(entity_type_map.keys()), filters=filters)
60 to_be_deleted = self._get_delete_entities_from_search_output(search_output, data, filters)
61
62 # TODO: Batch queries with APOC plugin
63 # TODO: Add more filter support
64 deleted_entities = self._delete_entities(to_be_deleted, filters["user_id"])
65 added_entities = self._add_entities(to_be_added, filters["user_id"], entity_type_map)
66
67 return {"deleted_entities": deleted_entities, "added_entities": added_entities}
68
69 def search(self, query, filters, limit=100):
70 """

Callers

nothing calls this directly

Calls 8

_search_graph_dbMethod · 0.95
_delete_entitiesMethod · 0.95
_add_entitiesMethod · 0.95
listFunction · 0.50
keysMethod · 0.45

Tested by

no test coverage detected