Skip to content

Commit b2ebabd

Browse files
committed
Update base_graph.py
1 parent e714a59 commit b2ebabd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scrapegraphai/graphs/base_graph.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Module for creating the base graphs
33
"""
44
import time
5+
import warnings
56
from langchain_community.callbacks import get_openai_callback
67

78

@@ -26,12 +27,19 @@ class BaseGraph:
2627
entry_point (BaseNode): The node instance that represents the entry point of the graph.
2728
"""
2829

29-
def __init__(self, nodes: list, edges: list):
30+
def __init__(self, nodes: list, edges: dict, entry_point: str):
3031
"""
3132
Initializes the graph with nodes, edges, and the entry point.
3233
"""
33-
self.nodes = nodes
34+
35+
self.nodes = {node.node_name: node for node in nodes}
3436
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.")
3543

3644
def _create_edges(self, edges: list) -> dict:
3745
"""

0 commit comments

Comments
 (0)