Skip to content

Commit

Permalink
feat: removed rag node
Browse files Browse the repository at this point in the history
  • Loading branch information
VinciGit00 committed May 31, 2024
1 parent 6d1d91a commit 930f673
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
17 changes: 4 additions & 13 deletions scrapegraphai/graphs/pdf_scraper_graph.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

"""
PDFScraperGraph Module
"""
Expand All @@ -9,7 +10,6 @@

from ..nodes import (
FetchNode,
RAGNode,
GenerateAnswerPDFNode
)

Expand Down Expand Up @@ -63,14 +63,7 @@ def _create_graph(self) -> BaseGraph:
input='pdf | pdf_dir',
output=["doc"],
)
rag_node = RAGNode(
input="user_prompt & doc",
output=["relevant_chunks"],
node_config={
"llm_model": self.llm_model,
"embedder_model": self.embedder_model
}
)

generate_answer_node_pdf = GenerateAnswerPDFNode(
input="user_prompt & (relevant_chunks | doc)",
output=["answer"],
Expand All @@ -83,12 +76,10 @@ def _create_graph(self) -> BaseGraph:
return BaseGraph(
nodes=[
fetch_node,
rag_node,
generate_answer_node_pdf,
],
edges=[
(fetch_node, rag_node),
(rag_node, generate_answer_node_pdf)
(fetch_node, generate_answer_node_pdf)
],
entry_point=fetch_node
)
Expand All @@ -104,4 +95,4 @@ def run(self) -> str:
inputs = {"user_prompt": self.prompt, self.input_key: self.source}
self.final_state, self.execution_info = self.graph.execute(inputs)

return self.final_state.get("answer", "No answer found.")
return self.final_state.get("answer", "No answer found.")
2 changes: 1 addition & 1 deletion scrapegraphai/graphs/smart_scraper_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ def run(self) -> str:
inputs = {"user_prompt": self.prompt, self.input_key: self.source}
self.final_state, self.execution_info = self.graph.execute(inputs)

return self.final_state.get("answer", "No answer found.")
return self.final_state.get("answer", "No answer found.")
6 changes: 2 additions & 4 deletions scrapegraphai/nodes/generate_answer_pdf_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ def execute(self, state):
output_parser = JsonOutputParser()
format_instructions = output_parser.get_format_instructions()


chains_dict = {}

# Use tqdm to add progress bar
for i, chunk in enumerate(
tqdm(doc, desc="Processing chunks", disable=not self.verbose)
Expand All @@ -107,7 +105,7 @@ def execute(self, state):
template=template_no_chunks_pdf,
input_variables=["question"],
partial_variables={
"context": chunk.page_content,
"context":chunk,
"format_instructions": format_instructions,
},
)
Expand All @@ -116,7 +114,7 @@ def execute(self, state):
template=template_chunks_pdf,
input_variables=["question"],
partial_variables={
"context": chunk.page_content,
"context":chunk,
"chunk_id": i + 1,
"format_instructions": format_instructions,
},
Expand Down

0 comments on commit 930f673

Please sign in to comment.