MukeshKapoor25's picture
Add FastAPI application and model training pipeline for AG News classification
327db33
raw
history blame contribute delete
404 Bytes
from fastapi import FastAPI, Request
from pydantic import BaseModel
from app.pipeline import classify_headline
app = FastAPI(title="AG News Classifier")
class TextRequest(BaseModel):
headline: str
@app.get("/")
def health_check():
return {"status": "ok"}
@app.post("/predict")
def predict(request: TextRequest):
result = classify_headline(request.headline)
return {"category": result}