Download app.py from kubrabuzlu/SentimentIntentetionAnalysis: direct link, hf CLI and curl.
- Browser
- Download file 770 Bytes
-
https://huggingface.co/spaces/kubrabuzlu/SentimentIntentetionAnalysis/resolve/main/app.py
- Command line
-
hf download hf://spaces/kubrabuzlu/SentimentIntentetionAnalysis/app.py
-
curl -L -o app.py https://huggingface.co/spaces/kubrabuzlu/SentimentIntentetionAnalysis/resolve/main/app.py
770 Bytes
| import streamlit as st | |
| import requests | |
| from pydantic import BaseModel | |
| # Define API endpoint | |
| API_ENDPOINT = "https://kubrabuzlu-sentimentandintentionanalysis.hf.space/analyze/" | |
| # Define data model for API request | |
| class Text(BaseModel): | |
| text: str | |
| # Create Streamlit app | |
| st.title("Text Analysis App") | |
| # Get text from user | |
| input_text = st.text_area("Enter your text here:") | |
| if st.button("Analyze"): | |
| # Send request | |
| response = requests.post(API_ENDPOINT, json=Text(text=input_text).dict()) | |
| # Check response | |
| 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.") | |