paarthmadan's picture
Upload 6 files
969cd78
raw
history blame
714 Bytes
from typing import Dict
from fastapi import Depends, FastAPI
from pydantic import BaseModel
from .classifier.model import Model, get_model
app = FastAPI()
class SentimentRequest(BaseModel):
text: str
class SentimentResponse(BaseModel):
probabilities: Dict[str, float]
sentiment: str
confidence: float
@app.post("/predict", response_model=SentimentResponse)
def predict(request: SentimentRequest, model: Model = Depends(get_model)):
sentiment, confidence, probabilities = model.predict(request.text)
return SentimentResponse(
sentiment=sentiment, confidence=confidence, probabilities=probabilities
)
@app.get("/")
def read_root():
return {"TrueFoundry": "Project"}