KishanKumar001's picture
Update app.py
df6e5ca
raw
history blame
708 Bytes
import os
import matplotlib
matplotlib.use('Agg') # Use the 'Agg' backend for non-interactive use
import streamlit as st
import tkinter as tk
from tkinter import scrolledtext
import requests
SECRET_TOKEN = os.getenv("SECRET_TOKEN")
API_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fahmedrachid%2FFinancialBERT-Sentiment-Analysis%26quot%3B%3C%2Fspan%3E%3C!-- HTML_TAG_END -->
headers = {"Authorization": f"Bearer {SECRET_TOKEN}"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
user_query = st.text_area("Enter your text:")
if st.button("Analyze Sentiment"):
output = query({"inputs": user_query})
st.text("Sentiment Analysis Output:")
st.text(output[0]['label'])