Skip to content

Commit 58cc903

Browse files
committed
feat(multiple): quick fix working
1 parent ff53771 commit 58cc903

File tree

7 files changed

+26
-24
lines changed

7 files changed

+26
-24
lines changed

examples/openai/multiple_search_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
graph_config = {
5050
"llm": {
5151
"api_key": openai_key,
52-
"model": "gpt-3.5-turbo",
52+
"model": "gpt-4o",
5353
},
5454
"verbose": True,
5555
"headless": False,

examples/openai/smart_scraper_openai.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
smart_scraper_graph = SmartScraperGraph(
3333
prompt="List me all the projects with their description",
3434
# also accepts a string with the already downloaded HTML code
35-
source="https://perinim.github.io/projects/"
35+
source="https://perinim.github.io/projects/",
36+
config=graph_config,
3637
)
3738

3839
result = smart_scraper_graph.run()

requirements-dev.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ certifi==2024.2.2
4545
# via requests
4646
charset-normalizer==3.3.2
4747
# via requests
48+
colorama==0.4.6
49+
# via ipython
50+
# via pytest
51+
# via tqdm
4852
dataclasses-json==0.6.6
4953
# via langchain
5054
# via langchain-community
@@ -100,6 +104,7 @@ graphviz==0.20.3
100104
# via scrapegraphai
101105
greenlet==3.0.3
102106
# via playwright
107+
# via sqlalchemy
103108
groq==0.5.0
104109
# via langchain-groq
105110
grpcio==1.63.0
@@ -212,8 +217,6 @@ pandas==2.2.2
212217
# via scrapegraphai
213218
parso==0.8.4
214219
# via jedi
215-
pexpect==4.9.0
216-
# via ipython
217220
playwright==1.43.0
218221
# via scrapegraphai
219222
pluggy==1.5.0
@@ -230,8 +233,6 @@ protobuf==4.25.3
230233
# via googleapis-common-protos
231234
# via grpcio-status
232235
# via proto-plus
233-
ptyprocess==0.7.0
234-
# via pexpect
235236
pure-eval==0.2.2
236237
# via stack-data
237238
pyasn1==0.6.0

requirements.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ certifi==2024.2.2
4545
# via requests
4646
charset-normalizer==3.3.2
4747
# via requests
48+
colorama==0.4.6
49+
# via ipython
50+
# via tqdm
4851
dataclasses-json==0.6.6
4952
# via langchain
5053
# via langchain-community
@@ -99,6 +102,7 @@ graphviz==0.20.3
99102
# via scrapegraphai
100103
greenlet==3.0.3
101104
# via playwright
105+
# via sqlalchemy
102106
groq==0.5.0
103107
# via langchain-groq
104108
grpcio==1.63.0
@@ -208,8 +212,6 @@ pandas==2.2.2
208212
# via scrapegraphai
209213
parso==0.8.4
210214
# via jedi
211-
pexpect==4.9.0
212-
# via ipython
213215
playwright==1.43.0
214216
# via scrapegraphai
215217
prompt-toolkit==3.0.43
@@ -224,8 +226,6 @@ protobuf==4.25.3
224226
# via googleapis-common-protos
225227
# via grpcio-status
226228
# via proto-plus
227-
ptyprocess==0.7.0
228-
# via pexpect
229229
pure-eval==0.2.2
230230
# via stack-data
231231
pyasn1==0.6.0

scrapegraphai/helpers/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
from .models_tokens import models_tokens
88
from .robots import robots_dictionary
99
from .generate_answer_node_prompts import *
10-
from .generate_answer_node_csv_prompts import *
11-
from .generate_answer_node_pdf_prompts import *
12-
from .generate_answer_node_omni_prompts import *
10+
# from .generate_answer_node_csv_prompts import *
11+
# from .generate_answer_node_pdf_prompts import *
12+
# from .generate_answer_node_omni_prompts import *

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_gen_answ = """
4+
template_chunks = """
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_gen_answ = """
15+
template_chunks_with_schema = """
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_gen_answ = """
27+
template_no_chunks = """
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_gen_answ = """
38+
template_no_chunks_with_schema = """
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_gen_answ = """
51+
template_merge = """
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_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_gen_answ, template_no_chunks_gen_answ, template_merge_gen_answ, template_chunks_with_schema_gen_answ, template_chunks_with_schema_gen_answ
16+
from ..helpers import template_chunks, template_no_chunks, template_merge, template_chunks_with_schema, template_no_chunks_with_schema
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_gen_answ,
80+
template=template_no_chunks,
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_chunks_with_schema_gen_answ,
86+
template=template_no_chunks_with_schema,
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_gen_answ,
94+
template=template_chunks,
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_gen_answ,
101+
template=template_chunks_with_schema,
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_gen_answ,
119+
template=template_merge,
120120
input_variables=["context", "question"],
121121
partial_variables={"format_instructions": format_instructions},
122122
)

0 commit comments

Comments
 (0)