hazardous's picture
add files
94e649c
from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
from pydantic import BaseModel
from classifier import Classifier
class SentimentText(BaseModel):
text: str
app = FastAPI()
@app.get("/")
def root(request: SentimentText):
classfier = Classifier()
prediction = classfier.classify(request.text)
return {"sentiment": prediction}
def endpoint_openapi():
if app.openapi_schema:
return app.openapi_schema
openapi_schema = get_openapi(
title="Sentiment Analysis",
version="2.5.0",
description="This is the OpenAPI schema for the app",
routes=app.routes,
)
openapi_schema["info"]["x-logo"] = {
"url": "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png"
}
app.openapi_schema = openapi_schema
return app.openapi_schema
app.openapi = endpoint_openapi