shvuuuu commited on
Commit
14c27e2
1 Parent(s): 433f54a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -5,12 +5,9 @@ import streamlit as st
5
  import tweepy
6
  from plotly.subplots import make_subplots
7
  from transformers import pipeline
8
- consumer_key = "kG4NXwrJllh7Jv5aLA9yjfb1U"
9
- consumer_secret = "fH27zr7ZcqYdbQMOSPY3v5a6nEgcOXDyFCJPFSb0VNNinZafCz"
10
- access_key = "1116912581434695680-SA7ddRFq6GUxISNrL1V5IoN2Z9FK3m"
11
- access_secret = "JDu1Rj4tj8kSilqawlH88LU8Y7nyu9GcbNZygNCpTk9kd"
12
- auth = tweepy.OAuthHandler(consumer_key,consumer_secret)
13
- auth.set_access_token(access_key,access_secret)
14
  api = tweepy.API(auth)
15
 
16
 
@@ -60,14 +57,19 @@ def get_aggregation_period(df):
60
  return "30D"
61
 
62
 
63
- @st.cache_data
64
  def load_model():
65
  pipe = pipeline(task="sentiment-analysis", model="bhadresh-savani/distilbert-base-uncased-emotion")
66
  return pipe
67
 
68
 
 
 
 
 
 
69
  pipe = load_model()
70
- twitter_handle = st.sidebar.text_input("Twitter handle:", "elonmusk")
71
  twitter_count = st.sidebar.selectbox("Number of tweets:", (10, 100, 500, 1000, 3200))
72
 
73
 
@@ -130,4 +132,4 @@ if st.sidebar.button("Get tweets!"):
130
  st.plotly_chart(fig)
131
 
132
  # tweet sample
133
- st.markdown(df.sample(n=5).to_markdown())
 
5
  import tweepy
6
  from plotly.subplots import make_subplots
7
  from transformers import pipeline
8
+
9
+ auth = tweepy.OAuthHandler(st.secrets["consumer_key"], st.secrets["consumer_secret"])
10
+ auth.set_access_token(st.secrets["access_key"], st.secrets["access_secret"])
 
 
 
11
  api = tweepy.API(auth)
12
 
13
 
 
57
  return "30D"
58
 
59
 
60
+ @st.cache(allow_output_mutation=True)
61
  def load_model():
62
  pipe = pipeline(task="sentiment-analysis", model="bhadresh-savani/distilbert-base-uncased-emotion")
63
  return pipe
64
 
65
 
66
+ """
67
+ # Twitter Emotion Analyser
68
+ """
69
+
70
+
71
  pipe = load_model()
72
+ twitter_handle = st.sidebar.text_input("Twitter handle:", "huggingface")
73
  twitter_count = st.sidebar.selectbox("Number of tweets:", (10, 100, 500, 1000, 3200))
74
 
75
 
 
132
  st.plotly_chart(fig)
133
 
134
  # tweet sample
135
+ st.markdown(df.sample(n=5).to_markdown())