Spaces:
Sleeping
Sleeping
File size: 593 Bytes
6cc5308 c0910c7 6cc5308 13cb401 3a14ea7 6cc5308 13cb401 c0910c7 |
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 |
import streamlit as st
from fastapi import FastAPI
from pydantic import BaseModel
from backend import predict
st.title("Classify Sentiment")
text= st.text_area("Enter your text")
if(text):
prediction= predict(text)
st.header(prediction)
st.json({"sentiment": prediction})
app = FastAPI()
class Input(BaseModel):
text: str
@app.get("/")
async def root():
return {"message": "SentimentPro API is running!"}
@app.post("/predict/")
async def predict_sentiment(input: Input):
prediction = predict(input.text)
return {"text": input.text, "sentiment": prediction} |