RaviVish's picture
Upload 3 files
ae60f16 verified
raw
history blame contribute delete
561 Bytes
from fastapi import FastAPI
from transformers import pipeline
app=FastAPI()
#create text generation pipeline
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
@app.get("/")
def home():
return {"message": "Hello World"}
# Define a functio to handle the GET requests at '/generate'
@app.get("/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']}