Skip to content

Commit b82f33a

Browse files
committed
fix: template names
1 parent 05e511e commit b82f33a

8 files changed

+32
-33
lines changed

scrapegraphai/helpers/generate_answer_node_csv_prompts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Generate answer csv schema
33
"""
4-
template_chunks = """
4+
template_chunks_csv = """
55
You are a scraper and you have just scraped the
66
following content from a csv.
77
You are now asked to answer a user question about the content you have scraped.\n
@@ -12,7 +12,7 @@
1212
Content of {chunk_id}: {context}. \n
1313
"""
1414

15-
template_no_chunks = """
15+
template_no_chunks_csv = """
1616
You are a csv scraper and you have just scraped the
1717
following content from a csv.
1818
You are now asked to answer a user question about the content you have scraped.\n
@@ -23,7 +23,7 @@
2323
csv content: {context}\n
2424
"""
2525

26-
template_merge = """
26+
template_merge_csv = """
2727
You are a csv scraper and you have just scraped the
2828
following content from a csv.
2929
You are now asked to answer a user question about the content you have scraped.\n

scrapegraphai/helpers/generate_answer_node_omni_prompts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Generate answer node omni prompts helper
33
"""
44

5-
template_chunks = """
5+
template_chunks_omni = """
66
You are a website scraper and you have just scraped the
77
following content from a website.
88
You are now asked to answer a user question about the content you have scraped.\n
@@ -13,7 +13,7 @@
1313
Content of {chunk_id}: {context}. \n
1414
"""
1515

16-
template_no_chunks = """
16+
template_no_chunk_omni = """
1717
You are a website scraper and you have just scraped the
1818
following content from a website.
1919
You are now asked to answer a user question about the content you have scraped.\n
@@ -26,7 +26,7 @@
2626
Image descriptions: {img_desc}\n
2727
"""
2828

29-
template_merge = """
29+
template_merge_omni = """
3030
You are a website scraper and you have just scraped the
3131
following content from a website.
3232
You are now asked to answer a user question about the content you have scraped.\n

scrapegraphai/helpers/generate_answer_node_pdf_prompts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Generate anwer node pdf prompt
33
"""
4-
template_chunks = """
4+
template_chunks_pdf = """
55
You are a scraper and you have just scraped the
66
following content from a PDF.
77
You are now asked to answer a user question about the content you have scraped.\n
@@ -12,7 +12,7 @@
1212
Content of {chunk_id}: {context}. \n
1313
"""
1414

15-
template_no_chunks = """
15+
template_no_chunks_pdf = """
1616
You are a PDF scraper and you have just scraped the
1717
following content from a PDF.
1818
You are now asked to answer a user question about the content you have scraped.\n
@@ -23,7 +23,7 @@
2323
PDF content: {context}\n
2424
"""
2525

26-
template_merge = """
26+
template_merge_pdf = """
2727
You are a PDF scraper and you have just scraped the
2828
following content from a PDF.
2929
You are now asked to answer a user question about the content you have scraped.\n

scrapegraphai/helpers/generate_answer_node_prompts.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Generate answer node prompts
33
"""
4-
template_chunks = """
4+
template_chunks_gen_answ = """
55
You are a website scraper and you have just scraped the
66
following content from a website.
77
You are now asked to answer a user question about the content you have scraped.\n
@@ -12,7 +12,7 @@
1212
Content of {chunk_id}: {context}. \n
1313
"""
1414

15-
template_chunks_with_schema = """
15+
template_chunks_with_schema_gen_answ = """
1616
You are a website scraper and you have just scraped the
1717
following content from a website.
1818
You are now asked to answer a user question about the content you have scraped.\n
@@ -24,7 +24,7 @@
2424
Content of {chunk_id}: {context}. \n
2525
"""
2626

