85 lines
3.3 KiB
Python
85 lines
3.3 KiB
Python
from pydantic import BaseModel, Field
|
|
|
|
from app.enums.generation_status import GenerationType
|
|
from app.schemas.common import NaiveDatetime, NaiveDatetimeOptional
|
|
|
|
|
|
class OptimizeParams(BaseModel):
|
|
project_id: str
|
|
prompt: str = Field(..., max_length=500)
|
|
gen_type: GenerationType = Field(GenerationType.video, description="生成类型:video-视频,image-图片")
|
|
engine_id: str = Field(..., min_length=1, max_length=32, description="提词阶段选定并冻结的生成引擎ID")
|
|
include_media_references: bool = Field(False, description="资源生成时是否携带本次提词附件;提词完成后不可修改")
|
|
duration: int | None = Field(None, description="视频时长(秒),视频生成必填")
|
|
aspect_ratio: str | None = Field(None, description="视频比例,视频生成必填")
|
|
resolution: str | None = Field(None, description="视频目标分辨率,视频生成必填")
|
|
image_size: str | None = Field(None, description="画面分辨率,图片生成使用")
|
|
image_proportion: str | None = Field(None, description="图片比例,图片生成使用")
|
|
image_px: str | None = Field(None, description="图片像素大小,图片生成使用")
|
|
references: list[dict] | None = None
|
|
idempotency_key: str | None = Field(None, max_length=64, description="幂等键,防止重复请求")
|
|
|
|
|
|
class OptimizeResult(BaseModel):
|
|
optimized_prompt: str
|
|
text_credits_cost: float
|
|
text_tokens_used: int = 0
|
|
record: "GenerationRecordOut"
|
|
|
|
class GenerationRecordOut(BaseModel):
|
|
id: str
|
|
project_id: str
|
|
project_name: str
|
|
original_prompt: str
|
|
optimized_prompt: str | None = None
|
|
gen_type: str = "video"
|
|
duration: int | None = None
|
|
aspect_ratio: str | None = None
|
|
resolution: str | None = None
|
|
image_size: str | None = None
|
|
image_proportion: str | None = None
|
|
image_px: str | None = None
|
|
status: str
|
|
pipeline_stage: str | None = None
|
|
video_upscale_enabled: bool = False
|
|
video_url: str | None = None
|
|
video_cover_url: str | None = None
|
|
image_url: str | None = None
|
|
references: list[dict] | None = None
|
|
engine_id: str | None = None
|
|
engine_name: str | None = None
|
|
engine_snapshot: dict | None = None
|
|
include_media_references: bool = False
|
|
config_complete: bool = False
|
|
config_recoverable: bool = False
|
|
config_fallback_hint: str | None = None
|
|
can_generate: bool = False
|
|
can_retry: bool = False
|
|
should_poll: bool = False
|
|
client_status: str = "ready"
|
|
operation_phase: str = "prompt"
|
|
text_credits_cost: float = 0.0
|
|
text_tokens_used: int = 0
|
|
credits_cost: float = 0.0
|
|
video_tokens_used: int = 0
|
|
image_tokens_used: int = 0
|
|
error_message: str | None = None
|
|
created_at: NaiveDatetime
|
|
generated_at: NaiveDatetimeOptional = None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class GenerationRecordPageListOut(BaseModel):
|
|
"""生成记录分页返回API。"""
|
|
page: int = Field(..., description="当前日期分组分页页码")
|
|
page_size: int = Field(..., description="当前每页返回的日期分组数量")
|
|
total: int = Field(..., description="当前生成日期下的生成成功记录总数")
|
|
items: list[GenerationRecordOut] = Field(default_factory=list,)
|
|
|
|
class UpdatePromptRequest(BaseModel):
|
|
optimized_prompt: str = Field(..., max_length=2000)
|
|
|
|
|
|
OptimizeResult.model_rebuild()
|