File size: 390 Bytes
fc94431 37ced21 fc94431 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# api.py
from fastapi import FastAPI
from pydantic import BaseModel
from typing import List, Dict, Any
from model_utils import predict_proba
app = FastAPI(title="StackOverflow Tagger API")
class Query(BaseModel):
text: str
top_k: int = 10
@app.post("/predict")
def predict(q: Query) -> Dict[str, Any]:
tags = predict_proba(q.text, top_k=q.top_k)
return {"tags": tags}
|