Skip to content

Commit 8b0304c

Browse files
committed
add emails
1 parent db5bc5e commit 8b0304c

File tree

6 files changed

+43
-17
lines changed

6 files changed

+43
-17
lines changed
-7 Bytes
Binary file not shown.

mails.txt

Whitespace-only changes.

main.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
st.set_page_config(page_title="Scrapegraph-ai demo",
99
page_icon="🕷️")
1010

11+
def save_email(email):
12+
with open("mails.txt", "a") as file:
13+
file.write(email + "\n")
14+
1115
with st.sidebar:
1216
st.write("Official demo for [Scrapegraph-ai](https://github.com/VinciGit00/Scrapegraph-ai) library")
1317
st.markdown("""---""")
@@ -23,12 +27,25 @@
2327
st.markdown("""---""")
2428
st.write("You want to suggest tips or improvements? Contact me through email to [email protected]")
2529

30+
31+
# Text field for email input
32+
st.write("Write your email to subscribe to the newsletter")
33+
email_input = st.text_input("Enter your email:")
34+
35+
# Button to save email
36+
if st.button("Save Email"):
37+
if email_input:
38+
save_email(email_input)
39+
st.success("Email saved successfully!")
40+
else:
41+
st.warning("Please enter an email before saving.")
42+
2643
st.title("Scrapegraph-ai")
2744
left_co, cent_co, last_co = st.columns(3)
2845
with cent_co:
2946
st.image("assets/scrapegraphai_logo.png")
3047

31-
key = st.text_input("API key", type="password")
48+
key = st.text_input("Openai API key", type="password")
3249
model = st.radio(
3350
"Select the model",
3451
["gpt-3.5-turbo", "gpt-3.5-turbo-0125", "gpt-4", "text-to-speech"],
@@ -49,14 +66,15 @@
4966
st.write(res["answer"])
5067
st.audio(res["audio"])
5168
else:
52-
(true_lens_result, graph_result) = task(key, link_to_scrape, prompt, model)
69+
graph_result = task(key, link_to_scrape, prompt, model)
5370

71+
print(graph_result)
5472
st.write("# Answer")
55-
st.write(graph_result[0])
73+
st.write(graph_result)
5674

57-
if graph_result[0]:
58-
json_str = json.dumps(graph_result[0], indent=4)
59-
df = pd.DataFrame(graph_result[0])
75+
if graph_result:
76+
json_str = json.dumps(graph_result, indent=4)
77+
df = pd.DataFrame(graph_result)
6078

6179
st.download_button(
6280
label="Download JSON",

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pandas==2.0.3
2-
scrapegraphai==0.0.7
2+
scrapegraphai==0.2.3

task.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from scrapegraphai.evaluators import TrulensEvaluator
1+
from scrapegraphai.graphs import SmartScraperGraph
22

33
def task(key:str, url:str, prompt:str, model:str):
44
"""
@@ -13,15 +13,23 @@ def task(key:str, url:str, prompt:str, model:str):
1313
- results_df (pd.Dataframe()): result as padnas df
1414
"""
1515

16-
llm_config = {
16+
graph_config = {
17+
"llm": {
1718
"api_key": key,
18-
"model_name": model,
19+
"model": model,
20+
},
1921
}
2022

21-
trulens_evaluator = TrulensEvaluator(key)
23+
# ************************************************
24+
# Create the SmartScraperGraph instance and run it
25+
# ************************************************
2226

23-
list_of_inputs = [
24-
(prompt, url, llm_config),
25-
]
27+
smart_scraper_graph = SmartScraperGraph(
28+
prompt=prompt,
29+
# also accepts a string with the already downloaded HTML code
30+
source=url,
31+
config=graph_config
32+
)
2633

27-
return trulens_evaluator.evaluate(list_of_inputs, dashboard=False)
34+
result = smart_scraper_graph.run()
35+
return result

text_to_speech.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from scrapegraphai.graphs import SpeechSummaryGraph
1+
from scrapegraphai.graphs import SpeechGraph
22

33
def text_to_speech(api_key: str, prompt: str, url: str):
44
"""Reads text after the prompt from a given URL.
@@ -16,5 +16,5 @@ def text_to_speech(api_key: str, prompt: str, url: str):
1616
audio_file = "audio_result.mp3"
1717

1818
# Create and run the speech summary graph
19-
speech_summary_graph = SpeechSummaryGraph(prompt, url, llm_config, audio_file)
19+
speech_summary_graph = SpeechGraph(prompt, url, llm_config, audio_file)
2020
return speech_summary_graph.run()

0 commit comments

Comments
 (0)