Skip to content

Commit db4b7cd

Browse files
committed
refactoring of the code
1 parent c2179ab commit db4b7cd

16 files changed

+24
-12
lines changed

scrapegraphai/graphs/abstract_graph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ def _create_llm(self, llm_config: dict) -> object:
128128
if requests_per_second is not None:
129129
with warnings.catch_warnings():
130130
warnings.simplefilter("ignore")
131-
llm_params["rate_limiter"] = InMemoryRateLimiter(requests_per_second=requests_per_second)
131+
llm_params["rate_limiter"] = InMemoryRateLimiter(
132+
requests_per_second=requests_per_second)
132133
if max_retries is not None:
133134
llm_params["max_retries"] = max_retries
134135

scrapegraphai/graphs/base_graph.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(self, nodes: list, edges: list, entry_point: str,
5959
# raise a warning if the entry point is not the first node in the list
6060
warnings.warn(
6161
"Careful! The entry point node is different from the first node in the graph.")
62-
62+
6363
self._set_conditional_node_edges()
6464

6565
# Burr configuration
@@ -89,11 +89,9 @@ def _set_conditional_node_edges(self):
8989
"""
9090
for node in self.nodes:
9191
if node.node_type == 'conditional_node':
92-
# Find outgoing edges from this ConditionalNode
9392
outgoing_edges = [(from_node, to_node) for from_node, to_node in self.raw_edges if from_node.node_name == node.node_name]
9493
if len(outgoing_edges) != 2:
9594
raise ValueError(f"ConditionalNode '{node.node_name}' must have exactly two outgoing edges.")
96-
# Assign true_node_name and false_node_name
9795
node.true_node_name = outgoing_edges[0][1].node_name
9896
node.false_node_name = outgoing_edges[1][1].node_name
9997

scrapegraphai/graphs/code_generator_graph.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def _create_graph(self) -> BaseGraph:
9999
"schema": self.schema,
100100
}
101101
)
102+
102103
prompt_refier_node = PromptRefinerNode(
103104
input="user_prompt",
104105
output=["refined_prompt"],
@@ -108,6 +109,7 @@ def _create_graph(self) -> BaseGraph:
108109
"schema": self.schema
109110
}
110111
)
112+
111113
html_analyzer_node = HtmlAnalyzerNode(
112114
input="refined_prompt & original_html",
113115
output=["html_info", "reduced_html"],
@@ -118,6 +120,7 @@ def _create_graph(self) -> BaseGraph:
118120
"reduction": self.config.get("reduction", 0)
119121
}
120122
)
123+
121124
generate_code_node = GenerateCodeNode(
122125
input="user_prompt & refined_prompt & html_info & reduced_html & answer",
123126
output=["generated_code"],

scrapegraphai/graphs/csv_scraper_graph.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def _create_graph(self):
5959
"""
6060
Creates the graph of nodes representing the workflow for web scraping.
6161
"""
62+
6263
fetch_node = FetchNode(
6364
input="csv | csv_dir",
6465
output=["doc"],
@@ -90,6 +91,7 @@ def run(self) -> str:
9091
"""
9192
Executes the web scraping process and returns the answer to the prompt.
9293
"""
94+
9395
inputs = {"user_prompt": self.prompt, self.input_key: self.source}
9496
self.final_state, self.execution_info = self.graph.execute(inputs)
9597

scrapegraphai/graphs/csv_scraper_multi_graph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def run(self) -> str:
9595
Returns:
9696
str: The answer to the prompt.
9797
"""
98+
9899
inputs = {"user_prompt": self.prompt, "jsons": self.source}
99100
self.final_state, self.execution_info = self.graph.execute(inputs)
100101

scrapegraphai/graphs/document_scraper_multi_graph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def run(self) -> str:
9494
Returns:
9595
str: The answer to the prompt.
9696
"""
97+
9798
inputs = {"user_prompt": self.prompt, "xmls": self.source}
9899
self.final_state, self.execution_info = self.graph.execute(inputs)
99100

scrapegraphai/graphs/json_scraper_multi_graph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def run(self) -> str:
9696
Returns:
9797
str: The answer to the prompt.
9898
"""
99+
99100
inputs = {"user_prompt": self.prompt, "jsons": self.source}
100101
self.final_state, self.execution_info = self.graph.execute(inputs)
101102

scrapegraphai/graphs/omni_scraper_graph.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ def _create_graph(self) -> BaseGraph:
6262
Returns:
6363
BaseGraph: A graph instance representing the web scraping workflow.
6464
"""
65+
6566
fetch_node = FetchNode(
6667
input="url | local_dir",
6768
output=["doc"],
6869
node_config={
6970
"loader_kwargs": self.config.get("loader_kwargs", {}),
7071
}
7172
)
73+
7274
parse_node = ParseNode(
7375
input="doc & (url | local_dir)",
7476
output=["parsed_doc", "link_urls", "img_urls"],
@@ -78,6 +80,7 @@ def _create_graph(self) -> BaseGraph:
7880
"llm_model": self.llm_model
7981
}
8082
)
83+
8184
image_to_text_node = ImageToTextNode(
8285
input="img_urls",
8386
output=["img_desc"],

scrapegraphai/graphs/omni_search_graph.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ def _create_graph(self) -> BaseGraph:
5959
BaseGraph: A graph instance representing the web scraping and searching workflow.
6060
"""
6161

62-
# omni_scraper_instance = OmniScraperGraph(
63-
# prompt="",
64-
# source="",
65-
# config=self.copy_config,
66-
# schema=self.copy_schema
67-
# )
68-
6962
search_internet_node = SearchInternetNode(
7063
input="user_prompt",
7164
output=["urls"],
@@ -115,6 +108,7 @@ def run(self) -> str:
115108
Returns:
116109
str: The answer to the prompt.
117110
"""
111+
118112
inputs = {"user_prompt": self.prompt}
119113
self.final_state, self.execution_info = self.graph.execute(inputs)
120114

scrapegraphai/graphs/script_creator_multi_graph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def run(self) -> str:
9393
Returns:
9494
str: The answer to the prompt.
9595
"""
96+
9697
inputs = {"user_prompt": self.prompt, "urls": self.source}
9798
self.final_state, self.execution_info = self.graph.execute(inputs)
9899
return self.final_state.get("merged_script", "Failed to generate the script.")

0 commit comments

Comments
 (0)