from fastapi import FastAPI, HTTPException from pydantic import BaseModel from transformers import pipeline classifier = pipeline("zero-shot-classification", model="MoritzLaurer/deberta-v3-base-zeroshot-v1.1-all-33") app = FastAPI() class EventRequest(BaseModel): text: str @app.get("/") def home(): return {"message" : "UT Compass Classifier is running!"} @app.post("/classify") async def classify_event(request: EventRequest): labels = [ "Engineering & Technology", "Legal & Political Advocacy", "Academic Research", "Career Networking", "Social & Cultural", "Musical" ] try: output = classifier(request.text, labels, hypothesis_template = "This event should appeal to people interested in {}.", multi_label=True) return output except Exception as e: raise HTTPException(status_code=500, detail=str(e))