from fastapi import FastAPI, HTTPException | |
from handler import EndpointHandler | |
from pydantic import BaseModel | |
class Input(BaseModel): | |
inputs: str | |
app = FastAPI() | |
handler = EndpointHandler() | |
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)) | |
async def root(): | |
return { | |
"message": "FLAN-T5 Custom Handler API", | |
"usage": "POST /generate with {'inputs': 'your text here'}" | |
} |