2d50679ec0
- FastAPI with job polling: POST /generate, GET /jobs/{id}, /download, /health
- SQLite job persistence (aiosqlite), background task processing
- LTX-2.3 DistilledPipeline via native ltx-pipelines (editable install from submodule)
- Configurable model paths, LoRA support, FP8 quantization via env vars
- Single-concurrency GPU lock for safe inference
- LTX-2 as git submodule under libs/
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import uuid
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# --- Request ---
|
|
|
|
class GenerateRequest(BaseModel):
|
|
prompt: Optional[str] = Field(None, description="Optional text prompt to guide generation")
|
|
width: int = Field(768, ge=256, le=2048, multiple_of=32, description="Video width (must be divisible by 32)")
|
|
height: int = Field(512, ge=256, le=2048, multiple_of=32, description="Video height (must be divisible by 32)")
|
|
num_frames: int = Field(65, ge=9, le=257, description="Frame count (must be 8n+1)")
|
|
fps: float = Field(24.0, gt=0, le=60, description="Frames per second")
|
|
seed: Optional[int] = Field(None, description="Random seed for reproducibility")
|
|
|
|
|
|
# --- Job Status ---
|
|
|
|
class JobStatusResponse(BaseModel):
|
|
job_id: str
|
|
status: str # pending, processing, completed, failed
|
|
prompt: Optional[str] = None
|
|
params: Optional[dict] = None
|
|
error: Optional[str] = None
|
|
created_at: Optional[str] = None
|
|
completed_at: Optional[str] = None
|
|
|
|
|
|
# --- Submission Response ---
|
|
|
|
class JobSubmitResponse(BaseModel):
|
|
job_id: str
|
|
status: str = "pending"
|
|
message: str = "Job submitted. Poll GET /jobs/{job_id} for status."
|
|
|
|
|
|
# --- Error ---
|
|
|
|
class ErrorResponse(BaseModel):
|
|
error: str
|