Skip to content

Commit 582c99d

Browse files
committed
refactoring of the classes of constructors
1 parent 9d6fcf7 commit 582c99d

6 files changed

+30
-13
lines changed

scrapegraphai/nodes/fetch_html_node.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ class FetchHTMLNode(BaseNode):
3333
to succeed.
3434
"""
3535

36-
def __init__(self, node_name: str, node_type: str = "node"):
36+
def __init__(self, node_name: str, node_type: str = "fetch_node"):
3737
"""
3838
Initializes the FetchHTMLNode with a node name and node type.
39+
Arguments:
40+
node_name (str): name of the node
41+
node_type (str, optional): type of the node
3942
"""
4043
super().__init__(node_name, node_type)
4144

@@ -54,6 +57,7 @@ def execute(self, state: dict) -> dict:
5457
KeyError: If the 'url' key is not found in the state, indicating that the
5558
necessary information to perform the operation is missing.
5659
"""
60+
print("---FETCHING HTML CODE---")
5761
try:
5862
url = state["url"]
5963
except KeyError as e:

scrapegraphai/nodes/generate_answer_node.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ class GenerateAnswerNode(BaseNode):
3232
updating the state with the generated answer under the 'answer' key.
3333
"""
3434

35-
def __init__(self, llm, node_name: str = "GenerateAnswerNode"):
35+
def __init__(self, llm, node_name: str, node_type: str = "GenerateAnswerNode"):
3636
"""
3737
Initializes the GenerateAnswerNode with a language model client and a node name.
38+
Args:
39+
llm (OpenAIImageToText): An instance of the OpenAIImageToText class.
40+
node_name (str): name of the node
41+
node_type (str, optional): type of the node
3842
"""
39-
super().__init__(node_name, "node")
43+
super().__init__(node_name, node_type)
4044
self.llm = llm
4145

4246
def execute(self, state: dict) -> dict:
@@ -58,7 +62,7 @@ def execute(self, state: dict) -> dict:
5862
that the necessary information for generating an answer is missing.
5963
"""
6064

61-
print("---GENERATE ANSWER---")
65+
print("---GENERATING ANSWER---")
6266
try:
6367
user_input = state["user_input"]
6468
document = state["document"]

scrapegraphai/nodes/get_probable_tags_node.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ class GetProbableTagsNode(BaseNode):
2929
probable HTML tags, updating the state with these tags under the 'tags' key.
3030
"""
3131

32-
def __init__(self, llm, node_name: str = "GetProbableTagsNode"):
32+
def __init__(self, llm, node_name: str, node_type: str = "GetPropbableTagsNode"):
3333
"""
3434
Initializes the GetProbableTagsNode with a language model client and a node name.
35+
Args:
36+
llm (OpenAIImageToText): An instance of the OpenAIImageToText class.
37+
node_name (str): name of the node
38+
node_type (str, optional): type of the node
3539
"""
36-
super().__init__(node_name, "node")
40+
super().__init__(node_name, node_type)
3741
self.llm = llm
3842

3943
def execute(self, state: dict):
@@ -54,7 +58,7 @@ def execute(self, state: dict):
5458
necessary information for generating tag predictions is missing.
5559
"""
5660

57-
print("---GET PROBABLE TAGS---")
61+
print("---GETTING PROBABLE TAGS---")
5862
try:
5963
user_input = state["user_input"]
6064
url = state["url"]

scrapegraphai/nodes/image_to_text_node.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from .base_node import BaseNode
66

7+
78
class ImageToTextNode(BaseNode):
89
"""
910
A class representing a node that processes an image and returns the text description.
@@ -15,13 +16,14 @@ class ImageToTextNode(BaseNode):
1516
execute(state, url): Execute the node's logic and return the updated state.
1617
"""
1718

18-
def __init__(self, llm, node_name: str = "ParseImageToText"):
19+
def __init__(self, llm, node_name: str, node_type: str = "ImageToTextNode"):
1920
"""
2021
Initializes an instance of the ImageToTextNode class.
2122
2223
Args:
2324
llm (OpenAIImageToText): An instance of the OpenAIImageToText class.
24-
node_name (str, optional): The name of the node. Defaults to "ParseImageToText".
25+
node_name (str): name of the node
26+
node_type (str, optional): type of the node
2527
"""
2628
super().__init__(node_name, "node")
2729
self.llm = llm

scrapegraphai/nodes/parse_html_node.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ class ParseHTMLNode(BaseNode):
2727
the specified tags, if provided, and updates the state with the parsed content.
2828
"""
2929

30-
def __init__(self, node_name="ParseHTMLNode"):
30+
def __init__(self, node_name: str, node_type: str = "ParseHTMLNode"):
3131
"""
3232
Initializes the ParseHTMLNode with a node name.
33+
Args:
34+
node_name (str): name of the node
35+
node_type (str, optional): type of the node
3336
"""
34-
super().__init__(node_name, "node")
37+
super().__init__(node_name, node_type)
3538

3639
def execute(self, state):
3740
"""
@@ -53,7 +56,7 @@ def execute(self, state):
5356
information for parsing is missing.
5457
"""
5558

56-
print("---PARSE HTML DOCUMENT---")
59+
print("---PARSING HTML DOCUMENT---")
5760
try:
5861
document = state["document"]
5962
except KeyError as e:

scrapegraphai/nodes/rag_node.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def execute(self, state):
6363
information for parsing is missing.
6464
"""
6565

66-
print("---PARSE HTML DOCUMENT---")
66+
print("---PARSING HTML DOCUMENT---")
6767
try:
6868
user_input = state["user_input"]
6969
document = state["document"]

0 commit comments

Comments
 (0)