Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fix: template names
Marco Vinciguerrab82f33aee725
diff --git a/scrapegraphai/helpers/generate_answer_node_csv_prompts.py b/scrapegraphai/helpers/generate_answer_node_csv_prompts.pyindex 0947c671..2cc726aa 100644--- a/scrapegraphai/helpers/generate_answer_node_csv_prompts.py+++ b/scrapegraphai/helpers/generate_answer_node_csv_prompts.py@@ -1,7 +1,7 @@"""Generate answer csv schema"""-template_chunks = """+template_chunks_csv = """You are a scraper and you have just scraped thefollowing content from a csv.You are now asked to answer a user question about the content you have scraped.\n@@ -12,7 +12,7 @@ Output instructions: {format_instructions}\nContent of {chunk_id}: {context}. \n"""-template_no_chunks = """+template_no_chunks_csv = """You are a csv scraper and you have just scraped thefollowing content from a csv.You are now asked to answer a user question about the content you have scraped.\n@@ -23,7 +23,7 @@ User question: {question}\ncsv content: {context}\n"""-template_merge = """+template_merge_csv = """You are a csv scraper and you have just scraped thefollowing content from a csv.You are now asked to answer a user question about the content you have scraped.\ndiff --git a/scrapegraphai/helpers/generate_answer_node_omni_prompts.py b/scrapegraphai/helpers/generate_answer_node_omni_prompts.pyindex 95866d2b..8a2b5ff5 100644--- a/scrapegraphai/helpers/generate_answer_node_omni_prompts.py+++ b/scrapegraphai/helpers/generate_answer_node_omni_prompts.py@@ -2,7 +2,7 @@Generate answer node omni prompts helper"""-template_chunks = """+template_chunks_omni = """You are a website scraper and you have just scraped thefollowing content from a website.You are now asked to answer a user question about the content you have scraped.\n@@ -13,7 +13,7 @@ Output instructions: {format_instructions}\nContent of {chunk_id}: {context}. \n"""-template_no_chunks = """+template_no_chunk_omni = """You are a website scraper and you have just scraped thefollowing content from a website.You are now asked to answer a user question about the content you have scraped.\n@@ -26,7 +26,7 @@ Website content: {context}\nImage descriptions: {img_desc}\n"""-template_merge = """+template_merge_omni = """You are a website scraper and you have just scraped thefollowing content from a website.You are now asked to answer a user question about the content you have scraped.\ndiff --git a/scrapegraphai/helpers/generate_answer_node_pdf_prompts.py b/scrapegraphai/helpers/generate_answer_node_pdf_prompts.pyindex 0635b209..17efa486 100644--- a/scrapegraphai/helpers/generate_answer_node_pdf_prompts.py+++ b/scrapegraphai/helpers/generate_answer_node_pdf_prompts.py@@ -1,7 +1,7 @@"""Generate anwer node pdf prompt"""-template_chunks = """+template_chunks_pdf = """You are a scraper and you have just scraped thefollowing content from a PDF.You are now asked to answer a user question about the content you have scraped.\n@@ -12,7 +12,7 @@ template_chunks = """Content of {chunk_id}: {context}. \n"""-template_no_chunks = """+template_no_chunks_pdf = """You are a PDF scraper and you have just scraped thefollowing content from a PDF.You are now asked to answer a user question about the content you have scraped.\n@@ -23,7 +23,7 @@ template_no_chunks = """PDF content: {context}\n"""-template_merge = """+template_merge_pdf = """You are a PDF scraper and you have just scraped thefollowing content from a PDF.You are now asked to answer a user question about the content you have scraped.\ndiff --git a/scrapegraphai/helpers/generate_answer_node_prompts.py b/scrapegraphai/helpers/generate_answer_node_prompts.pyindex 9fe29c23..09422862 100644--- a/scrapegraphai/helpers/generate_answer_node_prompts.py+++ b/scrapegraphai/helpers/generate_answer_node_prompts.py@@ -1,7 +1,7 @@"""Generate answer node prompts"""-template_chunks = """+template_chunks_gen_answ = """You are a website scraper and you have just scraped thefollowing content from a website.You are now asked to answer a user question about the content you have scraped.\n@@ -12,7 +12,7 @@ Output instructions: {format_instructions}\nContent of {chunk_id}: {context}. \n"""-template_chunks_with_schema = """+template_chunks_with_schema_gen_answ = """You are a website scraper and you have just scraped thefollowing content from a website.You are now asked to answer a user question about the content you have scraped.\n@@ -24,7 +24,7 @@ Output instructions: {format_instructions}\nContent of {chunk_id}: {context}. \n"""-template_no_chunks = """+template_no_chunks_gen_answ = """You are a website scraper and you have just scraped thefollowing content from a website.You are now asked to answer a user question about the content you have scraped.\n@@ -35,7 +35,7 @@ User question: {question}\nWebsite content: {context}\n"""-template_no_chunks_with_schema = """+template_no_chunks_with_schema_gen_answ = """You are a website scraper and you have just scraped thefollowing content from a website.You are now asked to answer a user question about the content you have scraped.\n@@ -48,7 +48,7 @@ Website content: {context}\n"""-template_merge = """+template_merge_gen_answ = """You are a website scraper and you have just scraped thefollowing content from a website.You are now asked to answer a user question about the content you have scraped.\ndiff --git a/scrapegraphai/nodes/generate_answer_csv_node.py b/scrapegraphai/nodes/generate_answer_csv_node.pyindex 921d8771..12de529c 100644--- a/scrapegraphai/nodes/generate_answer_csv_node.py+++ b/scrapegraphai/nodes/generate_answer_csv_node.py@@ -10,7 +10,7 @@ from langchain.prompts import PromptTemplatefrom langchain_core.output_parsers import JsonOutputParserfrom langchain_core.runnables import RunnableParallel-from ..helpers.generate_answer_node_csv_prompts import template_chunks, template_no_chunks, template_merge+from ..helpers.generate_answer_node_csv_prompts import template_chunks_csv, template_no_chunks_csv, template_merge_csv# Imports from the libraryfrom .base_node import BaseNode@@ -94,14 +94,14 @@ class GenerateAnswerCSVNode(BaseNode):for i, chunk in enumerate(tqdm(doc, desc="Processing chunks", disable=not self.verbose)):if len(doc) == 1:prompt = PromptTemplate(- template=template_no_chunks,+ template=template_no_chunks_csv,input_variables=["question"],partial_variables={"context": chunk.page_content,"format_instructions": format_instructions},)else:prompt = PromptTemplate(- template=template_chunks,+ template=template_chunks_csv,input_variables=["question"],partial_variables={"context": chunk.page_content,"chunk_id": i + 1,@@ -119,7 +119,7 @@ class GenerateAnswerCSVNode(BaseNode):answer = map_chain.invoke({"question": user_prompt})# Merge the answers from the chunksmerge_prompt = PromptTemplate(- template=template_merge,+ template=template_merge_csv,input_variables=["context", "question"],partial_variables={"format_instructions": format_instructions},)diff --git a/scrapegraphai/nodes/generate_answer_node.py b/scrapegraphai/nodes/generate_answer_node.pyindex 9d3a9798..5fa65cc7 100644--- a/scrapegraphai/nodes/generate_answer_node.py+++ b/scrapegraphai/nodes/generate_answer_node.py@@ -13,7 +13,7 @@ from langchain_core.runnables import RunnableParallel# Imports from the libraryfrom .base_node import BaseNode-from ..helpers import template_chunks, template_no_chunks, template_merge, template_chunks_with_schema, template_no_chunks_with_schema+from ..helpers import template_chunks_gen_answ, template_no_chunks_gen_answ, template_merge_gen_answ, template_chunks_with_schema_gen_answ, template_chunks_with_schema_gen_answclass GenerateAnswerNode(BaseNode):"""@@ -77,13 +77,13 @@ class GenerateAnswerNode(BaseNode):for i, chunk in enumerate(tqdm(doc, desc="Processing chunks", disable=not self.verbose)):if self.node_config["schema"] is None and len(doc) == 1:prompt = PromptTemplate(- template=template_no_chunks,+ template=template_no_chunks_gen_answ,input_variables=["question"],partial_variables={"context": chunk.page_content,"format_instructions": format_instructions})elif self.node_config["schema"] is not None and len(doc) == 1:prompt = PromptTemplate(- template=template_no_chunks_with_schema,+ template=template_chunks_with_schema_gen_answ,input_variables=["question"],partial_variables={"context": chunk.page_content,"format_instructions": format_instructions,@@ -91,14 +91,14 @@ class GenerateAnswerNode(BaseNode):})elif self.node_config["schema"] is None and len(doc) > 1:prompt = PromptTemplate(- template=template_chunks,+ template=template_chunks_gen_answ,input_variables=["question"],partial_variables={"context": chunk.page_content,"chunk_id": i + 1,"format_instructions": format_instructions})elif self.node_config["schema"] is not None and len(doc) > 1:prompt = PromptTemplate(- template=template_chunks_with_schema,+ template=template_chunks_with_schema_gen_answ,input_variables=["question"],partial_variables={"context": chunk.page_content,"chunk_id": i + 1,@@ -116,7 +116,7 @@ class GenerateAnswerNode(BaseNode):answer = map_chain.invoke({"question": user_prompt})# Merge the answers from the chunksmerge_prompt = PromptTemplate(- template=template_merge,+ template=template_merge_gen_answ,input_variables=["context", "question"],partial_variables={"format_instructions": format_instructions},)diff --git a/scrapegraphai/nodes/generate_answer_omni_node.py b/scrapegraphai/nodes/generate_answer_omni_node.pyindex 369a0006..1e1a98b3 100644--- a/scrapegraphai/nodes/generate_answer_omni_node.py+++ b/scrapegraphai/nodes/generate_answer_omni_node.py@@ -13,8 +13,7 @@ from langchain_core.runnables import RunnableParallel# Imports from the libraryfrom .base_node import BaseNode--from ..helpers.generate_answer_node_omni_prompts import template_chunks, template_no_chunks, template_merge+from ..helpers.generate_answer_node_omni_prompts import template_no_chunk_omni, template_chunks_omni, template_merge_omniclass GenerateAnswerOmniNode(BaseNode):"""@@ -82,7 +81,7 @@ class GenerateAnswerOmniNode(BaseNode):for i, chunk in enumerate(tqdm(doc, desc="Processing chunks", disable=not self.verbose)):if len(doc) == 1:prompt = PromptTemplate(- template=template_no_chunks,+ template=template_no_chunk_omni,input_variables=["question"],partial_variables={"context": chunk.page_content,"format_instructions": format_instructions,@@ -90,7 +89,7 @@ class GenerateAnswerOmniNode(BaseNode):)else:prompt = PromptTemplate(- template=template_chunks,+ template=template_chunks_omni,input_variables=["question"],partial_variables={"context": chunk.page_content,"chunk_id": i + 1,@@ -108,7 +107,7 @@ class GenerateAnswerOmniNode(BaseNode):answer = map_chain.invoke({"question": user_prompt})# Merge the answers from the chunksmerge_prompt = PromptTemplate(- template=template_merge,+ template=template_merge_omni,input_variables=["context", "question"],partial_variables={"format_instructions": format_instructions,diff --git a/scrapegraphai/nodes/generate_answer_pdf_node.py b/scrapegraphai/nodes/generate_answer_pdf_node.pyindex a11c9b58..9bfc546b 100644--- a/scrapegraphai/nodes/generate_answer_pdf_node.py+++ b/scrapegraphai/nodes/generate_answer_pdf_node.py@@ -12,7 +12,7 @@ from langchain_core.runnables import RunnableParallel# Imports from the libraryfrom .base_node import BaseNode-from ..helpers.generate_answer_node_pdf_prompts import template_chunks, template_no_chunks, template_merge+from ..helpers.generate_answer_node_pdf_prompts import template_chunks_pdf, template_no_chunks_pdf, template_merge_pdfclass GenerateAnswerPDFNode(BaseNode):"""@@ -93,14 +93,14 @@ class GenerateAnswerPDFNode(BaseNode):for i, chunk in enumerate(tqdm(doc, desc="Processing chunks", disable=not self.verbose)):if len(doc) == 1:prompt = PromptTemplate(- template=template_no_chunks,+ template=template_no_chunks_pdf,input_variables=["question"],partial_variables={"context": chunk.page_content,"format_instructions": format_instructions},)else:prompt = PromptTemplate(- template=template_chunks,+ template=template_chunks_pdf,input_variables=["question"],partial_variables={"context": chunk.page_content,"chunk_id": i + 1,@@ -118,7 +118,7 @@ class GenerateAnswerPDFNode(BaseNode):answer = map_chain.invoke({"question": user_prompt})# Merge the answers from the chunksmerge_prompt = PromptTemplate(- template=template_merge,+ template=template_merge_pdf,input_variables=["context", "question"],partial_variables={"format_instructions": format_instructions},)