全能创作闸门与多人物定妆收口
主页已填卖点跳过卖点确认;按图片内容创作不再重复问品牌品名;方案卡支撑改为 P0/P1/P2;多人物视频一次生成多张定妆图并在出片前校验数量;超管登录直进后台。
This commit is contained in:
@@ -591,23 +591,45 @@ def finish_generating_message(message: CreationMessage, *, assets: list[dict], m
|
||||
).first()
|
||||
if asset is None:
|
||||
return fail_generating_message(message, "人物参考已生成,但未找到可锁定的图片资产")
|
||||
cast_index = int(original_payload.get("cast_index") or 1)
|
||||
cast_total = int(original_payload.get("cast_total") or 1)
|
||||
cast_model_name = str(original_payload.get("cast_model_name") or "").strip()
|
||||
is_pet = "宠物" in str(conversation.preset or "")
|
||||
if not cast_model_name:
|
||||
if is_pet:
|
||||
cast_model_name = "平台生成宠物角色"
|
||||
elif cast_total > 1:
|
||||
cast_model_name = f"平台生成出镜人物{cast_index}"
|
||||
else:
|
||||
cast_model_name = "平台生成出镜人物"
|
||||
model = Model.objects.filter(
|
||||
team=conversation.team,
|
||||
portrait_asset=asset,
|
||||
is_deleted=False,
|
||||
purged_at__isnull=True,
|
||||
).first()
|
||||
is_pet = "宠物" in str(conversation.preset or "")
|
||||
if model is None:
|
||||
model = Model.objects.create(
|
||||
team=conversation.team,
|
||||
created_by=conversation.created_by,
|
||||
name="平台生成宠物角色" if is_pet else "平台生成出镜人物",
|
||||
name=cast_model_name,
|
||||
source=Model.Source.AI,
|
||||
portrait_asset=asset,
|
||||
description="由全能创作生成并锁定的宠物角色。" if is_pet else "由全能创作生成并锁定的视频出镜人物。",
|
||||
metadata={"feature": "omni_create", "conversation_id": str(conversation.id)},
|
||||
description=(
|
||||
"由全能创作生成并锁定的宠物角色。"
|
||||
if is_pet else
|
||||
"由全能创作生成并锁定的视频出镜人物。"
|
||||
),
|
||||
metadata={
|
||||
"feature": "omni_create",
|
||||
"conversation_id": str(conversation.id),
|
||||
"cast_index": cast_index,
|
||||
"cast_total": cast_total,
|
||||
},
|
||||
)
|
||||
elif model.name != cast_model_name and cast_total > 1:
|
||||
model.name = cast_model_name
|
||||
model.save(update_fields=["name", "updated_at"])
|
||||
pin_refs(conversation, [{
|
||||
"type": "model",
|
||||
"id": str(model.id),
|
||||
@@ -616,10 +638,37 @@ def finish_generating_message(message: CreationMessage, *, assets: list[dict], m
|
||||
}])
|
||||
memory = dict(conversation.memory or {})
|
||||
memory["person_source"] = "platform_generate"
|
||||
model_ids = [
|
||||
str(item)
|
||||
for item in (memory.get("person_cast_model_ids") or [])
|
||||
if str(item).strip()
|
||||
]
|
||||
model_id = str(model.id)
|
||||
if model_id not in model_ids:
|
||||
model_ids.append(model_id)
|
||||
memory["person_cast_model_ids"] = model_ids
|
||||
memory["person_model_id"] = model_id
|
||||
pending = int(memory.get("person_cast_pending") or cast_total or 1)
|
||||
pending = max(0, pending - 1)
|
||||
memory["person_cast_pending"] = pending
|
||||
memory["person_cast_total"] = int(memory.get("person_cast_total") or cast_total or 1)
|
||||
if pending > 0:
|
||||
# 还有其它角色定妆图在生成:继续等待,不打断用户确认
|
||||
memory["person_source_pending"] = True
|
||||
memory.pop("person_source_ready", None)
|
||||
memory.pop("person_confirm_pending", None)
|
||||
conversation.memory = memory
|
||||
conversation.status = CreationConversation.Status.RUNNING
|
||||
conversation.agent_status = CreationConversation.AgentStatus.IDLE
|
||||
conversation.last_active_at = timezone.now()
|
||||
conversation.save(update_fields=[
|
||||
"memory", "status", "agent_status", "last_active_at", "updated_at",
|
||||
])
|
||||
return message
|
||||
|
||||
memory["person_source_pending"] = False
|
||||
memory["person_source_ready"] = True
|
||||
memory["person_confirm_pending"] = True
|
||||
memory["person_model_id"] = str(model.id)
|
||||
conversation.memory = memory
|
||||
conversation.status = CreationConversation.Status.RUNNING
|
||||
conversation.agent_status = CreationConversation.AgentStatus.AWAITING_USER
|
||||
@@ -627,24 +676,38 @@ def finish_generating_message(message: CreationMessage, *, assets: list[dict], m
|
||||
conversation.save(update_fields=[
|
||||
"memory", "status", "agent_status", "last_active_at", "updated_at",
|
||||
])
|
||||
total = int(memory.get("person_cast_total") or 1)
|
||||
if is_pet:
|
||||
confirm_text = "宠物角色已生成。你看这只宠物合适吗?是否使用这个宠物角色继续创作?"
|
||||
reply_hint = "回复「使用这个角色」继续,或说明想要的宠物品种与外观…"
|
||||
regen = "重新生成一个宠物角色"
|
||||
upload = "我上传宠物参考图"
|
||||
upload_label = "上传其他宠物"
|
||||
elif total > 1:
|
||||
confirm_text = (
|
||||
f"已生成 {total} 位出镜角色定妆图。长视频会按这些图分别锁脸,"
|
||||
"避免前后形象漂移。你看这组角色合适吗?是否使用这些角色继续创作?"
|
||||
)
|
||||
reply_hint = "回复「使用这个角色」继续,或说明想调整哪一位…"
|
||||
regen = "重新生成一个角色"
|
||||
upload = "我上传人物参考图"
|
||||
upload_label = "上传其他人物"
|
||||
else:
|
||||
confirm_text = "人物参考已生成。你看这位角色合适吗?是否使用这个角色继续创作?"
|
||||
reply_hint = "回复「使用这个角色」继续,或说明想调整的地方…"
|
||||
regen = "重新生成一个角色"
|
||||
upload = "我上传人物参考图"
|
||||
upload_label = "上传其他人物"
|
||||
append_message(
|
||||
conversation,
|
||||
role="assistant",
|
||||
text=(
|
||||
"宠物角色已生成。你看这只宠物合适吗?是否使用这个宠物角色继续创作?"
|
||||
if is_pet else
|
||||
"人物参考已生成。你看这位角色合适吗?是否使用这个角色继续创作?"
|
||||
),
|
||||
text=confirm_text,
|
||||
payload={
|
||||
"reply_hint": (
|
||||
"回复「使用这个角色」继续,或说明想要的宠物品种与外观…"
|
||||
if is_pet else
|
||||
"回复「使用这个角色」继续,或说明想调整的地方…"
|
||||
),
|
||||
"reply_hint": reply_hint,
|
||||
"reply_options": [
|
||||
{"label": "使用这个角色", "text": "使用这个角色继续创作"},
|
||||
{"label": "重新生成一个", "text": "重新生成一个宠物角色" if is_pet else "重新生成一个角色"},
|
||||
{"label": "上传其他宠物" if is_pet else "上传其他人物", "text": "我上传宠物参考图" if is_pet else "我上传人物参考图"},
|
||||
{"label": "重新生成一个", "text": regen},
|
||||
{"label": upload_label, "text": upload},
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user