File size: 1,327 Bytes
5b38d99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys

sys.path.append('src')

from summarizer import summarize
from data_retrieval import scrape
from data_preprocessing import lda
from gsheets import upload_csv_to_new_worksheet

import joblib
import gradio as gr


def main_orchestrator(num_reddit_posts, num_news_articles, num_youtube_videos, gpt_key, model):
  #scraping
  filename = scrape(num_reddit_posts=num_reddit_posts,
                  num_news_articles=num_news_articles,
                  num_youtube_videos=num_youtube_videos)

  # summarizing
  csv_filename = summarize(filename, gpt_key, model)
  print(csv_filename)

  # topic modeling
  topics, graph1, graph2 = lda(filename)
  print(topics)

  #upload to sheets
  gsheet_status = upload_csv_to_new_worksheet(topics)
  return gsheet_status, topics, graph1, graph2

demo = gr.Interface(
    fn=main_orchestrator,
    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.
    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.
)
demo.launch()