优化住流程和添加复刻视频页面
This commit is contained in:
@@ -15,7 +15,13 @@ from django.db import connections, transaction
|
||||
from django.utils import timezone
|
||||
|
||||
from apps.ai.models import AITask, ModelConfig
|
||||
from apps.ai.script_agent import stream_script_agent
|
||||
from apps.ai.script_agent import (
|
||||
PRESENTATION_FORMATS,
|
||||
VIDEO_STRUCTURES,
|
||||
persona_label,
|
||||
recommend_script_setup,
|
||||
stream_script_agent,
|
||||
)
|
||||
from apps.ai.services import (
|
||||
collect_video_review_blockers,
|
||||
create_export_job,
|
||||
@@ -364,6 +370,17 @@ def _consume_script_agent(job: QuickCreateJob) -> None:
|
||||
if model_config is None:
|
||||
raise ValueError(f"{QUICK_SCRIPT_MODEL_NAME} is not configured")
|
||||
|
||||
wizard = dict((project.metadata or {}).get("wizard") or {})
|
||||
product = project.product
|
||||
rec = recommend_script_setup(
|
||||
getattr(product, "category", "") or "",
|
||||
getattr(product, "title", "") or "",
|
||||
)
|
||||
fmt = wizard.get("presentation_format") or rec["format"]
|
||||
structure = wizard.get("video_structure") or rec["structure"]
|
||||
persona = wizard.get("persona") or rec["persona"]
|
||||
format_label = PRESENTATION_FORMATS.get(fmt, fmt)
|
||||
structure_label = VIDEO_STRUCTURES.get(structure, structure)
|
||||
error_detail = ""
|
||||
stream = stream_script_agent(
|
||||
project=project,
|
||||
@@ -371,15 +388,16 @@ def _consume_script_agent(job: QuickCreateJob) -> None:
|
||||
model_config=model_config,
|
||||
mode="auto",
|
||||
user_prompt=(
|
||||
"请根据商品名称与商品参考图信息,自动推荐最适合的"
|
||||
f"{settings['total_duration']}秒、{settings['aspect_ratio']}画幅带货方案。"
|
||||
"请根据商品名称、品类与商品参考图信息,按推荐的"
|
||||
f"{format_label} × {structure_label} × {persona_label(persona)},"
|
||||
f"生成{settings['total_duration']}秒、{settings['aspect_ratio']}画幅带货方案。"
|
||||
),
|
||||
aspect_ratio=settings["aspect_ratio"],
|
||||
total_duration=settings["total_duration"],
|
||||
presentation_format="oral",
|
||||
video_structure="pain",
|
||||
presentation_format=fmt,
|
||||
video_structure=structure,
|
||||
entry_source="ai",
|
||||
persona="reviewer",
|
||||
persona=persona,
|
||||
)
|
||||
# 豆包思考模型会连续吐几百帧 reasoning。原先每帧 refresh_from_db,远程 MySQL
|
||||
# 一抖动就会把生成器关掉,模型调用被误记成 stream aborted (client disconnected)。
|
||||
|
||||
Reference in New Issue
Block a user