myspace / app.py
youaretranslation's picture
Update app.py
9aacd06 verified
raw
history blame contribute delete
528 Bytes
from fastapi import FastApi
from transformers import pipeline
#create fastapi instance
app = FastApi()
#initilize the text pipeline
# Use a pipeline as a high-level helper
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
@app.get(/)
def home():
return {"retuen mess : hello world"}
#defin function get handle the get requests
@app.get(/generate)
def generate(text:str):
#using the pipeline
output = pipe(text)
##retuen the text in json
return{"output":output[0]["generate_text"]}