MjolnirThor's picture
Update for FastAPI integration
232a012
raw
history blame
602 Bytes
from fastapi import FastAPI, HTTPException
from handler import EndpointHandler
from pydantic import BaseModel
class Input(BaseModel):
inputs: str
app = FastAPI()
handler = EndpointHandler()
@app.post("/generate")
async def generate(input_data: Input):
try:
result = handler({"inputs": input_data.inputs})
return result
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@app.get("/")
async def root():
return {
"message": "FLAN-T5 Custom Handler API",
"usage": "POST /generate with {'inputs': 'your text here'}"
}