| """ |
| 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 |
|
|