| from fastapi import FastAPI, HTTPException | |
| from pydantic import BaseModel | |
| import wai_service | |
| app = FastAPI() | |
| class InferenceRequest(BaseModel): | |
| word: str | |
| optimized_letter: str | |
| font: str = "KaushanScript-Regular" | |
| seed: int = 0 | |
| class Config: | |
| extra = "allow" | |
| def generate(req: InferenceRequest): | |
| try: | |
| payload = dict(req.__dict__) | |
| img_b64 = wai_service.handler(req.dict()) | |
| return {"image_base64": img_b64} | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=str(e)) | |