9
9
from ..utils .save_code_to_file import save_code_to_file
10
10
from ..nodes import (
11
11
FetchNodeLevelK ,
12
- ParseNodeDepthK
12
+ ParseNodeDepthK ,
13
+ DescriptionNode ,
14
+ RAGNode ,
15
+ GenerateAnswerNodeKLevel
13
16
)
14
17
15
18
class DepthSearchGraph (AbstractGraph ):
16
19
"""
17
- CodeGeneratorGraph is a script generator pipeline that generates the function extract_data(html: str) -> dict() for
18
- extracting the wanted information from a HTML page. The code generated is in Python and uses the library BeautifulSoup.
20
+ CodeGeneratorGraph is a script generator pipeline that generates
21
+ the function extract_data(html: str) -> dict() for
22
+ extracting the wanted information from a HTML page. The
23
+ code generated is in Python and uses the library BeautifulSoup.
19
24
It requires a user prompt, a source URL, and an output schema.
20
25
21
26
Attributes:
@@ -60,7 +65,7 @@ def _create_graph(self) -> BaseGraph:
60
65
BaseGraph: A graph instance representing the web scraping workflow.
61
66
"""
62
67
63
- fetch_node = FetchNodeLevelK (
68
+ fetch_node_k = FetchNodeLevelK (
64
69
input = "url| local_dir" ,
65
70
output = ["docs" ],
66
71
node_config = {
@@ -72,24 +77,61 @@ def _create_graph(self) -> BaseGraph:
72
77
"only_inside_links" : self .config .get ("only_inside_links" , False )
73
78
}
74
79
)
75
-
76
- parse_node = ParseNodeDepthK (
80
+
81
+ parse_node_k = ParseNodeDepthK (
77
82
input = "docs" ,
78
83
output = ["docs" ],
79
84
node_config = {
80
85
"verbose" : self .config .get ("verbose" , False )
81
86
}
82
87
)
83
88
89
+ description_node = DescriptionNode (
90
+ input = "docs" ,
91
+ output = ["docs" ],
92
+ node_config = {
93
+ "llm_model" : self .llm_model ,
94
+ "verbose" : self .config .get ("verbose" , False ),
95
+ "cache_path" : self .config .get ("cache_path" , False )
96
+ }
97
+ )
98
+
99
+ rag_node = RAGNode (
100
+ input = "docs" ,
101
+ output = ["vectorial_db" ],
102
+ node_config = {
103
+ "llm_model" : self .llm_model ,
104
+ "embedder_model" : self .config .get ("embedder_model" , False ),
105
+ "verbose" : self .config .get ("verbose" , False ),
106
+ }
107
+ )
108
+
109
+ generate_answer_k = GenerateAnswerNodeKLevel (
110
+ input = "vectorial_db" ,
111
+ output = ["answer" ],
112
+ node_config = {
113
+ "llm_model" : self .llm_model ,
114
+ "embedder_model" : self .config .get ("embedder_model" , False ),
115
+ "verbose" : self .config .get ("verbose" , False ),
116
+ }
117
+
118
+ )
119
+
84
120
return BaseGraph (
85
121
nodes = [
86
- fetch_node ,
87
- parse_node
122
+ fetch_node_k ,
123
+ parse_node_k ,
124
+ description_node ,
125
+ rag_node ,
126
+ generate_answer_k
88
127
],
89
128
edges = [
90
- (fetch_node , parse_node ),
129
+ (fetch_node_k , parse_node_k ),
130
+ (parse_node_k , description_node ),
131
+ (description_node , rag_node ),
132
+ (rag_node , generate_answer_k )
91
133
],
92
- entry_point = fetch_node ,
134
+ entry_point = fetch_node_k ,
93
135
graph_name = self .__class__ .__name__
94
136
)
95
137
0 commit comments