1616 Predicate ,
1717 SearchEntitiesResult ,
1818 SearchRelationshipsResult ,
19- Triple ,
2019)
2120
2221
@@ -50,57 +49,60 @@ def add_client(self, client: GraphClient) -> None:
5049 """
5150 self .graph = client
5251
53- def execute_operation (self , operation : str ) -> str :
52+ def execute_operation (self , operation : str , brain_id : str = "default" ) -> str :
5453 """
5554 Execute a generic graph operation.
5655 """
5756 try :
58- return self .graph .execute_operation (operation )
57+ return self .graph .execute_operation (operation , brain_id )
5958 except Exception as e : # pylint: disable=broad-exception-caught
6059 print (f"Error executing graph operation: { e } - { operation } " )
6160 return f"Error executing graph operation: { e } "
6261
6362 def add_nodes (
6463 self ,
6564 nodes : list [Node ],
65+ brain_id : str = "default" ,
6666 identification_params : Optional [dict ] = None ,
6767 metadata : Optional [dict ] = None ,
68- database : Optional [str ] = None ,
6968 ) -> list [Node ] | str :
7069 """
7170 Add nodes to the graph.
7271 """
73- return self .graph .add_nodes (nodes , identification_params , metadata , database )
72+ return self .graph .add_nodes (nodes , brain_id , identification_params , metadata )
7473
7574 def add_relationship (
7675 self ,
7776 subject : Node ,
7877 predicate : Predicate ,
7978 to_object : Node ,
79+ brain_id : str = "default" ,
8080 ) -> str :
8181 """
8282 Add a relationship between two nodes to the graph.
8383 """
84- return self .graph .add_relationship (subject , predicate , to_object )
84+ return self .graph .add_relationship (subject , predicate , to_object , brain_id )
8585
8686 def search_graph (
8787 self ,
8888 nodes : list [Node ],
89+ brain_id : str = "default" ,
8990 ) -> list [Node ]:
9091 """
9192 Search the graph for nodes and 1 degree relationships.
9293 """
93- return self .graph .search_graph (nodes )
94+ return self .graph .search_graph (nodes , brain_id )
9495
95- def node_text_search (self , text : str ) -> list [Node ]:
96+ def node_text_search (self , text : str , brain_id : str = "default" ) -> list [Node ]:
9697 """
9798 Search the graph for nodes by partial text match into the name of the nodes.
9899 """
99- return self .graph .node_text_search (text )
100+ return self .graph .node_text_search (text , brain_id )
100101
101102 def get_nodes_by_uuid (
102103 self ,
103104 uuids : list [str ],
105+ brain_id : str = "default" ,
104106 with_relationships : Optional [bool ] = False ,
105107 relationships_depth : Optional [int ] = 1 ,
106108 relationships_type : Optional [list [str ]] = None ,
@@ -111,80 +113,83 @@ def get_nodes_by_uuid(
111113 """
112114 return self .graph .get_nodes_by_uuid (
113115 uuids ,
116+ brain_id ,
114117 with_relationships ,
115118 relationships_depth ,
116119 relationships_type ,
117120 preferred_labels ,
118121 )
119122
120- def get_graph_entities (self ) -> list [str ]:
123+ def get_graph_entities (self , brain_id : str = "default" ) -> list [str ]:
121124 """
122125 Get the entities of the graph.
123126 """
124- return self .graph .get_graph_entities ()
127+ return self .graph .get_graph_entities (brain_id )
125128
126- def get_graph_relationships (self ) -> list [str ]:
129+ def get_graph_relationships (self , brain_id : str = "default" ) -> list [str ]:
127130 """
128131 Get the relationships of the graph.
129132 """
130- return self .graph .get_graph_relationships ()
133+ return self .graph .get_graph_relationships (brain_id )
131134
132- def get_graph_property_keys (self ) -> list [str ]:
135+ def get_graph_property_keys (self , brain_id : str = "default" ) -> list [str ]:
133136 """
134137 Get the property keys of the graph.
135138 """
136- return self .graph .get_graph_property_keys ()
139+ return self .graph .get_graph_property_keys (brain_id )
137140
138- def get_by_uuid (self , uuid : str ) -> Node :
141+ def get_by_uuid (self , uuid : str , brain_id : str = "default" ) -> Node :
139142 """
140143 Get a node by its UUID.
141144 """
142- return self .graph .get_by_uuid (uuid )
145+ return self .graph .get_by_uuid (uuid , brain_id )
143146
144- def get_by_uuids (self , uuids : list [str ]) -> list [Node ]:
147+ def get_by_uuids (self , uuids : list [str ], brain_id : str = "default" ) -> list [Node ]:
145148 """
146149 Get nodes by their UUIDs.
147150 """
148- return self .graph .get_by_uuids (uuids )
151+ return self .graph .get_by_uuids (uuids , brain_id )
149152
150153 def get_by_identification_params (
151154 self ,
152155 identification_params : IdentificationParams ,
156+ brain_id : str = "default" ,
153157 entity_types : Optional [list [str ]] = None ,
154158 ) -> Node :
155159 """
156160 Get a node by its identification params and entity types.
157161 """
158162 return self .graph .get_by_identification_params (
159- identification_params , entity_types
163+ identification_params , brain_id , entity_types
160164 )
161165
162166 def get_neighbors (
163- self , node : Node , limit : int
167+ self , node : Node , limit : int , brain_id : str = "default"
164168 ) -> list [Tuple [Node , Predicate , Node ]]:
165169 """
166170 Get the neighbors of a node.
167171 """
168- return self .graph .get_neighbors (node , limit )
172+ return self .graph .get_neighbors (node , limit , brain_id )
169173
170174 def get_node_with_rel_by_uuid (
171- self , rel_ids_with_node_ids : list [tuple [str , str ]]
175+ self , rel_ids_with_node_ids : list [tuple [str , str ]], brain_id : str = "default"
172176 ) -> list [dict ]:
173177 """
174178 Get the node with the relationships by their UUIDs.
175179 """
176- return self .graph .get_node_with_rel_by_uuid (rel_ids_with_node_ids )
180+ return self .graph .get_node_with_rel_by_uuid (rel_ids_with_node_ids , brain_id )
177181
178182 def get_neighbor_node_tuples (
179- self , a_uuid : str , b_uuids : list [str ]
183+ self , a_uuid : str , b_uuids : list [str ], brain_id : str = "default"
180184 ) -> list [Tuple [Node , Predicate , Node ]]:
181185 """
182186 Get the neighbor node tuples by their UUIDs.
183187 """
184- return self .graph .get_neighbor_node_tuples (a_uuid , b_uuids )
188+ return self .graph .get_neighbor_node_tuples (a_uuid , b_uuids , brain_id )
185189
186190 def get_connected_nodes (
187191 self ,
192+ brain_id : str = "default" ,
188193 node : Optional [Node ] = None ,
189194 uuids : Optional [list [str ]] = None ,
190195 limit : Optional [int ] = 10 ,
@@ -194,11 +199,12 @@ def get_connected_nodes(
194199 Get the connected nodes by their UUIDs.
195200 """
196201 return self .graph .get_connected_nodes (
197- node = node , uuids = uuids , limit = limit , with_labels = with_labels
202+ brain_id , node = node , uuids = uuids , limit = limit , with_labels = with_labels
198203 )
199204
200205 def search_relationships (
201206 self ,
207+ brain_id : str = "default" ,
202208 limit : int = 10 ,
203209 skip : int = 0 ,
204210 relationship_types : Optional [list [str ]] = None ,
@@ -213,6 +219,7 @@ def search_relationships(
213219 relationship_uuids = []
214220 # TODO: semantic search + src/core/agents/tools/kg_agent/KGAgentAddTripletsTool.py:165
215221 return self .graph .search_relationships (
222+ brain_id ,
216223 limit ,
217224 skip ,
218225 relationship_types ,
@@ -225,6 +232,7 @@ def search_relationships(
225232
226233 def search_entities (
227234 self ,
235+ brain_id : str = "default" ,
228236 limit : int = 10 ,
229237 skip : int = 0 ,
230238 node_labels : Optional [list [str ]] = None ,
@@ -236,7 +244,7 @@ def search_entities(
236244 node_uuids = []
237245 # TODO: semantic search
238246 return self .graph .search_entities (
239- limit , skip , node_labels , node_uuids , query_text
247+ brain_id , limit , skip , node_labels , node_uuids , query_text
240248 )
241249
242250
0 commit comments