Spaces:
Sleeping
Sleeping
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") | |
async def home(): | |
return pipe("what you know about AI?")[0]['generated_text'] | |
async def generate(text:str): | |
res = pipe(text) | |
return {"output":res[0]['generated_text']} | |