diff --git a/scrapegraphai/nodes/search_internet_node.py b/scrapegraphai/nodes/search_internet_node.py index 61b11995..adade2c0 100644 --- a/scrapegraphai/nodes/search_internet_node.py +++ b/scrapegraphai/nodes/search_internet_node.py @@ -8,6 +8,7 @@ from langchain_community.chat_models import ChatOllama from ..utils.logging import get_logger from ..utils.research_web import search_on_web from .base_node import BaseNode +from ..prompts import search_internet_template class SearchInternetNode(BaseNode): """ @@ -73,19 +74,8 @@ class SearchInternetNode(BaseNode): output_parser = CommaSeparatedListOutputParser() - search_template = """ - PROMPT: - You are a search engine and you need to generate a search query based on the user's prompt. \n - Given the following user prompt, return a query that can be - used to search the internet for relevant information. \n - You should return only the query string without any additional sentences. \n - For example, if the user prompt is "What is the capital of France?", - you should return "capital of France". \n - If you return something else, you will get a really bad grade. \n - USER PROMPT: {user_prompt}""" - search_prompt = PromptTemplate( - template=search_template, + template=search_internet_template, input_variables=["user_prompt"], ) diff --git a/scrapegraphai/prompts/__init__.py b/scrapegraphai/prompts/__init__.py index 3c35a58c..2b32431a 100644 --- a/scrapegraphai/prompts/__init__.py +++ b/scrapegraphai/prompts/__init__.py @@ -8,3 +8,4 @@ from .generate_answer_node_pdf_prompts import template_chunks_pdf, template_no_c 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 from .robots_node_prompts import template_robot +from .search_internet_node_prompts import search_internet_template \ No newline at end of file diff --git a/scrapegraphai/prompts/robots_node_prompts.py b/scrapegraphai/prompts/robots_node_prompts.py index 95dad776..9eca56af 100644 --- a/scrapegraphai/prompts/robots_node_prompts.py +++ b/scrapegraphai/prompts/robots_node_prompts.py @@ -1,6 +1,7 @@ """ Robot node prompts helper """ + template_robot = """ You are a website scraper and you need to scrape a website. You need to check if the website allows scraping of the provided path. \n diff --git a/scrapegraphai/prompts/search_internet_node_prompts.py b/scrapegraphai/prompts/search_internet_node_prompts.py new file mode 100644 index 00000000..ec694ee4 --- /dev/null +++ b/scrapegraphai/prompts/search_internet_node_prompts.py @@ -0,0 +1,14 @@ +""" +Search internet node prompts helper +""" + +search_internet_template = """ + PROMPT: + You are a search engine and you need to generate a search query based on the user's prompt. \n + Given the following user prompt, return a query that can be + used to search the internet for relevant information. \n + You should return only the query string without any additional sentences. \n + For example, if the user prompt is "What is the capital of France?", + you should return "capital of France". \n + If you return something else, you will get a really bad grade. \n + USER PROMPT: {user_prompt}""" \ No newline at end of file