修复chat生成参数提交错误BUG|模型引擎积分设置关联开发优化成功|视频/图片生成引擎API开发完成
This commit is contained in:
+61
-17
@@ -208,26 +208,70 @@ async def _seed_data():
|
||||
)
|
||||
)
|
||||
|
||||
# Seed credit ratios - use first model config if available
|
||||
model_result = await db.execute(select(ModelConfig).limit(1))
|
||||
model = model_result.scalar_one_or_none()
|
||||
if model:
|
||||
existing_ratio = await db.execute(
|
||||
select(CreditRatio).where(CreditRatio.model_config_id == model.id).limit(1)
|
||||
)
|
||||
if not existing_ratio.scalars().first():
|
||||
for gen_type, resolution, ratio_val, base, per_sec in [
|
||||
("video", "480p", 1.0, 60, 2),
|
||||
("video", "720p", 1.0, 80, 2),
|
||||
("video", "1080p", 1.5, 120, 3),
|
||||
("image", "2K", 1.0, 4, 0),
|
||||
("image", "4K", 1.0, 6, 0),
|
||||
]:
|
||||
# Seed credit ratios - model_config_id is kept as a compatible field name,
|
||||
# but now stores the actual engine id:
|
||||
# - gen_type=video -> video_engines.id
|
||||
# - gen_type=image -> image_engines.id
|
||||
await db.flush()
|
||||
|
||||
default_video_engine_result = await db.execute(
|
||||
select(VideoEngine)
|
||||
.where(VideoEngine.is_active == True)
|
||||
.order_by(VideoEngine.priority.desc(), VideoEngine.id.desc())
|
||||
.limit(1)
|
||||
)
|
||||
default_video_engine = default_video_engine_result.scalar_one_or_none()
|
||||
if default_video_engine:
|
||||
for resolution, ratio_val, base, per_sec in [
|
||||
("480p", 1.0, 60, 2),
|
||||
("720p", 1.0, 80, 2),
|
||||
("1080p", 1.5, 120, 3),
|
||||
]:
|
||||
existing_ratio = await db.execute(
|
||||
select(CreditRatio)
|
||||
.where(CreditRatio.model_config_id == default_video_engine.id)
|
||||
.where(CreditRatio.gen_type == "video")
|
||||
.where(CreditRatio.resolution == resolution)
|
||||
.limit(1)
|
||||
)
|
||||
if not existing_ratio.scalar_one_or_none():
|
||||
db.add(
|
||||
CreditRatio(
|
||||
id=generate_id(),
|
||||
model_config_id=model.id,
|
||||
gen_type=gen_type,
|
||||
model_config_id=default_video_engine.id,
|
||||
gen_type="video",
|
||||
resolution=resolution,
|
||||
ratio=ratio_val,
|
||||
base_credits=base,
|
||||
per_second_credits=per_sec,
|
||||
)
|
||||
)
|
||||
|
||||
default_image_engine_result = await db.execute(
|
||||
select(ImageEngine)
|
||||
.where(ImageEngine.is_active == True)
|
||||
.order_by(ImageEngine.priority.desc(), ImageEngine.id.desc())
|
||||
.limit(1)
|
||||
)
|
||||
default_image_engine = default_image_engine_result.scalar_one_or_none()
|
||||
if default_image_engine:
|
||||
for resolution, ratio_val, base, per_sec in [
|
||||
("2K", 1.0, 4, 0),
|
||||
("4K", 1.0, 6, 0),
|
||||
]:
|
||||
existing_ratio = await db.execute(
|
||||
select(CreditRatio)
|
||||
.where(CreditRatio.model_config_id == default_image_engine.id)
|
||||
.where(CreditRatio.gen_type == "image")
|
||||
.where(CreditRatio.resolution == resolution)
|
||||
.limit(1)
|
||||
)
|
||||
if not existing_ratio.scalar_one_or_none():
|
||||
db.add(
|
||||
CreditRatio(
|
||||
id=generate_id(),
|
||||
model_config_id=default_image_engine.id,
|
||||
gen_type="image",
|
||||
resolution=resolution,
|
||||
ratio=ratio_val,
|
||||
base_credits=base,
|
||||
|
||||
Reference in New Issue
Block a user