89 lines
2.9 KiB
Python
89 lines
2.9 KiB
Python
from pydantic import BaseModel, ConfigDict, Field
|
||
|
||
from app.schemas.common import NaiveDatetime
|
||
|
||
|
||
class CreditRatioCreate(BaseModel):
|
||
model_config_id: str = Field(
|
||
...,
|
||
max_length=32,
|
||
description=(
|
||
"引擎ID,兼容旧字段名。gen_type=image 时填写 image_engines.id;"
|
||
"gen_type=video 时填写 video_engines.id。当前不再绑定 model_configs.id 外键"
|
||
),
|
||
examples=["engine_xxx"],
|
||
)
|
||
gen_type: str = Field(
|
||
default="video",
|
||
max_length=16,
|
||
description="生成类型:image=图片积分规则,video=视频积分规则",
|
||
examples=["video"],
|
||
)
|
||
resolution: str = Field(
|
||
...,
|
||
max_length=16,
|
||
description="计费参数。视频为分辨率,例如 480p/720p/1080p;图片为分辨率档位,例如 2K/4K",
|
||
examples=["720p"],
|
||
)
|
||
ratio: float = Field(
|
||
...,
|
||
gt=0,
|
||
description="积分倍率。最终扣费会乘以该倍率",
|
||
examples=[1.0],
|
||
)
|
||
base_credits: float = Field(
|
||
default=80.0,
|
||
ge=0,
|
||
description="基础积分。视频按 base_credits + per_second_credits * duration 后再乘 ratio;图片按 base_credits * ratio",
|
||
examples=[80.0],
|
||
)
|
||
per_second_credits: float = Field(
|
||
default=2.0,
|
||
ge=0,
|
||
description="视频每秒积分。图片规则通常为 0",
|
||
examples=[2.0],
|
||
)
|
||
input_video_ratio: float = Field(
|
||
default=1.0,
|
||
ge=0,
|
||
description="传入视频积分倍率。视频生成时,用户上传参考视频的额外积分倍率",
|
||
examples=[1.0],
|
||
)
|
||
input_video_base_credits: float = Field(
|
||
default=0.0,
|
||
ge=0,
|
||
description="传入视频基础积分。视频生成时,用户上传参考视频的基础积分",
|
||
examples=[0.0],
|
||
)
|
||
input_video_per_second_credits: float = Field(
|
||
default=0.5,
|
||
ge=0,
|
||
description="传入视频每秒积分。视频生成时,用户上传参考视频每秒消耗的积分",
|
||
examples=[0.5],
|
||
)
|
||
input_image_ratio: float = Field(
|
||
default=1.0,
|
||
ge=0,
|
||
description="传入图片积分倍率。图片生成时,用户上传参考图片的额外积分倍率",
|
||
examples=[1.0],
|
||
)
|
||
input_image_base_credits: float = Field(
|
||
default=0.0,
|
||
ge=0,
|
||
description="传入图片基础积分。图片生成时,用户上传参考图片的基础积分",
|
||
examples=[0.0],
|
||
)
|
||
input_image_per_image_credits: float = Field(
|
||
default=0.0,
|
||
ge=0,
|
||
description="传入图片每张积分。图片生成时,用户上传参考图片每张消耗的积分",
|
||
examples=[0.0],
|
||
)
|
||
|
||
|
||
class CreditRatioOut(CreditRatioCreate):
|
||
id: str = Field(..., description="积分规则ID")
|
||
created_at: NaiveDatetime = Field(..., description="创建时间")
|
||
|
||
model_config = ConfigDict(from_attributes=True)
|