Skip to content

Commit

Permalink
add rag node
Browse files Browse the repository at this point in the history
  • Loading branch information
VinciGit00 committed Jun 1, 2024
1 parent 5bda918 commit fff1232
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions scrapegraphai/graphs/pdf_scraper_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

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

Expand Down Expand Up @@ -63,7 +64,15 @@ def _create_graph(self) -> BaseGraph:
input='pdf | pdf_dir',
output=["doc"],
)


rag_node = RAGNode(
input="user_prompt & (parsed_doc | 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 @@ -76,10 +85,12 @@ def _create_graph(self) -> BaseGraph:
return BaseGraph(
nodes=[
fetch_node,
rag_node,
generate_answer_node_pdf,
],
edges=[
(fetch_node, generate_answer_node_pdf)
(fetch_node, rag_node),
(rag_node, generate_answer_node_pdf)
],
entry_point=fetch_node
)
Expand All @@ -95,4 +106,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.")

0 comments on commit fff1232

Please sign in to comment.