test-docker / app.py
Mohamed-Sami's picture
Update app.py
afcb910 verified
raw
history blame
463 Bytes
from transformers import pipeline
from fastapi import FastAPI
import os
os.environ['TRANSFORMERS_CACHE'] = '/.cache/huggingface/hub'
app = FastAPI()
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
@app.get("/")
async def home():
return pipe("what you know about AI?")[0]['generated_text']
@app.get("/generate")
async def generate(text:str):
res = pipe(text)
return {"output":res[0]['generated_text']}