mirror of
https://github.com/VinciGit00/Scrapegraph-ai.git
synced 2026-07-01 21:00:48 +08:00
fix: refactoring of merge_answer_node
This commit is contained in:
parent
bfc6852b77
commit
898e5a7af5
@ -10,3 +10,4 @@ from .generate_answer_node_prompts import template_chunks, template_no_chunks, t
|
||||
from .generate_answer_node_csv_prompts import template_chunks_csv, template_no_chunks_csv, template_merge_csv
|
||||
from .generate_answer_node_pdf_prompts import template_chunks_pdf, template_no_chunks_pdf, template_merge_pdf
|
||||
from .generate_answer_node_omni_prompts import template_chunks_omni, template_no_chunk_omni, template_merge_omni
|
||||
from .merge_answer_node_prompts import template_combined
|
||||
|
||||
13
scrapegraphai/helpers/merge_answer_node_prompts.py
Normal file
13
scrapegraphai/helpers/merge_answer_node_prompts.py
Normal file
@ -0,0 +1,13 @@
|
||||
"""
|
||||
Merge answer node prompts
|
||||
"""
|
||||
|
||||
template_combined = """
|
||||
You are a website scraper and you have just scraped some content from multiple websites.\n
|
||||
You are now asked to provide an answer to a USER PROMPT based on the content you have scraped.\n
|
||||
You need to merge the content from the different websites into a single answer without repetitions (if there are any). \n
|
||||
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
|
||||
OUTPUT INSTRUCTIONS: {format_instructions}\n
|
||||
USER PROMPT: {user_prompt}\n
|
||||
WEBSITE CONTENT: {website_content}
|
||||
"""
|
||||
@ -7,6 +7,7 @@ from langchain.prompts import PromptTemplate
|
||||
from langchain_core.output_parsers import JsonOutputParser
|
||||
from ..utils.logging import get_logger
|
||||
from .base_node import BaseNode
|
||||
from ..helpers import template_combined
|
||||
|
||||
|
||||
class MergeAnswersNode(BaseNode):
|
||||
@ -79,18 +80,8 @@ class MergeAnswersNode(BaseNode):
|
||||
|
||||
format_instructions = output_parser.get_format_instructions()
|
||||
|
||||
template_merge = """
|
||||
You are a website scraper and you have just scraped some content from multiple websites.\n
|
||||
You are now asked to provide an answer to a USER PROMPT based on the content you have scraped.\n
|
||||
You need to merge the content from the different websites into a single answer without repetitions (if there are any). \n
|
||||
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
|
||||
OUTPUT INSTRUCTIONS: {format_instructions}\n
|
||||
USER PROMPT: {user_prompt}\n
|
||||
WEBSITE CONTENT: {website_content}
|
||||
"""
|
||||
|
||||
prompt_template = PromptTemplate(
|
||||
template=template_merge,
|
||||
template=template_combined,
|
||||
input_variables=["user_prompt"],
|
||||
partial_variables={
|
||||
"format_instructions": format_instructions,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user