rmz0312's picture
Upload 3 files
f6c42f2 verified
Raw
History Blame Contribute Delete
379 Bytes
from fastapi import FastAPI
from transformers import pipeline
app = FastAPI()
pipeline = pipeline("text2text-generation", model="google/flan-t5-small")
@app.get("/")
def home():
return {"message": "Welcome to the Text Generation API!"}
@app.get("/generate")
def generate(text: str):
output = pipeline(text)
return {"generated_text": output[0]['generated_text']}