File size: 2,319 Bytes
9834af3 db23a91 9834af3 db23a91 9834af3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | """
Fact Image Schemas
Pydantic models for request/response validation
"""
from pydantic import BaseModel, Field
from typing import Literal, Optional
from enum import Enum
class ImageModel(str, Enum):
"""Supported image generation models"""
nvidia = "nvidia"
cloudflare = "cloudflare"
pexels = "pexels"
class JobStatus(str, Enum):
"""Job status enum"""
queued = "queued"
generating_image = "generating_image"
adding_text = "adding_text"
creating_video = "creating_video"
ready = "ready"
failed = "failed"
class HeadingBackground(BaseModel):
"""Heading background style configuration"""
enabled: bool = True
color: str = Field(default="rgba(0, 0, 0, 0.45)", description="Background color (rgba or hex)")
padding: int = Field(default=22, ge=5, le=50, description="Padding around text")
corner_radius: int = Field(default=28, ge=0, le=50, description="Corner radius for rounded edges")
class FactImageRequest(BaseModel):
"""Request schema for creating a fact image video"""
model: ImageModel = Field(
default=ImageModel.nvidia,
description="Image generation model: nvidia, cloudflare, or pexels"
)
image_prompt: str = Field(
...,
min_length=10,
max_length=500,
description="Prompt for generating the background image"
)
fact_heading: Optional[str] = Field(
default=None,
max_length=50,
description="Optional heading text (e.g., 'Psychological Hack')"
)
heading_background: Optional[HeadingBackground] = Field(
default=None,
description="Heading background style configuration"
)
fact_text: str = Field(
...,
min_length=5,
max_length=200,
description="The fact text to overlay on the image"
)
duration: int = Field(
default=5,
ge=4,
le=7,
description="Video duration in seconds (4-7)"
)
class FactImageResponse(BaseModel):
"""Response schema for job creation"""
job_id: str
status: str
status_url: str
download_url: str
class FactImageStatus(BaseModel):
"""Response schema for job status"""
job_id: str
status: JobStatus
progress: int = 0
video_url: Optional[str] = None
error: Optional[str] = None
|