# 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']) import os import streamlit as st 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"): # Show loading message while the model is loading with st.spinner("Analyzing..."): # Load the model output = query({"inputs": user_query}) # Display results after loading st.text("Sentiment Analysis Output:") st.text(output[0][0]['label'])