|
|
import streamlit as st |
|
|
import requests |
|
|
from pydantic import BaseModel |
|
|
|
|
|
|
|
|
API_ENDPOINT = "https://kubrabuzlu-sentimentandintentionanalysis.hf.space/analyze/" |
|
|
|
|
|
|
|
|
class Text(BaseModel): |
|
|
text: str |
|
|
|
|
|
|
|
|
st.title("Text Analysis App") |
|
|
|
|
|
|
|
|
input_text = st.text_area("Enter your text here:") |
|
|
|
|
|
if st.button("Analyze"): |
|
|
|
|
|
response = requests.post(API_ENDPOINT, json=Text(text=input_text).dict()) |
|
|
|
|
|
|
|
|
if response.status_code == 200: |
|
|
result = response.json() |
|
|
st.write("Sentiment:", result["sentiment"]) |
|
|
st.write("Intention:", result["intention"]) |
|
|
else: |
|
|
st.error("An error occurred while analyzing the text.") |
|
|
|