27-
template_no_chunks = """
27+
template_no_chunks_gen_answ = """
2828
You are a website scraper and you have just scraped the
2929
following content from a website.
3030
You are now asked to answer a user question about the content you have scraped.\n
@@ -35,7 +35,7 @@
3535
Website content: {context}\n
3636
"""
3737

38-
template_no_chunks_with_schema = """
38+
template_no_chunks_with_schema_gen_answ = """
3939
You are a website scraper and you have just scraped the
4040
following content from a website.
4141
You are now asked to answer a user question about the content you have scraped.\n
@@ -48,7 +48,7 @@
4848
"""
4949

5050

51-
template_merge = """
51+
template_merge_gen_answ = """
5252
You are a website scraper and you have just scraped the
5353
following content from a website.
5454
You are now asked to answer a user question about the content you have scraped.\n

scrapegraphai/nodes/generate_answer_csv_node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from langchain_core.output_parsers import JsonOutputParser
1111
from langchain_core.runnables import RunnableParallel
1212

13-
from ..helpers.generate_answer_node_csv_prompts import template_chunks, template_no_chunks, template_merge
13+
from ..helpers.generate_answer_node_csv_prompts import template_chunks_csv, template_no_chunks_csv, template_merge_csv
1414

1515
# Imports from the library
1616
from .base_node import BaseNode
@@ -94,14 +94,14 @@ def execute(self, state):
9494
for i, chunk in enumerate(tqdm(doc, desc="Processing chunks", disable=not self.verbose)):
9595
if len(doc) == 1:
9696
prompt = PromptTemplate(
97-
template=template_no_chunks,
97+
template=template_no_chunks_csv,
9898
input_variables=["question"],
9999
partial_variables={"context": chunk.page_content,
100100
"format_instructions": format_instructions},
101101
)
102102
else:
103103
prompt = PromptTemplate(
104-
template=template_chunks,
104+
template=template_chunks_csv,
105105
input_variables=["question"],
106106
partial_variables={"context": chunk.page_content,
107107
"chunk_id": i + 1,
@@ -119,7 +119,7 @@ def execute(self, state):
119119
answer = map_chain.invoke({"question": user_prompt})
120120
# Merge the answers from the chunks
121121
merge_prompt = PromptTemplate(
122-
template=template_merge,
122+
template=template_merge_csv,
123123
input_variables=["context", "question"],
124124
partial_variables={"format_instructions": format_instructions},
125125
)

scrapegraphai/nodes/generate_answer_node.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
# Imports from the library
1515
from .base_node import BaseNode
16-
from ..helpers import template_chunks, template_no_chunks, template_merge, template_chunks_with_schema, template_no_chunks_with_schema
16+
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_answ
1717

1818
class GenerateAnswerNode(BaseNode):
1919
"""
@@ -77,28 +77,28 @@ def execute(self, state: dict) -> dict:
7777
for i, chunk in enumerate(tqdm(doc, desc="Processing chunks", disable=not self.verbose)):
7878
if self.node_config["schema"] is None and len(doc) == 1:
7979
prompt = PromptTemplate(
80-
template=template_no_chunks,
80+
template=template_no_chunks_gen_answ,
8181
input_variables=["question"],
8282
partial_variables={"context": chunk.page_content,
8383
"format_instructions": format_instructions})
8484
elif self.node_config["schema"] is not None and len(doc) == 1:
8585
prompt = PromptTemplate(
86-
template=template_no_chunks_with_schema,
86+
template=template_chunks_with_schema_gen_answ,
8787
input_variables=["question"],
8888
partial_variables={"context": chunk.page_content,
8989
"format_instructions": format_instructions,
9090
"schema": self.node_config["schema"]
9191
})
9292
elif self.node_config["schema"] is None and len(doc) > 1:
9393
prompt = PromptTemplate(
94-
template=template_chunks,
94+
template=template_chunks_gen_answ,
9595
input_variables=["question"],
9696
partial_variables={"context": chunk.page_content,
9797
"chunk_id": i + 1,
9898
"format_instructions": format_instructions})
9999
elif self.node_config["schema"] is not None and len(doc) > 1:
100100
prompt = PromptTemplate(
101-
template=template_chunks_with_schema,
101+
template=template_chunks_with_schema_gen_answ,
102102
input_variables=["question"],
103103
partial_variables={"context": chunk.page_content,
104104
"chunk_id": i + 1,
@@ -116,7 +116,7 @@ def execute(self, state: dict) -> dict:
116116
answer = map_chain.invoke({"question": user_prompt})
117117
# Merge the answers from the chunks
118118
merge_prompt = PromptTemplate(
119-
template=template_merge,
119+
template=template_merge_gen_answ,
120120
input_variables=["context", "question"],
121121
partial_variables={"format_instructions": format_instructions},
122122
)

scrapegraphai/nodes/generate_answer_omni_node.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
# Imports from the library
1515
from .base_node import BaseNode
16-
17-
from ..helpers.generate_answer_node_omni_prompts import template_chunks, template_no_chunks, template_merge
16+
from ..helpers.generate_answer_node_omni_prompts import template_no_chunk_omni, template_chunks_omni, template_merge_omni
1817

1918
class GenerateAnswerOmniNode(BaseNode):
2019
"""
@@ -82,15 +81,15 @@ def execute(self, state: dict) -> dict:
8281
for i, chunk in enumerate(tqdm(doc, desc="Processing chunks", disable=not self.verbose)):
8382
if len(doc) == 1:
8483
prompt = PromptTemplate(
85-
template=template_no_chunks,
84+
template=template_no_chunk_omni,
8685
input_variables=["question"],
8786
partial_variables={"context": chunk.page_content,
8887
"format_instructions": format_instructions,
8988
"img_desc": imag_desc},
9089
)
9190
else:
9291
prompt = PromptTemplate(
93-
template=template_chunks,
92+
template=template_chunks_omni,
9493
input_variables=["question"],
9594
partial_variables={"context": chunk.page_content,
9695
"chunk_id": i + 1,
@@ -108,7 +107,7 @@ def execute(self, state: dict) -> dict:
108107
answer = map_chain.invoke({"question": user_prompt})
109108
# Merge the answers from the chunks
110109
merge_prompt = PromptTemplate(
111-
template=template_merge,
110+
template=template_merge_omni,
112111
input_variables=["context", "question"],
113112
partial_variables={
114113
"format_instructions": format_instructions,

scrapegraphai/nodes/generate_answer_pdf_node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# Imports from the library
1414
from .base_node import BaseNode
15-
from ..helpers.generate_answer_node_pdf_prompts import template_chunks, template_no_chunks, template_merge
15+
from ..helpers.generate_answer_node_pdf_prompts import template_chunks_pdf, template_no_chunks_pdf, template_merge_pdf
1616

1717
class GenerateAnswerPDFNode(BaseNode):
1818
"""
@@ -93,14 +93,14 @@ def execute(self, state):
9393
for i, chunk in enumerate(tqdm(doc, desc="Processing chunks", disable=not self.verbose)):
9494
if len(doc) == 1:
9595
prompt = PromptTemplate(
96-
template=template_no_chunks,
96+
template=template_no_chunks_pdf,
9797
input_variables=["question"],
9898
partial_variables={"context": chunk.page_content,
9999
"format_instructions": format_instructions},
100100
)
101101
else:
102102
prompt = PromptTemplate(
103-
template=template_chunks,
103+
template=template_chunks_pdf,
104104
input_variables=["question"],
105105
partial_variables={"context": chunk.page_content,
106106
"chunk_id": i + 1,
@@ -118,7 +118,7 @@ def execute(self, state):
118118
answer = map_chain.invoke({"question": user_prompt})
119119
# Merge the answers from the chunks
120120
merge_prompt = PromptTemplate(
121-
template=template_merge,
121+
template=template_merge_pdf,
122122
input_variables=["context", "question"],
123123
partial_variables={"format_instructions": format_instructions},
124124
)

0 commit comments

Comments
 (0)