Skip to content

Commit ab71a6b

Browse files
committed
fixed documentation and fetch_text_node
1 parent e29454e commit ab71a6b

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

examples/graph_examples/graph_from_text_example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dotenv import load_dotenv
77
from scrapegraphai.models import OpenAI
88
from scrapegraphai.graphs import BaseGraph
9-
from scrapegraphai.nodes import TextNode, ParseTextNode, GenerateAnswerNode
9+
from scrapegraphai.nodes import FetchTextNode, ParseTextNode, GenerateAnswerNode
1010

1111
load_dotenv()
1212

@@ -25,7 +25,7 @@
2525

2626

2727
# define the nodes for the graph
28-
fetch_html_node = TextNode("load_html")
28+
fetch_html_node = FetchTextNode("load_html")
2929
parse_document_node = ParseTextNode("parse_document")
3030
generate_answer_node = GenerateAnswerNode(model, "generate_answer")
3131

@@ -45,7 +45,7 @@
4545

4646
# execute the graph
4747
inputs = {"user_input": "Give me the name of all the news",
48-
"url": text}
48+
"text": text}
4949
result = graph.execute(inputs)
5050

5151
# get the answer from the result

scrapegraphai/nodes/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
from .rag_node import RAGNode
1010
from .text_to_speech_node import TextToSpeechNode
1111
from .image_to_text_node import ImageToTextNode
12-
from .text_node import TextNode
12+
from .fetch_text_node import FetchTextNode
1313
from .parse_text_node import ParseTextNode

scrapegraphai/nodes/text_node.py renamed to scrapegraphai/nodes/fetch_text_node.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
""" 
2-
Module for TextNode
2+
Module for FetchTextNode
33
"""
44
from .base_node import BaseNode
55

66

7-
class TextNode(BaseNode):
7+
class FetchTextNode(BaseNode):
88
"""
99
A node for loading raw text into the state.
1010
@@ -27,7 +27,7 @@ class TextNode(BaseNode):
2727

2828
def __init__(self, node_name: str):
2929
"""
30-
Initializes the TextNode with a node name.
30+
Initializes the FetchTextNode with a node name.
3131
3232
Args:
3333
node_name (str): The unique name for the node.
@@ -39,7 +39,7 @@ def execute(self, state: dict) -> dict:
3939
Loads raw text content into the state.
4040
4141
Args:
42-
state (dict): The current state, expected to contain a 'url' key
42+
state (dict): The current state, expected to contain a 'text' key
4343
indicating the source of the text.
4444
4545
Returns:
@@ -50,8 +50,8 @@ def execute(self, state: dict) -> dict:
5050
"""
5151
print("---LOADING TEXT CODE---")
5252

53-
if 'url' not in state:
53+
if 'text' not in state:
5454
raise KeyError("The 'url' key is required to load the text.")
5555

56-
state["document"] = state["url"]
56+
state["document"] = state["text"]
5757
return state

scrapegraphai/nodes/parse_text_node.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ def execute(self, state):
4242
4343
Args:
4444
state (dict): Expects the following keys:
45-
* 'document': The HTML content to parse.
46-
* 'tags' (optional): A list of HTML tags to target for extraction.
45+
'document': The HTML content to parse.
46+
'tags' (optional): A list of HTML tags to target for extraction.
4747
4848
Returns:
4949
dict: Updated state with the following:
50-
* 'parsed_document': The extracted content
50+
'parsed_document': The extracted content
5151
(or the original document if no tags were provided).
52-
* 'document_chunks': The original document split into chunks (using RecursiveCharacterTextSplitter)
52+
'document_chunks': The original document split into chunka
53+
(using RecursiveCharacterTextSplitter)
5354
for larger documents.
5455
5556
Raises:

0 commit comments

Comments
 (0)