text_generation / app.py
baadror's picture
text generator
3124816
raw
history blame
628 Bytes
from fastapi import FastAPI
from starlette.responses import FileResponse
from starlette.staticfiles import StaticFiles
from transformers import pipeline
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
app = FastAPI()
@app.get("/infer_t5")
def t5(input):
output = pipe_flan(input)
return {"output": output[0]["generated_text"]}
app.mount("/", StaticFiles(directory="static", html=True), name="static")
@app.get("/")
def index() -> FileResponse:
return FileResponse(path="/app/static/index.html", media_type="text/html")
# @app.get('/')
# def greet():
# return {'Hello': 'Moti'}