模特库标签分页与全能创作收口:藏长视频、选择器分页
角色库导入打标签并支持筛选;模特库与全能创作角色/商品选择改为每页 20 条分页。临时限制成片 ≤60 秒,过滤对话里的超长时长选项,并收拢本地全能创作与后台用户相关修复。
This commit is contained in:
@@ -10,6 +10,65 @@ from .models import (
|
||||
)
|
||||
|
||||
|
||||
# 仅把可解释的阶段名返回给创作页。模型原始 reasoning 可能冗长、跑题或包含内部工作草稿,
|
||||
# 不能直接作为用户可见内容;前端据此展示「正在做什么」,避免异步规划看起来像卡住。
|
||||
_PUBLIC_AGENT_PROGRESS = {
|
||||
"starting": {
|
||||
"label": "正在读取创作要求",
|
||||
"detail": "已收到素材、角色与时长设定",
|
||||
},
|
||||
"reasoning": {
|
||||
"label": "正在分析素材与创作方向",
|
||||
"detail": "正在结合商品、角色和目标时长梳理方案",
|
||||
},
|
||||
"search_library": {
|
||||
"label": "正在查找可用素材",
|
||||
"detail": "正在核对当前创作需要的素材信息",
|
||||
},
|
||||
"write_strategy": {
|
||||
"label": "正在确定创作策略",
|
||||
"detail": "正在整理受众、核心卖点和整体表达方向",
|
||||
},
|
||||
"write_plan": {
|
||||
"label": "正在编排视频方案",
|
||||
"detail": "正在安排分段节奏,并锁定角色和商品的一致性",
|
||||
},
|
||||
"write_prompt": {
|
||||
"label": "正在整理出片指令",
|
||||
"detail": "正在把方案转成可直接生成的视频脚本",
|
||||
},
|
||||
"generate_image": {
|
||||
"label": "正在准备生成画面",
|
||||
"detail": "正在整理画面参考与生成条件",
|
||||
},
|
||||
"ask_user": {
|
||||
"label": "正在核对关键设定",
|
||||
"detail": "正在确认会影响成片效果的信息",
|
||||
},
|
||||
"responding": {
|
||||
"label": "正在整理回复内容",
|
||||
"detail": "马上把下一步呈现给你",
|
||||
},
|
||||
}
|
||||
|
||||
_PUBLIC_REASONING_DETAILS = {
|
||||
"brief": "正在理解这次创作的重点和限制",
|
||||
"product": "正在提炼商品卖点与可呈现的真实证据",
|
||||
"cast": "正在安排角色出镜方式与人物关系",
|
||||
"structure": "正在检查时长、分段节奏和前后衔接",
|
||||
"consistency": "正在锁定人物与商品在各段的一致性",
|
||||
"shots": "正在细化镜头、动作和出片表达",
|
||||
}
|
||||
|
||||
|
||||
def _public_agent_progress(phase: str, detail_key: str = "") -> dict[str, str]:
|
||||
"""把持久化的阶段键转换成用户可见的受控摘要。"""
|
||||
progress = dict(_PUBLIC_AGENT_PROGRESS.get(phase, _PUBLIC_AGENT_PROGRESS["starting"]))
|
||||
if phase == "reasoning":
|
||||
progress["detail"] = _PUBLIC_REASONING_DETAILS.get(detail_key, progress["detail"])
|
||||
return progress
|
||||
|
||||
|
||||
class ModelProviderSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ModelProvider
|
||||
@@ -114,17 +173,19 @@ class CreationConversationSerializer(serializers.ModelSerializer):
|
||||
|
||||
message_count = serializers.SerializerMethodField()
|
||||
cover_url = serializers.SerializerMethodField()
|
||||
agent_progress = serializers.SerializerMethodField()
|
||||
|
||||
class Meta:
|
||||
model = CreationConversation
|
||||
fields = [
|
||||
"id", "title", "mode", "preset", "params", "status",
|
||||
"agent_status", "agent_started_at",
|
||||
"agent_progress",
|
||||
"message_count", "cover_url",
|
||||
"last_active_at", "created_at", "updated_at",
|
||||
]
|
||||
read_only_fields = [
|
||||
"id", "status", "agent_status", "agent_started_at",
|
||||
"id", "status", "agent_status", "agent_started_at", "agent_progress",
|
||||
"message_count", "cover_url",
|
||||
"last_active_at", "created_at", "updated_at",
|
||||
]
|
||||
@@ -149,6 +210,32 @@ class CreationConversationSerializer(serializers.ModelSerializer):
|
||||
first = assets[0] or {}
|
||||
return first.get("cover") or first.get("url") or ""
|
||||
|
||||
def get_agent_progress(self, obj):
|
||||
"""规划期间只返回受控阶段文案,绝不把模型原始 thinking 暴露给页面。"""
|
||||
if obj.agent_status != CreationConversation.AgentStatus.PLANNING:
|
||||
return None
|
||||
memory = obj.memory if isinstance(obj.memory, dict) else {}
|
||||
phase = str(memory.get("agent_progress_phase") or "")
|
||||
if not phase:
|
||||
return None
|
||||
detail_key = str(memory.get("agent_progress_detail_key") or "")
|
||||
progress = _public_agent_progress(phase, detail_key)
|
||||
history: list[dict[str, str]] = []
|
||||
for item in memory.get("agent_progress_history") or []:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
history.append(
|
||||
_public_agent_progress(
|
||||
str(item.get("phase") or ""),
|
||||
str(item.get("detail_key") or ""),
|
||||
)
|
||||
)
|
||||
# 兼容服务端升级前已开始的轮次:至少显示当前一条进度。
|
||||
if not history or history[-1] != progress:
|
||||
history.append(progress)
|
||||
progress["history"] = history[-12:]
|
||||
return progress
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
# mode 定死:允许传但忽略,避免前端误改后顶栏参数与已生成内容对不上
|
||||
validated_data.pop("mode", None)
|
||||
|
||||
Reference in New Issue
Block a user