Skip to content

Commit 898e5a7

Browse files
fix: refactoring of merge_answer_node
1 parent bfc6852 commit 898e5a7

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

scrapegraphai/helpers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
from .generate_answer_node_csv_prompts import template_chunks_csv, template_no_chunks_csv, template_merge_csv
1111
from .generate_answer_node_pdf_prompts import template_chunks_pdf, template_no_chunks_pdf, template_merge_pdf
1212
from .generate_answer_node_omni_prompts import template_chunks_omni, template_no_chunk_omni, template_merge_omni
13+
from .merge_answer_node_prompts import template_combined
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
Merge answer node prompts
3+
"""
4+
5+
template_combined = """
6+
You are a website scraper and you have just scraped some content from multiple websites.\n
7+
You are now asked to provide an answer to a USER PROMPT based on the content you have scraped.\n
8+
You need to merge the content from the different websites into a single answer without repetitions (if there are any). \n
9+
The scraped contents are in a JSON format and you need to merge them based on the context and providing a correct JSON structure.\n
10+
OUTPUT INSTRUCTIONS: {format_instructions}\n
11+
USER PROMPT: {user_prompt}\n
12+
WEBSITE CONTENT: {website_content}
13+
"""

scrapegraphai/nodes/merge_answers_node.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from langchain_core.output_parsers import JsonOutputParser
88
from ..utils.logging import get_logger
99
from .base_node import BaseNode
10+
from ..helpers import template_combined
1011

1112

1213
class MergeAnswersNode(BaseNode):
@@ -79,18 +80,8 @@ def execute(self, state: dict) -> dict:
7980

8081
format_instructions = output_parser.get_format_instructions()
8182

82-
template_merge = """
83-
You are a website scraper and you have just scraped some content from multiple websites.\n
84-
You are now asked to provide an answer to a USER PROMPT based on the content you have scraped.\n
85-
You need to merge the content from the different websites into a single answer without repetitions (if there are any). \n
86-
The scraped contents are in a JSON format and you need to merge them based on the context and providing a correct JSON structure.\n
87-
OUTPUT INSTRUCTIONS: {format_instructions}\n
88-
USER PROMPT: {user_prompt}\n
89-
WEBSITE CONTENT: {website_content}
90-
"""
91-
9283
prompt_template = PromptTemplate(
93-
template=template_merge,
84+
template=template_combined,
9485
input_variables=["user_prompt"],
9586
partial_variables={
9687
"format_instructions": format_instructions,

0 commit comments

Comments
 (0)