-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
28 lines (24 loc) · 1.05 KB
/
main.py
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
import matplotlib.pyplot as plt
import requests
import seaborn as sns
import streamlit as st
def send_request(text):
api_url = 'https://main-common-computer-backend-jonathanlampkin.endpoint.ainize.ai/summarize'
files = {'base_text': (None, text)}
response = requests.post(api_url, files=files)
status_code = response.status_code
return status_code, response
st.title("People's Thoughts Demo")
st.header("Generate Twitter Summary and Sentiment")
base_story = st.text_input("Type Search Phrase", "\"Will Smith\"")
if st.button("Submit"):
status_code, response = send_request(base_story)
if status_code == 200:
prediction = response.json()
st.text_area(label='Summary', value=prediction['prediction'])
fig, ax = plt.subplots()
sentiments = dict(sorted(prediction['sentiment'].items(),key= lambda x:x[1], reverse=True))
sns.barplot(ax=ax, x=list(sentiments.keys()), y=list(sentiments.values())).set(title='Sentiment Scores')
st.pyplot(fig)
else:
st.error(str(status_code) + " Error")