File tree Expand file tree Collapse file tree 3 files changed +7
-18
lines changed Expand file tree Collapse file tree 3 files changed +7
-18
lines changed Original file line number Diff line number Diff line change 1+
12"""
23PDFScraperGraph Module
34"""
910
1011from ..nodes import (
1112 FetchNode ,
12- RAGNode ,
1313 GenerateAnswerPDFNode
1414)
1515
@@ -63,14 +63,7 @@ def _create_graph(self) -> BaseGraph:
6363 input = 'pdf | pdf_dir' ,
6464 output = ["doc" ],
6565 )
66- rag_node = RAGNode (
67- input = "user_prompt & doc" ,
68- output = ["relevant_chunks" ],
69- node_config = {
70- "llm_model" : self .llm_model ,
71- "embedder_model" : self .embedder_model
72- }
73- )
66+
7467 generate_answer_node_pdf = GenerateAnswerPDFNode (
7568 input = "user_prompt & (relevant_chunks | doc)" ,
7669 output = ["answer" ],
@@ -83,12 +76,10 @@ def _create_graph(self) -> BaseGraph:
8376 return BaseGraph (
8477 nodes = [
8578 fetch_node ,
86- rag_node ,
8779 generate_answer_node_pdf ,
8880 ],
8981 edges = [
90- (fetch_node , rag_node ),
91- (rag_node , generate_answer_node_pdf )
82+ (fetch_node , generate_answer_node_pdf )
9283 ],
9384 entry_point = fetch_node
9485 )
@@ -104,4 +95,4 @@ def run(self) -> str:
10495 inputs = {"user_prompt" : self .prompt , self .input_key : self .source }
10596 self .final_state , self .execution_info = self .graph .execute (inputs )
10697
107- return self .final_state .get ("answer" , "No answer found." )
98+ return self .final_state .get ("answer" , "No answer found." )
Original file line number Diff line number Diff line change @@ -117,4 +117,4 @@ def run(self) -> str:
117117 inputs = {"user_prompt" : self .prompt , self .input_key : self .source }
118118 self .final_state , self .execution_info = self .graph .execute (inputs )
119119
120- return self .final_state .get ("answer" , "No answer found." )
120+ return self .final_state .get ("answer" , "No answer found." )
Original file line number Diff line number Diff line change @@ -95,9 +95,7 @@ def execute(self, state):
9595 output_parser = JsonOutputParser ()
9696 format_instructions = output_parser .get_format_instructions ()
9797
98-
9998 chains_dict = {}
100-
10199 # Use tqdm to add progress bar
102100 for i , chunk in enumerate (
103101 tqdm (doc , desc = "Processing chunks" , disable = not self .verbose )
@@ -107,7 +105,7 @@ def execute(self, state):
107105 template = template_no_chunks_pdf ,
108106 input_variables = ["question" ],
109107 partial_variables = {
110- "context" : chunk . page_content ,
108+ "context" :chunk ,
111109 "format_instructions" : format_instructions ,
112110 },
113111 )
@@ -116,7 +114,7 @@ def execute(self, state):
116114 template = template_chunks_pdf ,
117115 input_variables = ["question" ],
118116 partial_variables = {
119- "context" : chunk . page_content ,
117+ "context" :chunk ,
120118 "chunk_id" : i + 1 ,
121119 "format_instructions" : format_instructions ,
122120 },
You can’t perform that action at this time.
0 commit comments