HinaCortus's picture
Update app.py
5f0a349
raw
history blame
529 Bytes
from fastapi import FastAPI
from pydantic import BaseModel
from app.model.model import predict_pipeline
from app.model.model import __version__ as model_version
app = FastAPI()
class TextIn(BaseModel):
text: str
class PredictionOut(BaseModel):
language: str
@app.get("/")
def home():
return {"health_check": "OK", "model_version": model_version}
@app.post("/predict", response_model=PredictionOut)
def predict(payload: TextIn):
language = predict_pipeline(payload.text)
return {"language": language}