Kashyap2512's picture
Upload 3 files
52d75c4 verified
raw
history blame contribute delete
No virus
610 Bytes
from fastapi import FastAPI
from transformers import pipeline
# print("Package Load Successfully")
### create a FastAPI app instance
app = FastAPI()
## Initialize the Text Generation pipeline
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
### Define the Route
@app.get('/')
def home():
return ({"message":"Hello world"})
@app.get('/generate')
def generate(text:str):
## use the pipeline to generate the text generation
output=pipe(text)
## return the output generated text in json format
return {"output":output[0]["generated_text"]}