mysora/api/schemas.py

54 lines
1.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from enum import Enum
from typing import Optional
from pydantic import BaseModel, Field
class Resolution(str, Enum):
px256 = "256px"
px768 = "768px"
class AspectRatio(str, Enum):
landscape = "16:9"
portrait = "9:16"
square = "1:1"
cinematic = "2.39:1"
class CondType(str, Enum):
t2v = "t2v"
i2v_head = "i2v_head"
class GenerateRequest(BaseModel):
prompt: str = Field(..., min_length=1, max_length=2000, description="文本提示词")
resolution: Resolution = Field(Resolution.px256, description="分辨率")
aspect_ratio: AspectRatio = Field(AspectRatio.landscape, description="画面比例")
num_frames: int = Field(49, ge=1, le=129, description="帧数4k+1建议 49=~2s97=~4s129=~5s")
motion_score: int = Field(4, ge=1, le=7, description="运动幅度1=静态7=剧烈)")
num_steps: int = Field(50, ge=10, le=100, description="扩散步数,越多质量越高但越慢")
seed: Optional[int] = Field(None, description="随机种子,不填则随机")
cond_type: CondType = Field(CondType.t2v, description="生成类型")
class JobStatus(str, Enum):
pending = "pending"
processing = "processing"
completed = "completed"
failed = "failed"
class SubmitResponse(BaseModel):
job_id: str
message: str = "任务已提交"
class JobResponse(BaseModel):
job_id: str
status: JobStatus
video_url: Optional[str] = None
error: Optional[str] = None
created_at: Optional[str] = None
completed_at: Optional[str] = None