File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 2
2
Module for creating the base graphs
3
3
"""
4
4
import time
5
+ import warnings
5
6
from langchain_community .callbacks import get_openai_callback
6
7
7
8
@@ -26,12 +27,19 @@ class BaseGraph:
26
27
entry_point (BaseNode): The node instance that represents the entry point of the graph.
27
28
"""
28
29
29
- def __init__ (self , nodes : list , edges : list ):
30
+ def __init__ (self , nodes : list , edges : dict , entry_point : str ):
30
31
"""
31
32
Initializes the graph with nodes, edges, and the entry point.
32
33
"""
33
- self .nodes = nodes
34
+
35
+ self .nodes = {node .node_name : node for node in nodes }
34
36
self .edges = self ._create_edges (edges )
37
+ self .entry_point = entry_point .node_name
38
+
39
+ if nodes [0 ].node_name != entry_point .node_name :
40
+ # raise a warning if the entry point is not the first node in the list
41
+ warnings .warn (
42
+ "Careful! The entry point node is different from the first node if the graph." )
35
43
36
44
def _create_edges (self , edges : list ) -> dict :
37
45
"""
You can’t perform that action at this time.
0 commit comments