Skip to content

Commit 444a13a

Browse files
committed
Created set_common_params function
1 parent 2178485 commit 444a13a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

scrapegraphai/graphs/abstract_graph.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,30 @@ def __init__(self, prompt: str, config: dict, source: Optional[str] = None):
4646
self.embedder_model = self.llm_model if "embeddings" not in config else self._create_llm(
4747
config["embeddings"])
4848

49+
# Create the graph
50+
self.graph = self._create_graph()
51+
self.final_state = None
52+
self.execution_info = None
53+
4954
# Set common configuration parameters
5055
self.verbose = True if config is None else config.get("verbose", False)
5156
self.headless = True if config is None else config.get(
5257
"headless", True)
58+
common_params = {"verbose": self.verbose,
59+
"headless": self.headless}
60+
self.set_common_params(common_params)
5361

54-
# Create the graph
55-
self.graph = self._create_graph()
56-
self.final_state = None
57-
self.execution_info = None
5862

63+
def set_common_params(self, params: dict):
64+
"""
65+
Pass parameters to every node in the graph unless otherwise defined in the graph.
66+
67+
Args:
68+
params (dict): Common parameters and their values.
69+
"""
70+
71+
for node in self.graph.nodes:
72+
node.update_config(params)
5973

6074
def _set_model_token(self, llm):
6175

0 commit comments

Comments
 (0)