Skip to content

Commit

Permalink
fix: generate answer node
Browse files Browse the repository at this point in the history
  • Loading branch information
VinciGit00 committed Oct 13, 2024
1 parent 54b37bb commit 431b209
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scrapegraphai/nodes/generate_answer_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(
self.is_md_scraper = node_config.get("is_md_scraper", False)
self.additional_info = node_config.get("additional_info")

async def execute(self, state: dict) -> dict:
def execute(self, state: dict) -> dict:
"""
Executes the GenerateAnswerNode.
Expand Down Expand Up @@ -123,7 +123,7 @@ async def execute(self, state: dict) -> dict:
chain = prompt | self.llm_model
if output_parser:
chain = chain | output_parser
answer = await chain.ainvoke({"question": user_prompt})
answer = chain.invoke({"question": user_prompt})

state.update({self.output[0]: answer})
return state
Expand All @@ -143,7 +143,7 @@ async def execute(self, state: dict) -> dict:
chains_dict[chain_name] = chains_dict[chain_name] | output_parser

async_runner = RunnableParallel(**chains_dict)
batch_results = await async_runner.ainvoke({"question": user_prompt})
batch_results = async_runner.invoke({"question": user_prompt})

merge_prompt = PromptTemplate(
template=template_merge_prompt,
Expand All @@ -154,7 +154,7 @@ async def execute(self, state: dict) -> dict:
merge_chain = merge_prompt | self.llm_model
if output_parser:
merge_chain = merge_chain | output_parser
answer = await merge_chain.ainvoke({"context": batch_results, "question": user_prompt})
answer = merge_chain.invoke({"context": batch_results, "question": user_prompt})

state.update({self.output[0]: answer})
return state

0 comments on commit 431b209

Please sign in to comment.