File size: 602 Bytes
232a012
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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'}"
    }