nocoai / app.py
kuoe's picture
Create app.py
799b050 verified
raw
history blame
452 Bytes
from fastapi import FastAPI
from pydantic import BaseModel
from transformers import pipeline
app = FastAPI()
pipe = pipeline("text2text-generation", model="google/flan-t5-base")
class Req(BaseModel):
inputs: str
@app.get("/health")
def health():
return {"status": "ok"}
@app.post("/generate")
def generate(req: Req):
out = pipe(req.inputs, max_new_tokens=64)
text = out[0].get("generated_text", "").strip()
return {"text": text}