nameform-ru / main.py
ultrin's picture
fix tokenizer_kwargs
dd49e10
raw
history blame
623 Bytes
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from transformers import pipeline
app = FastAPI()
pipe = pipeline("text-generation", model="ai-forever/rugpt3large_based_on_gpt2")
@app.get("/infer_t5")
def t5(input):
tokenizer_kwargs = {'max_length':512}
output = pipe(input, **tokenizer_kwargs)
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")