File size: 2,201 Bytes
ace7b0f
 
 
010a8fb
c4251ad
 
887db57
ace7b0f
384368c
887db57
 
ace7b0f
887db57
 
ace7b0f
 
c4251ad
010a8fb
 
 
 
 
 
c4251ad
 
 
 
 
 
 
 
d78af2d
 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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)

def get_user_input():
    user_query = user_input.get("1.0", tk.END).strip()
    output_text.delete(1.0, tk.END)  # Clear previous output
    output = query({"inputs": user_query})
    output_text.insert(tk.END, output)













# import tkinter as tk
# from tkinter import scrolledtext
# import requests
# import os
# SECRET_TOKEN = os.getenv("SECRET_TOKEN")

# API_URL = "https://api-inference.huggingface.co/models/ahmedrachid/FinancialBERT-Sentiment-Analysis"
# headers = {"Authorization": "Bearer {SECRET_TOKEN}"}

# def query(payload):
# 	response = requests.post(API_URL, headers=headers, json=payload)
# 	return response.json()
	
# # output = query({
# # 	"inputs": "I like you. I love you",
# # })


# def get_user_input():
#     user_query = user_input.get("1.0", tk.END).strip()
#     output_text.delete(1.0, tk.END)  # Clear previous output
#     output = query({"inputs": user_query})
#     output_text.insert(tk.END, output)


# window = tk.Tk()
# window.title("Query Interface")


# user_input_label = tk.Label(window, text="Enter your query:")
# user_input_label.pack()

# user_input = scrolledtext.ScrolledText(window, width=40, height=5, wrap=tk.WORD)
# user_input.pack()


# query_button = tk.Button(window, text="Query", command=get_user_input)
# query_button.pack()


# output_text_label = tk.Label(window, text="Output:")
# output_text_label.pack()

# output_text = scrolledtext.ScrolledText(window, width=40, height=10, wrap=tk.WORD)
# output_text.pack()


# window.mainloop()