dfinol commited on
Commit
4287b9d
·
verified ·
1 Parent(s): d54297d

Update node handling for better error management.

Browse files
Files changed (1) hide show
  1. mindsearch/agent/graph.py +15 -1
mindsearch/agent/graph.py CHANGED
@@ -303,5 +303,19 @@ class ExecutionAction(BaseAction):
303
  ),
304
  stream_state=AgentStatusCode.STREAM_ING,
305
  )
306
- res = [graph.nodes[node.strip().strip('"').strip("'")] for node in node_list]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  return res, graph.nodes, graph.adjacency_list
 
303
  ),
304
  stream_state=AgentStatusCode.STREAM_ING,
305
  )
306
+ #res = [graph.nodes[node.strip().strip('"').strip("'")] for node in node_list]
307
+ res = []
308
+ missing_nodes = []
309
+ for node in node_list:
310
+ node_key = node.strip().strip('"').strip("'")
311
+ if node_key in graph.nodes:
312
+ res.append(graph.nodes[node_key])
313
+ else:
314
+ missing_nodes.append(node_key)
315
+
316
+ if missing_nodes:
317
+ print(f"Warning: The following nodes are missing: {missing_nodes}")
318
+ # Optionally, raise an exception or handle missing nodes as needed
319
+ raise KeyError(f"Missing nodes in graph: {missing_nodes}")
320
+
321
  return res, graph.nodes, graph.adjacency_list