800f90d8c6
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (push) Successful in 2s
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Check push changed paths (push) Successful in 4s
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Successful in 24s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 26s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 1m15s
CI/CD Pipeline / Retag skipped Staging API Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Integration Tests (push) Successful in 1m37s
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Successful in 1m58s
CI/CD Pipeline / Validate - Style (push) Successful in 2m13s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m38s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 4m9s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m38s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 2m57s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 4m49s
CI/CD Pipeline / Validate - Security (push) Successful in 8m27s
CI/CD Pipeline / Unit Tests (push) Successful in 8m34s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / CI Gate (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Canary Release to Production (push) Has been skipped
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
112 lines
3.5 KiB
Python
112 lines
3.5 KiB
Python
"""AI数字人渲染合成管线 API Schema — #1798."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Any, Optional
|
|
|
|
from pydantic import BaseModel, Field, field_validator
|
|
|
|
|
|
class BRollSegment(BaseModel):
|
|
"""B-roll 片段配置."""
|
|
|
|
script_segment_index: int = Field(..., ge=0, description="对应文案片段索引")
|
|
asset_url: str = Field(..., description="B-roll 素材 URL")
|
|
mode: str = Field(..., description="插入模式: fullscreen 或 pip")
|
|
start_time: float = Field(..., ge=0.0, description="在对口型视频中的起始时间(秒)")
|
|
end_time: float = Field(..., ge=0.0, description="在对口型视频中的结束时间(秒)")
|
|
pip_position: Optional[str] = Field("bottom_right", description="pip 模式位置")
|
|
pip_scale: Optional[float] = Field(0.3, ge=0.05, le=1.0, description="pip 模式缩放比例")
|
|
|
|
@field_validator("mode")
|
|
@classmethod
|
|
def validate_mode(cls, v: str) -> str:
|
|
v = v.strip().lower()
|
|
if v not in ("fullscreen", "pip"):
|
|
raise ValueError("mode 必须为 fullscreen 或 pip")
|
|
return v
|
|
|
|
@field_validator("asset_url")
|
|
@classmethod
|
|
def validate_asset_url(cls, v: str) -> str:
|
|
v = v.strip()
|
|
if not v:
|
|
raise ValueError("asset_url 不能为空")
|
|
if not v.startswith(("http://", "https://")):
|
|
raise ValueError("asset_url 必须是 HTTP/HTTPS URL")
|
|
return v
|
|
|
|
@field_validator("end_time")
|
|
@classmethod
|
|
def validate_end_time(cls, v: float, info: Any) -> float:
|
|
start = info.data.get("start_time", 0.0)
|
|
if v <= start:
|
|
raise ValueError("end_time 必须大于 start_time")
|
|
return v
|
|
|
|
|
|
class CreateAiAvatarRenderRequest(BaseModel):
|
|
"""创建渲染任务请求."""
|
|
|
|
lipsync_job_id: str = Field(..., description="对口型任务 ID")
|
|
script_id: str = Field(..., description="文案 ID")
|
|
b_roll_segments: list[BRollSegment] = Field(default_factory=list, description="B-roll 片段列表")
|
|
title_config: dict[str, Any] = Field(default_factory=dict, description="标题配置")
|
|
cover_config: dict[str, Any] = Field(default_factory=dict, description="封面配置")
|
|
project_id: str = Field("", description="项目 ID")
|
|
|
|
@field_validator("lipsync_job_id")
|
|
@classmethod
|
|
def validate_lipsync_job_id(cls, v: str) -> str:
|
|
v = v.strip()
|
|
if not v:
|
|
raise ValueError("lipsync_job_id 不能为空")
|
|
return v
|
|
|
|
@field_validator("script_id")
|
|
@classmethod
|
|
def validate_script_id(cls, v: str) -> str:
|
|
v = v.strip()
|
|
if not v:
|
|
raise ValueError("script_id 不能为空")
|
|
return v
|
|
|
|
|
|
class AiAvatarRenderJobResponse(BaseModel):
|
|
"""渲染任务响应."""
|
|
|
|
id: str
|
|
user_id: str
|
|
project_id: str
|
|
lipsync_job_id: str
|
|
script_id: str
|
|
b_roll_segments: list[dict[str, Any]]
|
|
title_config: dict[str, Any]
|
|
cover_config: dict[str, Any]
|
|
status: str
|
|
progress: int
|
|
output_video_url: str
|
|
output_cover_url: str
|
|
output_duration: float
|
|
error_message: str
|
|
submitted_at: Optional[datetime] = None
|
|
started_at: Optional[datetime] = None
|
|
completed_at: Optional[datetime] = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class AiAvatarRenderProgressResponse(BaseModel):
|
|
"""渲染进度响应."""
|
|
|
|
status: str
|
|
progress: int
|
|
output_video_url: str
|
|
output_cover_url: str
|
|
output_duration: float
|
|
error_message: str
|