atishayj281 commited on
Commit
f0dc6f5
·
1 Parent(s): 4b99f88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -1,8 +1,9 @@
1
  import streamlit as st
2
  import requests
3
-
 
4
  API_URL = "https://api-inference.huggingface.co/models/ProsusAI/finbert"
5
- headers = {"Authorization": "Bearer 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"}
6
 
7
  def show_plot(bot_response):
8
  scores = {label_info['label']: label_info['score'] for label_info in bot_response}
@@ -17,10 +18,14 @@ def display_chat_history(chat_history):
17
  if entry["speaker"] == "You":
18
  st.text(f"You: {entry['message']}")
19
  elif entry["speaker"] == "Chatbot":
20
- st.text(f"Chatbot:")
21
- # for label_info in entry['message'][0]:
22
- # st.write(f"Label: {label_info['label']}, Score: {label_info['score']}")
23
- show_plot(entry['message'][0])
 
 
 
 
24
 
25
 
26
  def display_bot_response(bot_response):
@@ -60,4 +65,4 @@ def main():
60
  # display_bot_response(chat_history[-1]["message"])
61
 
62
  if __name__ == "__main__":
63
- main()
 
1
  import streamlit as st
2
  import requests
3
+ import os
4
+ SECRET_TOKEN = os.getenv("SECRET_TOKEN")
5
  API_URL = "https://api-inference.huggingface.co/models/ProsusAI/finbert"
6
+ headers = {"Authorization": f:"Bearer {SECRET_TOKEN}"}
7
 
8
  def show_plot(bot_response):
9
  scores = {label_info['label']: label_info['score'] for label_info in bot_response}
 
18
  if entry["speaker"] == "You":
19
  st.text(f"You: {entry['message']}")
20
  elif entry["speaker"] == "Chatbot":
21
+ try:
22
+ st.text(f"Chatbot:")
23
+ # for label_info in entry['message'][0]:
24
+ # st.write(f"Label: {label_info['label']}, Score: {label_info['score']}")
25
+ print(entry['message'])
26
+ show_plot(entry['message'][0])
27
+ except:
28
+ st.text(f"Something went wrong.")
29
 
30
 
31
  def display_bot_response(bot_response):
 
65
  # display_bot_response(chat_history[-1]["message"])
66
 
67
  if __name__ == "__main__":
68
+ main()