File size: 711 Bytes
ace7b0f
 
 
010a8fb
c4251ad
 
887db57
ace7b0f
384368c
887db57
 
ace7b0f
887db57
 
ace7b0f
 
c4251ad
010a8fb
 
 
 
5f8a61a
ace7b0f
 
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
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 = "https://api-inference.huggingface.co/models/ahmedrachid/FinancialBERT-Sentiment-Analysis"
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][0]['label'])