Files
video-gen/video-gen-api/app/models/credit_ratio.py
T
root 790d546451 1、后台积分比例需要对图片增加和列表增加传入图片价格,倍率、基础积分、每张积分
2、后台列表视频倍率、视频基础积分、视频每秒积分放在单独的传入视频列里
3、列表图片的对应放在单独的传入图片列里
4、/credits/credit-ratios接口对应返回图片添加的规则
5、/credits/ratios接口对应返回图片添加的规则
6、同步修改前台AI创作的/conversation的具体最终图片积分计算逻辑
2026-07-09 10:48:06 +08:00

31 lines
1.7 KiB
Python
Raw 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 sqlalchemy import Float, Index, String
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base, TimestampMixin
class CreditRatio(Base, TimestampMixin):
__tablename__ = "credit_ratios"
__table_args__ = (
Index("ix_credit_ratios_gen_type_engine_resolution", "gen_type", "model_config_id", "resolution"),
Index("ix_credit_ratios_gen_type_resolution", "gen_type", "resolution"),
)
id: Mapped[str] = mapped_column(String(32), primary_key=True)
# 兼容旧字段名:
# gen_type=image 时,该字段保存 image_engines.id
# gen_type=video 时,该字段保存 video_engines.id。
# 不再通过数据库外键绑定 model_configs.id,避免同一字段无法同时关联图片/视频引擎表。
model_config_id: Mapped[str] = mapped_column(String(32), index=True)
gen_type: Mapped[str] = mapped_column(String(16), default="video", index=True)
resolution: Mapped[str] = mapped_column(String(16), nullable=False, index=True)
ratio: Mapped[float] = mapped_column(Float, nullable=False)
base_credits: Mapped[float] = mapped_column(Float, default=80.0)
per_second_credits: Mapped[float] = mapped_column(Float, default=2.0)
input_video_ratio: Mapped[float] = mapped_column(Float, default=1.0)
input_video_base_credits: Mapped[float] = mapped_column(Float, default=0.0)
input_video_per_second_credits: Mapped[float] = mapped_column(Float, default=0.5)
input_image_ratio: Mapped[float] = mapped_column(Float, default=1.0)
input_image_base_credits: Mapped[float] = mapped_column(Float, default=0.0)
input_image_per_image_credits: Mapped[float] = mapped_column(Float, default=0.5)