from fastapi import FastAPI from pydantic import BaseModel from transformers import pipeline import uvicorn app = FastAPI() class Payload(BaseModel): text: str async def classify_text(text): pipe = pipeline("text-classification", model="SamLowe/roberta-base-go_emotions") return pipe(text) @app.post("/classify") async def classify(payload: Payload): return {"response": classify_text(payload.text)}