File size: 366 Bytes
aca7985 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from fastapi import FastAPI
from transformers import pipeline
app = FastAPI()
pipe = pipeline("text-generation", model="google/flan-t5-small")
@app.get("/generate")
def generate(query: str):
output = pipe(query, max_length=50, do_sample=True, top_k=50)
return {"output": output[0]["generated_text"], "query": query, "model": "google/flan-t5-small"}
|