ayang903 commited on
Commit
5b38d99
·
1 Parent(s): afc8e9b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+ sys.path.append('src')
4
+
5
+ from summarizer import summarize
6
+ from data_retrieval import scrape
7
+ from data_preprocessing import lda
8
+ from gsheets import upload_csv_to_new_worksheet
9
+
10
+ import joblib
11
+ import gradio as gr
12
+
13
+
14
+ def main_orchestrator(num_reddit_posts, num_news_articles, num_youtube_videos, gpt_key, model):
15
+ #scraping
16
+ filename = scrape(num_reddit_posts=num_reddit_posts,
17
+ num_news_articles=num_news_articles,
18
+ num_youtube_videos=num_youtube_videos)
19
+
20
+ # summarizing
21
+ csv_filename = summarize(filename, gpt_key, model)
22
+ print(csv_filename)
23
+
24
+ # topic modeling
25
+ topics, graph1, graph2 = lda(filename)
26
+ print(topics)
27
+
28
+ #upload to sheets
29
+ gsheet_status = upload_csv_to_new_worksheet(topics)
30
+ return gsheet_status, topics, graph1, graph2
31
+
32
+ demo = gr.Interface(
33
+ fn=main_orchestrator,
34
+ inputs=[gr.Number(precision=0, minimum=1, maximum=10), gr.Number(precision=0, minimum=1, maximum=10), gr.Number(precision=0, minimum=1, maximum=10), "text", "text"], # list of inputs that correspond to the parameters of the function.
35
+ outputs=[gr.Textbox(label="Google Sheet Location"), gr.Textbox(label="Topics"), gr.Plot(label="Frequency of Topics"), gr.Plot(label="Top Words in Topics")], # list of outputs that correspond to the returned values in the function.
36
+ )
37
+ demo.launch()
38
+