Skip to content

Commit 186c0d0

Browse files
committed
fix(examples): openai std examples
1 parent 8632c0a commit 186c0d0

25 files changed

+3413
-52
lines changed

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,4 @@ examples/graph_examples/ScrapeGraphAI_generated_graph
3131
examples/**/result.csv
3232
examples/**/result.json
3333
main.py
34-
poetry.lock
35-
36-
# lock files
37-
*.lock
38-
poetry.lock
3934

examples/openai/csv_scraper_openai.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77
import pandas as pd
88
from scrapegraphai.graphs import CSVScraperGraph
99
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
10-
1110
load_dotenv()
11+
1212
# ************************************************
13-
# Read the csv file
13+
# Read the CSV file
1414
# ************************************************
1515

16-
text = pd.read_csv("inputs/username.csv")
16+
FILE_NAME = "inputs/username.csv"
17+
curr_dir = os.path.dirname(os.path.realpath(__file__))
18+
file_path = os.path.join(curr_dir, FILE_NAME)
19+
20+
text = pd.read_csv(file_path)
1721

1822
# ************************************************
1923
# Define the configuration for the graph

examples/openai/custom_graph_openai.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
output=["is_scrapable"],
4040
node_config={
4141
"llm_model": llm_model,
42+
"force_scraping": True,
4243
"verbose": True,
4344
}
4445
)
@@ -103,8 +104,8 @@
103104
# ************************************************
104105

105106
result, execution_info = graph.execute({
106-
"user_prompt": "List me the projects with their description",
107-
"url": "https://perinim.github.io/projects/"
107+
"user_prompt": "Describe the content",
108+
"url": "https://example.com/"
108109
})
109110

110111
# get the answer from the result

examples/openai/json_scraper_openai.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@
5555
# Save to json or csv
5656
convert_to_csv(result, "result")
5757
convert_to_json(result, "result")
58+

examples/openai/scrape_plain_text_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
# ************************************************
4040

4141
smart_scraper_graph = SmartScraperGraph(
42-
prompt="List me all the news with their description.",
42+
prompt="List me all the projects with their description.",
4343
source=text,
4444
config=graph_config
4545
)

examples/openai/script_generator_openai.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@
4343

4444
graph_exec_info = smart_scraper_graph.get_execution_info()
4545
print(prettify_exec_info(graph_exec_info))
46+

examples/openai/search_graph_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"api_key": openai_key,
2020
"model": "gpt-3.5-turbo",
2121
},
22-
"max_results": 5,
22+
"max_results": 2,
2323
"verbose": True,
2424
}
2525

examples/openai/smart_scraper_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"api_key": openai_key,
2222
"model": "gpt-3.5-turbo",
2323
},
24-
"verbose": False,
24+
"verbose": True,
2525
}
2626

2727
# ************************************************

examples/openai/speech_graph_openai.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141
# ************************************************
4242

4343
speech_graph = SpeechGraph(
44-
prompt="Give me a gift idea for a friend.",
45-
source="https://www.amazon.it/s?k=profumo&__mk_it_IT=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=17UXSZNCS2NKE&sprefix=profumo%2Caps%2C88&ref=nb_sb_noss_1",
44+
prompt="Make a detailed audio summary of the projects.",
45+
source="https://perinim.github.io/projects/",
4646
config=graph_config,
4747
)
4848

4949
result = speech_graph.run()
50-
print(result.get("answer", "No answer found"))
50+
print(result)
5151

5252
# ************************************************
5353
# Get graph execution info

examples/openai/xml_scraper_openai.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@
5656
# Save to json or csv
5757
convert_to_csv(result, "result")
5858
convert_to_json(result, "result")
59+

0 commit comments

Comments
 (0)