Rephrase / app.py
Credbox's picture
Create app.py
9184e73 verified
raw
history blame contribute delete
577 Bytes
from fastapi import FastAPI
from pydantic import BaseModel
from fastapi.responses import JSONResponse
from Paraphrase import paraphrase_paragraph
app = FastAPI()
class Sentence(BaseModel):
sentence: str
@app.get("/")
def index():
return "OK"
@app.post("/rephrase")
def rephrase(sentence: Sentence):
try:
rephrase_text = paraphrase_paragraph(sentence.sentence)
return JSONResponse(status_code=200, content={"rephrased_sentence": rephrase_text})
except Exception as e:
return JSONResponse(status_code=422,content="Unable to rephrase")