修复chat生成参数提交错误BUG|模型引擎积分设置关联开发优化成功|视频/图片生成引擎API开发完成
This commit is contained in:
@@ -63,68 +63,37 @@ def _build_optimized_prompt_by_params(task: ChatGenerationTask) -> str:
|
||||
|
||||
gen_type = (_to_clean_str(getattr(task, "gen_type", None)) or "").lower()
|
||||
|
||||
# 常见字段名兼容:
|
||||
# duration / duration_seconds / video_duration
|
||||
# aspect_ratio / ratio
|
||||
# resolution
|
||||
# image_size / size / pixel_size
|
||||
duration = _get_first_value(task, "duration", "duration_seconds", "video_duration")
|
||||
aspect_ratio = _get_first_value(task, "aspect_ratio", "ratio")
|
||||
duration = _get_first_value(task, "duration")
|
||||
aspect_ratio = _get_first_value(task, "aspect_ratio")
|
||||
resolution = _get_first_value(task, "resolution")
|
||||
image_size = _get_first_value(task, "image_size", "size", "pixel_size")
|
||||
image_size = _get_first_value(task, "image_size")
|
||||
image_px = _get_first_value(task, "image_px")
|
||||
image_proportion = _get_first_value(task, "image_proportion")
|
||||
|
||||
parts = []
|
||||
|
||||
if gen_type == "video":
|
||||
duration_text = _format_duration(duration)
|
||||
aspect_ratio_text = _to_clean_str(aspect_ratio)
|
||||
resolution_text = _to_clean_str(resolution)
|
||||
|
||||
if duration_text:
|
||||
parts.append(f"时长:{duration_text}")
|
||||
if aspect_ratio_text:
|
||||
parts.append(f"画面比例:{aspect_ratio_text}")
|
||||
if resolution_text:
|
||||
parts.append(f"分辨率:{resolution_text}")
|
||||
|
||||
# 时长:4秒,画面比例:16:9,分辨率:480p
|
||||
if duration:
|
||||
parts.append(f"时长:{duration}秒")
|
||||
parts.append(f"画面比例:{aspect_ratio}")
|
||||
parts.append(f"分辨率:{resolution}")
|
||||
else:
|
||||
parts.append(f"时长:4秒")
|
||||
parts.append(f"画面比例:16:9")
|
||||
parts.append(f"分辨率:480p")
|
||||
elif gen_type == "image":
|
||||
resolution_text = _to_clean_str(resolution)
|
||||
aspect_ratio_text = _to_clean_str(aspect_ratio)
|
||||
image_size_text = _to_clean_str(image_size)
|
||||
|
||||
if resolution_text:
|
||||
if resolution_text.startswith("分辨率"):
|
||||
parts.append(resolution_text)
|
||||
else:
|
||||
parts.append(f"分辨率{resolution_text}")
|
||||
|
||||
if aspect_ratio_text:
|
||||
if aspect_ratio_text.startswith("画布比例"):
|
||||
parts.append(aspect_ratio_text)
|
||||
else:
|
||||
parts.append(f"画布比例{aspect_ratio_text}")
|
||||
|
||||
if image_size_text:
|
||||
if image_size_text.startswith("像素尺寸"):
|
||||
parts.append(image_size_text)
|
||||
else:
|
||||
parts.append(f"像素尺寸{image_size_text}")
|
||||
|
||||
if image_size :
|
||||
parts.append(f"分辨率:{image_size}")
|
||||
parts.append(f"画布比例:{image_proportion}")
|
||||
parts.append(f"像素尺寸:{image_px}")
|
||||
else:
|
||||
parts.append(f"分辨率:2K")
|
||||
parts.append(f"画布比例:1:1")
|
||||
parts.append(f"像素尺寸:2048x2048")
|
||||
else:
|
||||
# 未知类型时尽量保守拼接已有参数,避免直接丢失生成参数。
|
||||
duration_text = _format_duration(duration)
|
||||
aspect_ratio_text = _to_clean_str(aspect_ratio)
|
||||
resolution_text = _to_clean_str(resolution)
|
||||
image_size_text = _to_clean_str(image_size)
|
||||
|
||||
if duration_text:
|
||||
parts.append(f"时长:{duration_text}")
|
||||
if aspect_ratio_text:
|
||||
parts.append(f"画面比例:{aspect_ratio_text}")
|
||||
if resolution_text:
|
||||
parts.append(f"分辨率:{resolution_text}")
|
||||
if image_size_text:
|
||||
parts.append(f"像素尺寸{image_size_text}")
|
||||
# 未知类型时返回原始字符
|
||||
return base_prompt
|
||||
|
||||
suffix = ",".join(parts)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user