135e422d45
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 3s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 4s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 51s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 51s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 51s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 1m39s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m53s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 1m50s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 2m1s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m11s
CI/CD Pipeline / Validate - Style (pull_request) Failing after 2m14s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m13s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 5m2s
AI Code Review / AI Code Review (pull_request) Successful in 6m21s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 8m51s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 4s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 5m47s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 7s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 36s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 67h58m7s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 68h5m29s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 68h5m41s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 68h5m17s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 68h5m43s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 68h5m44s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 68h5m45s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 67h57m43s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 67h57m40s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 67h57m44s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 67h57m40s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 68h5m5s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 68h5m7s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 68h5m18s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 68h6m42s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 68h40m30s
127 lines
4.3 KiB
Python
127 lines
4.3 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="标题配置(可含 title_image_dataurl:前端 Canvas 渲染的标题 PNG dataURL)"
|
||
)
|
||
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:
|
||
return (v or "").strip()
|
||
|
||
|
||
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
|
||
|
||
|
||
class SmartCoverResponse(BaseModel):
|
||
"""智能封面响应(封面从最终成片抽帧,不再叠加标题)."""
|
||
|
||
cover_url: str = Field("", description="封面图公网 URL(OSS,非临时);失败为空")
|
||
status: str = Field("completed", description="completed / fallback_failed")
|
||
message: str = Field("", description="失败原因(如有)")
|
||
|
||
|
||
class FinalizeRenderResponse(BaseModel):
|
||
"""封面选好后点「完成」,正式入库成片库的响应."""
|
||
|
||
video_id: str = Field(..., description="成片库视频ID")
|
||
cover_url: str = Field("", description="封面URL")
|
||
status: str = Field("success", description="success/already_finalized")
|