Spaces:
Runtime error
Runtime error
from fastapi import FastAPI | |
from transformers import pipeline | |
app=FastAPI() | |
#create text generation pipeline | |
pipe = pipeline("text2text-generation", model="google/flan-t5-small") | |
def home(): | |
return {"message": "Hello World"} | |
# Define a functio to handle the GET requests at '/generate' | |
def generate(text:str): | |
## use the pipeline to generate the text from the given input | |
output=pipe(text) | |
## return the response in JSON format | |
return {"output":output[0]['generated_text']} | |