From a64ae95eb8235c8b9a6d299cc842ea6b9e1a7ace Mon Sep 17 00:00:00 2001
From: hit-cxf <2024111082@stu.hit.edu.cn>
Date: Thu, 02 Apr 2026 14:56:03 +0800
Subject: [PATCH] 更新了第一阶段生成剧本的提示词
---
aigc-director/aigc-claw/backend/core/agents/video_agent.py | 23 +
aigc-director/aigc-claw/backend/prompts/script/act_extract_en.txt | 54 ++
aigc-director/aigc-claw/backend/prompts/script/step_outline_en.txt | 2
aigc-director/aigc-claw/backend/prompts/script/logline_generate_en.txt | 14
aigc-director/aigc-claw/backend/prompts/script/meta_extract_zh.txt | 6
aigc-director/aigc-claw/backend/prompts/script/logline_generate_zh.txt | 7
aigc-director/aigc-claw/backend/refactor_agent.py | 42 ++
aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx | 12
aigc-director/aigc-claw/backend/prompts/script/logline_check_en.txt | 0
aigc-director/aigc-claw/backend/prompts/script/logline_check_zh.txt | 0
aigc-director/aigc-claw/backend/remove_prompts.py | 18
aigc-director/aigc-claw/backend/core/agents/script_agent.py | 493 +------------------------
aigc-director/aigc-claw/backend/prompts/script/step_outline_zh.txt | 2
aigc-director/aigc-claw/backend/tool/image_client.py | 10
aigc-director/aigc-claw/backend/prompts/loader.py | 16
aigc-director/aigc-claw/backend/prompts/script/micro_meta_extract_en.txt | 6
aigc-director/aigc-claw/backend/prompts/script/micro_meta_extract_zh.txt | 6
aigc-director/aigc-claw/backend/core/agents/storyboard_agent.py | 59 ++-
aigc-director/aigc-claw/backend/prompts/script/consolidate_zh.txt | 24 +
aigc-director/aigc-claw/backend/core/agents/character_agent.py | 51 ++
aigc-director/aigc-claw/backend/prompts/storyboard/shot_zh.txt | 29 +
aigc-director/aigc-claw/backend/prompts/script/consolidate_en.txt | 21 +
aigc-director/aigc-claw/backend/prompts/script/beat_sheet_zh.txt | 9
search.log | 0
/dev/null | 11
aigc-director/aigc-claw/backend/prompts/script/beat_sheet_en.txt | 7
aigc-director/aigc-claw/backend/prompts/script/micro_beat_sheet_en.txt | 5
aigc-director/aigc-claw/backend/prompts/script/micro_step_outline_zh.txt | 11
aigc-director/aigc-claw/backend/prompts/storyboard/expand_zh.txt | 41 ++
aigc-director/aigc-claw/backend/prompts/script/meta_extract_en.txt | 6
aigc-director/aigc-claw/backend/prompts/script/logline_extract_zh.txt | 0
aigc-director/aigc-claw/backend/prompts/script/act_extract_zh.txt | 54 ++
aigc-director/aigc-claw/backend/prompts/script/logline_extract_en.txt | 7
aigc-director/aigc-claw/backend/prompts/script/micro_step_outline_en.txt | 24 +
aigc-director/aigc-claw/backend/core/agents/reference_agent.py | 24
aigc-director/aigc-claw/backend/prompts/script/micro_beat_sheet_zh.txt | 5
aigc-director/aigc-claw/frontend/components/stages/StageActions.tsx | 19
37 files changed, 562 insertions(+), 556 deletions(-)
diff --git a/aigc-director/aigc-claw/backend/core/agents/character_agent.py b/aigc-director/aigc-claw/backend/core/agents/character_agent.py
index e243f90..4dfedde 100644
--- a/aigc-director/aigc-claw/backend/core/agents/character_agent.py
+++ b/aigc-director/aigc-claw/backend/core/agents/character_agent.py
@@ -411,9 +411,39 @@
select_sets = intervention.get("select_settings", {}) # {asset_id: path}
update_descriptions = intervention.get("update_descriptions", {}) # {characters: {}, settings: {}}
- script_data = self._read_script_data(sid)
- chars_desc = script_data["characters"]
- sets_desc = script_data["settings"]
+ # 优先从 input_data (artifacts) 中恢复当前状态,确保之前在界面上做的修改能保留
+ chars_desc = {}
+ sets_desc = {}
+
+ # input_data.get("characters") 在正常流程中是 list,需转换为 dict 以便后续 .items() 使用
+ input_chars = input_data.get("characters", [])
+ if isinstance(input_chars, list):
+ for c in input_chars:
+ if isinstance(c, dict) and "id" in c:
+ chars_desc[c["id"]] = {
+ "name": c.get("name", ""),
+ "description": c.get("description", ""),
+ "species": c.get("species", ""),
+ }
+ elif isinstance(input_chars, dict):
+ chars_desc = input_chars
+
+ input_sets = input_data.get("settings", [])
+ if isinstance(input_sets, list):
+ for s in input_sets:
+ if isinstance(s, dict) and "id" in s:
+ sets_desc[s["id"]] = {
+ "name": s.get("name", ""),
+ "description": s.get("description", ""),
+ }
+ elif isinstance(input_sets, dict):
+ sets_desc = input_sets
+
+ # 如果 input_data 为空(比如后端重启后的第一次介入),再读原始文件
+ if not chars_desc and not sets_desc:
+ script_data = self._read_script_data(sid)
+ chars_desc = script_data["characters"]
+ sets_desc = script_data["settings"]
# 处理描述更新
if update_descriptions:
@@ -512,9 +542,18 @@
# ═══════════ 正常流程: 全量首次生成 ═══════════
self._report_progress("角色设计", "读取剧本数据...", 5)
- script_data = self._read_script_data(sid)
- chars_desc = script_data["characters"]
- sets_desc = script_data["settings"]
+ # 优先从 input_data 获取素材定义,如果没有再从原始剧本文件读取
+ chars_desc, sets_desc = {}, {}
+ if input_data and isinstance(input_data, dict):
+ if "characters" in input_data:
+ chars_desc = input_data["characters"]
+ if "settings" in input_data:
+ sets_desc = input_data["settings"]
+
+ if not chars_desc and not sets_desc:
+ script_data = self._read_script_data(sid)
+ chars_desc = script_data["characters"]
+ sets_desc = script_data["settings"]
if not chars_desc and not sets_desc:
raise Exception("未能从剧本中读取到角色或场景描述数据")
diff --git a/aigc-director/aigc-claw/backend/core/agents/reference_agent.py b/aigc-director/aigc-claw/backend/core/agents/reference_agent.py
index ab1078d..300fbb2 100644
--- a/aigc-director/aigc-claw/backend/core/agents/reference_agent.py
+++ b/aigc-director/aigc-claw/backend/core/agents/reference_agent.py
@@ -469,15 +469,23 @@
ark_base_url=settings.ARK_BASE_URL,
)
- # 读取数据
- with open(result_file, 'r', encoding='utf-8') as f:
- results = json.load(f)
- story_data = results[str(sid)]
-
- storyboard = story_data.get('storyboard', {})
- shots = storyboard.get('shots', [])
+ # 优先从 input_data (artifacts) 中获取分镜数据,如果没有再读原始文件
+ shots = []
+ if input_data and isinstance(input_data, dict) and "shots" in input_data:
+ shots = input_data["shots"]
+ logger.info(f"[ReferenceAgent] 使用来自 input_data 的 {len(shots)} 个分镜数据")
+
if not shots:
- raise Exception("未找到分镜数据(storyboard.shots),请先完成阶段3")
+ # 备选:从结果文件读取
+ with open(result_file, 'r', encoding='utf-8') as f:
+ results = json.load(f)
+ story_data = results[str(sid)]
+ storyboard = story_data.get('storyboard', {})
+ shots = storyboard.get('shots', [])
+ logger.info(f"[ReferenceAgent] 使用来自结果文件的 {len(shots)} 个分镜数据")
+
+ if not shots:
+ raise Exception("未找到分镜数据,请先完成阶段3")
script_json = story_data.get('script_json', {})
diff --git a/aigc-director/aigc-claw/backend/core/agents/script_agent.py b/aigc-director/aigc-claw/backend/core/agents/script_agent.py
index 77f9c11..ec1fc72 100644
--- a/aigc-director/aigc-claw/backend/core/agents/script_agent.py
+++ b/aigc-director/aigc-claw/backend/core/agents/script_agent.py
@@ -14,6 +14,11 @@
from datetime import datetime, timezone
from typing import Any, Optional, Dict
+from prompts.loader import load_prompt_with_fallback
+
+def _get_script_prompt(name: str, lang: str = "zh") -> str:
+ return load_prompt_with_fallback("script", name, lang, "zh")
+
from .base_agent import AgentInterface
# 导入提示词加载器
@@ -21,437 +26,8 @@
logger = logging.getLogger(__name__)
-
-# 懒加载提示词 - 优先从外部文件加载,失败则返回空
-def _p(category: str, name: str, lang: str = 'zh') -> str:
- """Load prompt from external file, return empty string if not found"""
- try:
- return load_prompt(category, name, lang)
- except FileNotFoundError:
- return ""
-
-
-# 从外部文件加载提示词的辅助函数
-def _load_prompt(category: str, name: str, fallback: str) -> str:
- """Load prompt from external file, fallback to hardcoded string"""
- try:
- return load_prompt(category, name, 'zh')
- except FileNotFoundError:
- return fallback
-
-# =============================================================
-# Phase 1A: Logline 生成(扩写创意 → 3 个 Logline 方案)
-# =============================================================
-
-LOGLINE_GENERATE_PROMPT_ZH = (
- "你是资深制片人。请将以下灵感扩展为 3 个不同的 Logline(故事大纲)。\n"
- "要求:\n"
- "- 明确主角(Who)、目标(Goal)、核心障碍(Conflict)和反转(Twist)\n"
- "- 确定故事的 Theme(潜在主题)\n"
- "- Logline 按照\"如果…会怎样\"的句式描述\n"
- "- 3 个 Logline 应风格各异、各有侧重\n\n"
- "输入内容:{idea}\n\n"
- "请严格按如下 JSON 数组格式输出(直接输出纯JSON,不要用```包裹,不要添加任何其他文字):\n"
- '[{{"logline":"如果...会怎样","who":"主角描述","goal":"目标","conflict":"核心障碍","twist":"反转","theme":"潜在主题"}}]\n'
- "输出恰好 3 个元素的 JSON 数组。"
-)
-
-LOGLINE_GENERATE_PROMPT_EN = (
- "You are a senior producer. Expand the following idea into 3 different Loglines.\n"
- "Requirements:\n"
- "- Define the protagonist (Who), Goal, core Conflict, and Twist\n"
- "- Identify the story's Theme\n"
- "- Each Logline should use 'What if...' format\n"
- "- The 3 Loglines should be diverse in style and focus\n\n"
- "Input: {idea}\n\n"
- "Output ONLY a JSON array with exactly 3 elements (no code block markers, no other text):\n"
- '[{{"logline":"What if...","who":"protagonist","goal":"goal","conflict":"conflict","twist":"twist","theme":"theme"}}]'
-)
-
-# =============================================================
-# Phase 1B: Logline 检测 & 提取(未勾选扩写时)
-# =============================================================
-
-LOGLINE_CHECK_PROMPT_ZH = (
- "请判断以下文本是否包含足够的叙事要素,能够从中总结出一个完整故事的 Logline。\n"
- "(完整 Logline 需涵盖:主角、目标、核心障碍、反转和主题)\n\n"
- "文本:{idea}\n\n"
- "只回答 Yes 或 No,不要添加任何其他内容。"
-)
-
-LOGLINE_CHECK_PROMPT_EN = (
- "Determine if the following text contains enough narrative elements for a complete story Logline.\n"
- "(Needs: protagonist, goal, conflict, twist, and theme)\n\n"
- "Text: {idea}\n\n"
- "Answer only Yes or No."
-)
-
-LOGLINE_EXTRACT_PROMPT_ZH = (
- "你是资深制片人。请从以下文本中总结提取 Logline 及故事五要素。\n"
- "Logline 请使用\"如果…会怎样\"的句式。\n\n"
- "文本:{idea}\n\n"
- "请严格按如下 JSON 格式输出(直接输出纯JSON,不要用```包裹,不要添加任何其他文字):\n"
- '{{"logline":"如果...会怎样","who":"主角描述","goal":"目标","conflict":"核心障碍","twist":"反转","theme":"潜在主题"}}'
-)
-
-LOGLINE_EXTRACT_PROMPT_EN = (
- "You are a senior producer. Extract the Logline and five story elements from the following text.\n"
- "The Logline should use 'What if...' format.\n\n"
- "Text: {idea}\n\n"
- "Output ONLY valid JSON (no code block markers, no other text):\n"
- '{{"logline":"What if...","who":"protagonist","goal":"goal","conflict":"conflict","twist":"twist","theme":"theme"}}'
-)
-
-# =============================================================
-# Phase 2A: 节拍表 (Save the Cat! Beat Sheet)
-# =============================================================
-
-BEAT_SHEET_PROMPT_ZH = (
- "你是好莱坞编剧导师。请根据以下故事线,使用 Save the Cat! 节拍表将故事拆解为四幕结构。\n\n"
- "必须包含以下四个关键节拍(起承转合):\n"
- "第一幕 - 激励事件(Inciting Incident):建立世界观和主角现状,发生打破平衡的事件\n"
- "第二幕 - 进入新世界(Break into Two):主角踏上旅程,面对挑战和考验,副线展开\n"
- "第三幕 - 灵魂黑夜(Dark Night of the Soul):主角遭受最大打击,陷入低谷\n"
- "第四幕 - 高潮决战(Finale):主角获得顿悟,最终决战,故事收束\n\n"
- "请确保:逻辑严密、冲突逐步升级、每一幕有清晰的转折点。\n\n"
- "故事线:\n{draft}\n\n"
- "故事风格:{style}\n\n"
- "请直接输出四幕节拍表,每一幕用\"【第X幕 - 名称】\"标记开始,详细描述该幕的情节要点、角色发展和关键转折。"
-)
-
-BEAT_SHEET_PROMPT_EN = (
- "You are a Hollywood screenwriting mentor. Break down the following storyline into a 4-act structure "
- "using the Save the Cat! Beat Sheet.\n\n"
- "Must include these four key beats:\n"
- "Act 1 - Inciting Incident: Establish the world and protagonist's status quo, then a disruptive event\n"
- "Act 2 - Break into Two: Protagonist embarks on journey, faces challenges, B-story unfolds\n"
- "Act 3 - Dark Night of the Soul: Protagonist suffers the biggest blow, hits rock bottom\n"
- "Act 4 - Finale: Protagonist gains epiphany, final confrontation, story resolves\n\n"
- "Ensure: tight logic, escalating conflict, clear turning points in each act.\n\n"
- "Storyline:\n{draft}\n\n"
- "Story style: {style}\n\n"
- "Output the 4-act beat sheet directly. Start each act with '[Act X - Name]' heading. "
- "Detail the plot points, character development and key turning points for each act."
-)
-
-# =============================================================
-# Phase 2B: 分场大纲 (Step Outline, 逐幕生成)
-# =============================================================
-
-STEP_OUTLINE_PROMPT_ZH = (
- "你是分场导演。以下是完整的四幕节拍表:\n\n"
- "{beat_sheet}\n\n"
- "请将第{act_number}幕({act_name})转化为详细的分场大纲。\n\n"
- "格式要求(每场一段):\n"
- "[场次编号]. [地点(室内/室外)] - [日/夜]\n"
- "[核心动作]:详细描述该场戏发生了什么,包含完整的对话、动作和表情描写。\n"
- "[情感转变]:描述主角在本场戏开始到结束的情绪变化(+/-)。\n"
- "[出场角色]:列出本场出现的所有角色。\n\n"
- "要求:\n"
- "- 每个角色都要有详细的外貌描写(发型、眼睛颜色、体型、服装颜色和款式等视觉特征)\n"
- "- **重要:外貌描写必须是静态的、贯穿全剧保持一致的特征,不要随剧情发展而变化**\n"
- " - 例如:不要写\"他穿着破碎的衣服\"这种随情节变化的描写\n"
- " - 应该写:\"他身穿蓝色衬衫,黑色长裤\"这种固定的服装描述\n"
- "- 每个场景都要有详细的环境、布局、色彩与氛围描写\n"
- "- 分场数量根据情节长度和节奏自行决定,确保叙事节奏合理\n"
- "- 对话用双引号标注,对话内容真实生动\n"
- "- 场次编号从 {scene_start} 开始递增\n"
- "- 故事风格:{style}\n\n"
- "请直接输出分场大纲,不要添加幕次标题或额外说明。"
-)
-
-STEP_OUTLINE_PROMPT_EN = (
- "You are a scene director. Here is the complete 4-act beat sheet:\n\n"
- "{beat_sheet}\n\n"
- "Convert Act {act_number} ({act_name}) into a detailed step outline.\n\n"
- "Format for each scene:\n"
- "[Scene number]. [Location (Indoor/Outdoor)] - [Day/Night]\n"
- "[Core Action]: Detailed description of what happens, including dialogue, actions and expressions.\n"
- "[Emotional Shift]: Describe the protagonist's emotional change from start to end (+/-).\n"
- "[Characters Present]: List all characters appearing in this scene.\n\n"
- "Requirements:\n"
- "- Each character needs detailed physical descriptions (hair, eyes, build, clothing details)\n"
- "- **IMPORTANT: Physical descriptions must be STATIC and consistent throughout the entire story - do NOT change with plot development**\n"
- " - For example: do NOT write \"wearing torn clothes\" which changes with the plot\n"
- " - Instead write: \"wearing a blue shirt and black pants\" which is a fixed clothing description\n"
- "- Each scene needs detailed environment, layout, color and atmosphere descriptions\n"
- "- Number of scenes based on plot length and pacing\n"
- "- Dialogue marked with double quotes, natural and vivid\n"
- "- Scene numbers start from {scene_start} and increment\n"
- "- Story style: {style}\n\n"
- "Output the step outline directly, without act headings or extra notes."
-)
-
ACT_NAMES_ZH = {1: "激励事件", 2: "进入新世界", 3: "灵魂黑夜", 4: "高潮决战"}
ACT_NAMES_EN = {1: "Inciting Incident", 2: "Break into Two", 3: "Dark Night of the Soul", 4: "Finale"}
-
-# =============================================================
-# Micro-film 微电影模式专用提示词
-# =============================================================
-
-MICRO_BEAT_SHEET_PROMPT_ZH = (
- "你是微电影编剧专家。请根据以下故事线,将故事压缩为一个紧凑的单幕剧情概要。\n\n"
- "要求:\n"
- "- 叙事节奏快,情节紧凑精炼,没有拖沓的铺垫\n"
- "- 全部内容在一幕内完成,不分幕\n"
- "- 保留核心冲突和情感转折,去掉多余叙事\n"
- "- 场景数量控制在 3-6 场\n"
- "- 适合 1-3 分钟的微电影\n\n"
- "故事线:\n{draft}\n\n"
- "故事风格:{style}\n\n"
- "请直接输出紧凑的剧情概要,描述场景发展、核心动作和情感转折。"
-)
-
-MICRO_BEAT_SHEET_PROMPT_EN = (
- "You are a micro-film screenwriting expert. Compress the following storyline "
- "into a compact single-act plot summary.\n\n"
- "Requirements:\n"
- "- Fast narrative pacing, concise and tight plot\n"
- "- All content in a single act, no act divisions\n"
- "- Keep core conflict and emotional turns, remove unnecessary setup\n"
- "- 3-6 scenes total\n"
- "- Suitable for a 1-3 minute short film\n\n"
- "Storyline:\n{draft}\n\n"
- "Story style: {style}\n\n"
- "Output a compact plot summary directly, describing scene progression, "
- "core actions and emotional shifts."
-)
-
-MICRO_STEP_OUTLINE_PROMPT_ZH = (
- "你是分场导演。以下是微电影剧情概要:\n\n"
- "{beat_sheet}\n\n"
- "请将其转化为详细的分场大纲。\n\n"
- "格式要求(每场一段):\n"
- "[场次编号]. [地点(室内/室外)] - [日/夜]\n"
- "[核心动作]:详细描述该场戏发生了什么,包含完整的对话、动作和表情描写。\n"
- "[情感转变]:描述主角在本场戏开始到结束的情绪变化(+/-)。\n"
- "[出场角色]:列出本场出现的所有角色。\n\n"
- "要求:\n"
- "- 每个角色都要有详细的外貌描写(发型、眼睛颜色、体型、服装颜色和款式等视觉特征)\n"
- "- **重要:外貌描写必须是静态的、贯穿全剧保持一致的特征,不要随剧情发展而变化**\n"
- " - 例如:不要写\"他穿着破碎的衣服\"这种随情节变化的描写\n"
- " - 应该写:\"他身穿蓝色衬衫,黑色长裤\"这种固定的服装描述\n"
- "- 每个场景都要有详细的环境、布局、色彩与氛围描写\n"
- "- 分场数量 3-6 场,叙事紧凑快节奏\n"
- "- 对话用双引号标注,对话内容真实生动\n"
- "- 场次编号从 1 开始递增\n"
- "- 故事风格:{style}\n\n"
- "请直接输出分场大纲,不要添加额外说明。"
-)
-
-MICRO_STEP_OUTLINE_PROMPT_EN = (
- "You are a scene director. Here is the micro-film plot summary:\n\n"
- "{beat_sheet}\n\n"
- "Convert it into a detailed step outline.\n\n"
- "Format for each scene:\n"
- "[Scene number]. [Location (Indoor/Outdoor)] - [Day/Night]\n"
- "[Core Action]: Detailed description including dialogue, actions and expressions.\n"
- "[Emotional Shift]: Protagonist's emotional change from start to end (+/-).\n"
- "[Characters Present]: All characters appearing in this scene.\n\n"
- "Requirements:\n"
- "- Each character needs detailed physical descriptions (hair, eyes, build, clothing)\n"
- "- **IMPORTANT: Physical descriptions must be STATIC and consistent throughout the entire story - do NOT change with plot development**\n"
- " - For example: do NOT write \"wearing torn clothes\" which changes with the plot\n"
- " - Instead write: \"wearing a blue shirt and black pants\" which is a fixed clothing description\n"
- "- Each scene needs detailed environment, layout, color and atmosphere descriptions\n"
- "- 3-6 scenes total, compact and fast-paced\n"
- "- Dialogue marked with double quotes, natural and vivid\n"
- "- Scene numbers start from 1 and increment\n"
- "- Story style: {style}\n\n"
- "Output the step outline directly, without extra notes."
-)
-
-MICRO_META_EXTRACT_PROMPT_ZH = (
- "你是专业的剧本分析师。以下是微电影剧情概要:\n\n"
- "{beat_sheet}\n\n"
- "请从中提取以下信息,以纯JSON格式输出(不要用```包裹):\n"
- '{{"title":"故事标题(2-8字)","logline":"一句话概括故事(30字以内)",'
- '"genre":["类型1","类型2"],"synopsis":"完整故事梗概(50-100字)",'
- '"mood":"影片情绪基调"}}'
-)
-
-MICRO_META_EXTRACT_PROMPT_EN = (
- "You are a professional script analyst. Here is the micro-film plot summary:\n\n"
- "{beat_sheet}\n\n"
- "Extract the following information as pure JSON (no code blocks):\n"
- '{{"title":"Story title (short)","logline":"One sentence summary",'
- '"genre":["genre1","genre2"],"synopsis":"Complete synopsis (50-100 words)",'
- '"mood":"Overall mood"}}'
-)
-
-# =============================================================
-# Phase 3A: 单幕结构化 JSON 提取
-# =============================================================
-
-ACT_EXTRACT_INTRO_ZH = (
- "你是一个专业的剧本分析师。请仔细阅读以下第{act_number}幕的分场大纲,从中提取并整理为标准JSON格式。\n\n"
- "分场大纲:\n{outline}\n\n"
- "请严格按照以下JSON结构输出(直接输出纯JSON,不要用```包裹,不要添加注释或任何其他文字):\n\n"
-)
-
-ACT_EXTRACT_INTRO_EN = (
- "You are a professional script analyst. Read the following Act {act_number} step outline carefully "
- "and extract it into a structured JSON format.\n\n"
- "Step outline:\n{outline}\n\n"
- "Output ONLY valid JSON in the following structure (no code block markers, no comments, no other text):\n\n"
-)
-
-ACT_EXTRACT_SCHEMA_ZH = """{{
- "characters": [
- {{
- "name": "角色全名",
- "character_id": "char_加8位随机字母数字",
- "description": "外貌描写: 含发型、体型、服装颜色和款式等视觉特征, 不要描述眼睛颜色, 面部不要有文字等特殊符号, 形象要正常(可以前卫时髦但不能恐怖灵异), 50-80字, 不要用比喻",
- "personality": ["性格特征1", "性格特征2", "性格特征3"],
- "motivation": "角色核心动机",
- "arc_description": "角色成长弧线",
- "role": "主角 或 配角 或 背景",
- "age": "年龄",
- "species": "人类 或 具体动物种类"
- }}
- ],
- "settings": [
- {{
- "name": "场景名称(室内) 或 场景名称(室外)",
- "setting_id": "set_加8位随机字母数字",
- "description": "环境布局、色彩、光线、氛围等视觉细节, 80-120字, 不要包含人物或动物"
- }}
- ],
- "scenes": [
- {{
- "scene_number": {scene_start},
- "act": {act_number},
- "location": "必须是settings中已定义的场景名称",
- "characters": ["出场角色名(必须与characters中的name一致)"],
- "plot": "该场景完整详细的剧情, 含对话、动作和表情描写, 必须完整表达分场内容, 无字数限制"
- }}
- ]
-}}"""
-
-ACT_EXTRACT_SCHEMA_EN = """{{
- "characters": [
- {{
- "name": "Full name",
- "character_id": "char_ plus 8 random alphanumeric",
- "description": "Visual description: hair, eyes, build, clothing details, 50-80 words",
- "personality": ["trait1", "trait2", "trait3"],
- "motivation": "Core motivation",
- "arc_description": "Character growth arc",
- "role": "protagonist or supporting or background",
- "age": "age",
- "species": "human or specific animal"
- }}
- ],
- "settings": [
- {{
- "name": "Location name (Indoor) or Location name (Outdoor)",
- "setting_id": "set_ plus 8 random alphanumeric",
- "description": "Layout, colors, lighting, atmosphere details, 80-120 words, no people or animals"
- }}
- ],
- "scenes": [
- {{
- "scene_number": {scene_start},
- "act": {act_number},
- "location": "Must be a name defined in settings",
- "characters": ["character names matching characters array"],
- "plot": "Complete detailed scene plot with dialogue, actions and expressions, no word limit"
- }}
- ]
-}}"""
-
-ACT_EXTRACT_RULES_ZH = (
- "\n\n重要规则:\n"
- "1. characters中的name必须与scenes中的角色名完全一致\n"
- "2. scenes中的location必须是settings中已定义的场景名称之一\n"
- "3. settings的name需标注(室内)或(室外)\n"
- "4. 所有scene的act字段必须为{act_number}\n"
- "5. scene_number从{scene_start}开始递增\n"
- "6. 角色的description要有足够视觉细节用于AI图像生成\n"
- "7. setting的description要有足够视觉细节用于AI背景图生成\n"
- "8. 不要生成群体角色(如\"邻居们\"),每个角色都是独立个体\n"
- "9. scene的plot字段必须完整表达该分场的全部内容\n"
- "10. 只输出纯JSON\n"
-)
-
-ACT_EXTRACT_RULES_EN = (
- "\n\nImportant rules:\n"
- "1. Character names in scenes must exactly match names in characters array\n"
- "2. Scene locations must be names defined in settings array\n"
- "3. Setting names must include (Indoor) or (Outdoor)\n"
- "4. All scenes' act field must be {act_number}\n"
- "5. scene_number starts from {scene_start} and increments\n"
- "6. Character descriptions need enough visual detail for AI image generation\n"
- "7. Setting descriptions need enough visual detail for AI background generation\n"
- "8. No group characters, every character is an individual\n"
- "9. Scene 'plot' field must fully express all content, do not truncate\n"
- "10. Output ONLY the JSON\n"
-)
-
-# =============================================================
-# Phase 3B: 最终合并补充提示词(生成 title / logline / synopsis 等顶层字段)
-# =============================================================
-
-META_EXTRACT_PROMPT_ZH = (
- "你是专业的剧本分析师。以下是完整的四幕节拍表:\n\n"
- "{beat_sheet}\n\n"
- "请从中提取以下信息,以纯JSON格式输出(不要用```包裹):\n"
- '{{"title":"故事标题(2-8字)","logline":"一句话概括故事(30字以内)",'
- '"genre":["类型1","类型2"],"synopsis":"完整故事梗概(100-200字)",'
- '"mood":"影片情绪基调"}}'
-)
-
-META_EXTRACT_PROMPT_EN = (
- "You are a professional script analyst. Here is the complete 4-act beat sheet:\n\n"
- "{beat_sheet}\n\n"
- "Extract the following information as pure JSON (no code blocks):\n"
- '{{"title":"Story title (short)","logline":"One sentence summary",'
- '"genre":["genre1","genre2"],"synopsis":"Complete synopsis (100-200 words)",'
- '"mood":"Overall mood"}}'
-)
-
-# =============================================================
-# Phase 4: 场景 & 角色合并(去重相似条目)
-# =============================================================
-
-CONSOLIDATE_PROMPT_ZH = (
- "你是剧本审校专家。请审查以下剧本中的场景列表和角色列表,找出可以合并的条目。\n\n"
- "合并规则:\n"
- "- 场景合并:如果两个场景在物理空间上是同一个地点(只是拍摄角度、景别不同),应合并为一个\n"
- " 例如:「车厢内」「车厢过道」「车厢全景」都是同一节车厢 → 合并为「车厢内」\n"
- " 例如:「咖啡馆吧台」「咖啡馆角落」→ 合并为「咖啡馆」\n"
- " 注意:不同物理空间不能合并(如「车厢内」和「车厢连接处」是不同空间)\n"
- "- 角色合并:如果同名角色出现多次(可能描述略有不同),合并为一个\n"
- "- 合并后保留最详细的描述\n\n"
- "当前场景列表:\n{settings_json}\n\n"
- "当前角色列表:\n{characters_json}\n\n"
- "请输出纯JSON(不要用```包裹),格式如下:\n"
- '{{\n'
- ' "setting_merges": {{"被合并的场景名": "合并到的目标场景名", ...}},\n'
- ' "character_merges": {{"被合并的角色名": "合并到的目标角色名", ...}}\n'
- '}}\n\n'
- "如果没有需要合并的条目,对应字段返回空对象 {{}}。\n"
- "只输出纯JSON,不要添加任何其他文字。"
-)
-
-CONSOLIDATE_PROMPT_EN = (
- "You are a script review expert. Review the following settings and characters lists "
- "and identify entries that should be merged.\n\n"
- "Merge rules:\n"
- "- Settings merge: If two settings are the same physical location (just different camera angles), "
- "merge them into one. E.g., 'Train interior', 'Train aisle', 'Train panorama' are all the same car.\n"
- " Different physical spaces should NOT be merged.\n"
- "- Character merge: If the same character appears with slightly different descriptions, merge them.\n"
- "- Keep the most detailed description after merging.\n\n"
- "Current settings:\n{settings_json}\n\n"
- "Current characters:\n{characters_json}\n\n"
- "Output ONLY valid JSON (no code blocks):\n"
- '{{\n'
- ' "setting_merges": {{"merged_setting_name": "target_setting_name", ...}},\n'
- ' "character_merges": {{"merged_char_name": "target_char_name", ...}}\n'
- '}}\n\n'
- "If nothing to merge, return empty objects {{}}. Output ONLY the JSON."
-)
class ScriptWriterAgent(AgentInterface):
"""编剧智能体:多轮LLM交互 → 结构化剧本JSON"""
@@ -716,7 +292,7 @@
from tool.llm_client import LLM
llm = LLM()
self._report_progress("剧本生成", "正在生成 Logline 方案...", 5)
- prompt = (LOGLINE_GENERATE_PROMPT_ZH if is_zh else LOGLINE_GENERATE_PROMPT_EN).format(idea=idea)
+ prompt = _get_script_prompt("logline_generate", "zh" if is_zh else "en").format(idea=idea)
for attempt in range(3):
self._check_cancel()
@@ -736,13 +312,13 @@
prompt = (
"上次输出格式不正确,请严格按要求重新输出。"
"必须输出纯JSON数组,不要用```包裹,不要有任何多余文字。\n\n"
- + (LOGLINE_GENERATE_PROMPT_ZH).format(idea=idea)
+ + (_get_script_prompt("logline_generate", "zh")).format(idea=idea)
)
else:
prompt = (
"Previous output format was incorrect. Please try again. "
"Output ONLY a raw JSON array, no code blocks, no extra text.\n\n"
- + (LOGLINE_GENERATE_PROMPT_EN).format(idea=idea)
+ + (_get_script_prompt("logline_generate", "en")).format(idea=idea)
)
raise Exception("Logline 生成失败:多次尝试均无法解析输出")
@@ -778,12 +354,12 @@
from tool.llm_client import LLM
llm = LLM()
self._report_progress("剧本生成", "分析创意文本...", 5)
- check_prompt = (LOGLINE_CHECK_PROMPT_ZH if is_zh else LOGLINE_CHECK_PROMPT_EN).format(idea=idea)
+ check_prompt = _get_script_prompt("logline_check", "zh" if is_zh else "en").format(idea=idea)
answer = self._cancellable_query(llm, check_prompt, model=llm_model, task_id=sid, web_search=web_search).strip()
if answer.lower().startswith("yes"):
self._report_progress("剧本生成", "提取 Logline...", 10)
- extract_prompt = (LOGLINE_EXTRACT_PROMPT_ZH if is_zh else LOGLINE_EXTRACT_PROMPT_EN).format(idea=idea)
+ extract_prompt = _get_script_prompt("logline_extract", "zh" if is_zh else "en").format(idea=idea)
raw = self._cancellable_query(llm, extract_prompt, model=llm_model, task_id=sid, web_search=web_search)
logger.info(f"[ScriptWriter] Logline extract raw ({len(raw)} chars): {raw[:500]}")
logline_data = self._extract_json_from_text(raw)
@@ -857,7 +433,7 @@
# 逐幕生成节拍表 + 分场大纲 + 结构化提取
json_data = self._generate_script_incremental(
- llm, draft, style, llm_model, sid, is_zh, web_search=web_search, pct_start=20
+ llm, draft, idea, style, llm_model, sid, is_zh, web_search=web_search, pct_start=20
)
# 补充元数据
@@ -937,7 +513,7 @@
# 微电影模式: 单幕生成
json_data = self._generate_micro_script_incremental(
- llm, draft, style, llm_model, sid, is_zh, web_search=web_search, pct_start=20
+ llm, draft, idea, style, llm_model, sid, is_zh, web_search=web_search, pct_start=20
)
# 补充元数据
@@ -997,7 +573,7 @@
# Step 1: 生成 Logline 方案
self._report_progress("剧本生成", "正在生成 Logline 方案...", 5)
- prompt = (LOGLINE_GENERATE_PROMPT_ZH if is_zh else LOGLINE_GENERATE_PROMPT_EN).format(idea=idea)
+ prompt = _get_script_prompt("logline_generate", "zh" if is_zh else "en").format(idea=idea)
logline_data = None
for attempt in range(3):
@@ -1018,13 +594,13 @@
prompt = (
"上次输出格式不正确,请严格按要求重新输出。"
"必须输出纯JSON数组,不要用```包裹,不要有任何多余文字。\n\n"
- + LOGLINE_GENERATE_PROMPT_ZH.format(idea=idea)
+ + _get_script_prompt("logline_generate", "zh").format(idea=idea)
)
else:
prompt = (
"Previous output format was incorrect. Please try again. "
"Output ONLY a raw JSON array, no code blocks, no extra text.\n\n"
- + LOGLINE_GENERATE_PROMPT_EN.format(idea=idea)
+ + _get_script_prompt("logline_generate", "en").format(idea=idea)
)
if logline_data is None:
@@ -1056,7 +632,7 @@
# Step 3: 逐幕生成节拍表 + 分场大纲 + 结构化提取
json_data = self._generate_script_incremental(
- llm, draft, style, llm_model, sid, is_zh, web_search=web_search, pct_start=20
+ llm, draft, idea, style, llm_model, sid, is_zh, web_search=web_search, pct_start=20
)
# 补充元数据
@@ -1095,7 +671,7 @@
# ─── 公共: 逐幕生成节拍表 + 分场大纲 + 结构化提取 ───
- def _generate_script_incremental(self, llm, draft: str, style: str,
+ def _generate_script_incremental(self, llm, draft: str, idea: str, style: str,
llm_model: str, sid: str, is_zh: bool,
web_search: bool = False,
pct_start: int = 20) -> dict:
@@ -1103,7 +679,7 @@
# Step 1: 生成四幕节拍表
self._report_progress("剧本生成", "生成节拍表...", pct_start)
- prompt = (BEAT_SHEET_PROMPT_ZH if is_zh else BEAT_SHEET_PROMPT_EN).format(draft=draft, style=style)
+ prompt = _get_script_prompt("beat_sheet", "zh" if is_zh else "en").format(draft=draft, idea=idea, style=style)
beat_sheet = self._cancellable_query(llm, prompt, model=llm_model, task_id=sid, web_search=web_search)
logger.info(f"[ScriptWriter] Beat sheet generated ({len(beat_sheet)} chars)")
@@ -1113,7 +689,7 @@
# Step 2: 提取顶层元数据 (title, logline, genre, synopsis, mood)
self._report_progress("剧本生成", "提取故事元信息...", pct_start + 7)
- meta_prompt = (META_EXTRACT_PROMPT_ZH if is_zh else META_EXTRACT_PROMPT_EN).format(beat_sheet=beat_sheet)
+ meta_prompt = _get_script_prompt("meta_extract", "zh" if is_zh else "en").format(beat_sheet=beat_sheet)
meta_raw = self._cancellable_query(llm, meta_prompt, model=llm_model, task_id=sid, web_search=web_search)
meta_data = self._extract_json_from_text(meta_raw) or {}
logger.info(f"[ScriptWriter] Meta extracted: {list(meta_data.keys())}")
@@ -1137,7 +713,7 @@
if is_zh else f"Generating Act {act_num} outline ({act_name})...")
self._report_progress("剧本生成", progress_msg, pct_outline)
- outline_prompt = (STEP_OUTLINE_PROMPT_ZH if is_zh else STEP_OUTLINE_PROMPT_EN).format(
+ outline_prompt = _get_script_prompt("step_outline", "zh" if is_zh else "en").format(
beat_sheet=beat_sheet,
act_number=act_num,
act_name=act_name,
@@ -1222,7 +798,7 @@
# ─── 微电影模式: 单幕紧凑生成 ───
- def _generate_micro_script_incremental(self, llm, draft: str, style: str,
+ def _generate_micro_script_incremental(self, llm, draft: str, idea: str, style: str,
llm_model: str, sid: str, is_zh: bool,
web_search: bool = False,
pct_start: int = 20) -> dict:
@@ -1230,8 +806,8 @@
# Step 1: 生成单幕剧情概要
self._report_progress("剧本生成", "生成微电影剧情概要...", pct_start)
- prompt = (MICRO_BEAT_SHEET_PROMPT_ZH if is_zh else MICRO_BEAT_SHEET_PROMPT_EN).format(
- draft=draft, style=style
+ prompt = _get_script_prompt("micro_beat_sheet", "zh" if is_zh else "en").format(
+ draft=draft, idea=idea, style=style
)
beat_sheet = self._cancellable_query(llm, prompt, model=llm_model, task_id=sid, web_search=web_search)
logger.info(f"[ScriptWriter][micro] Beat sheet generated ({len(beat_sheet)} chars)")
@@ -1242,7 +818,7 @@
# Step 2: 提取顶层元数据
self._report_progress("剧本生成", "提取故事元信息...", pct_start + 15)
- meta_prompt = (MICRO_META_EXTRACT_PROMPT_ZH if is_zh else MICRO_META_EXTRACT_PROMPT_EN).format(
+ meta_prompt = _get_script_prompt("micro_meta_extract", "zh" if is_zh else "en").format(
beat_sheet=beat_sheet
)
meta_raw = self._cancellable_query(llm, meta_prompt, model=llm_model, task_id=sid, web_search=web_search)
@@ -1255,7 +831,7 @@
"生成微电影分场大纲..." if is_zh else "Generating micro-film step outline...",
pct_start + 25)
- outline_prompt = (MICRO_STEP_OUTLINE_PROMPT_ZH if is_zh else MICRO_STEP_OUTLINE_PROMPT_EN).format(
+ outline_prompt = _get_script_prompt("micro_step_outline", "zh" if is_zh else "en").format(
beat_sheet=beat_sheet, style=style
)
outline = self._cancellable_query(llm, outline_prompt, model=llm_model, task_id=sid, web_search=web_search)
@@ -1331,16 +907,9 @@
llm_model: str, sid: str, is_zh: bool,
web_search: bool = False) -> dict:
"""从单幕分场大纲提取结构化JSON,带校验重试"""
- schema = (ACT_EXTRACT_SCHEMA_ZH if is_zh else ACT_EXTRACT_SCHEMA_EN).format(
- act_number=act_number, scene_start=scene_start
+ extract_prompt = _get_script_prompt("act_extract", "zh" if is_zh else "en").format(
+ act_number=act_number, scene_start=scene_start, outline=outline
)
- intro = (ACT_EXTRACT_INTRO_ZH if is_zh else ACT_EXTRACT_INTRO_EN).format(
- act_number=act_number, outline=outline
- )
- rules = (ACT_EXTRACT_RULES_ZH if is_zh else ACT_EXTRACT_RULES_EN).format(
- act_number=act_number, scene_start=scene_start
- )
- extract_prompt = intro + schema + rules
last_error = ""
@@ -1355,7 +924,7 @@
extract_prompt = (
("上次输出不是合法JSON,请重新输出。" if is_zh
else "Previous output was not valid JSON. Please try again. ")
- + intro + schema + rules
+ + extract_prompt
)
continue
@@ -1367,7 +936,7 @@
extract_prompt = (
(f"上次输出的JSON缺少scenes。请确保scenes是非空列表。" if is_zh
else "Previous JSON had no scenes. Ensure scenes is a non-empty array. ")
- + intro + schema + rules
+ + extract_prompt
)
continue
@@ -1387,7 +956,7 @@
extract_prompt = (
(f"上次输出的JSON存在问题: {last_error}。请修正后重新输出。" if is_zh
else f"Previous JSON issue: {last_error}. Please fix and retry. ")
- + intro + schema + rules
+ + extract_prompt
)
continue
@@ -1414,7 +983,7 @@
chars_summary = [{"name": c["name"], "description": c.get("description", "")}
for c in characters]
- prompt = (CONSOLIDATE_PROMPT_ZH if is_zh else CONSOLIDATE_PROMPT_EN).format(
+ prompt = _get_script_prompt("consolidate", "zh" if is_zh else "en").format(
settings_json=json.dumps(settings_summary, ensure_ascii=False, indent=2),
characters_json=json.dumps(chars_summary, ensure_ascii=False, indent=2),
)
diff --git a/aigc-director/aigc-claw/backend/core/agents/storyboard_agent.py b/aigc-director/aigc-claw/backend/core/agents/storyboard_agent.py
index 2354aaa..3cbc048 100644
--- a/aigc-director/aigc-claw/backend/core/agents/storyboard_agent.py
+++ b/aigc-director/aigc-claw/backend/core/agents/storyboard_agent.py
@@ -22,23 +22,21 @@
def _get_shot_prompt(lang: str = 'zh') -> str:
- """获取分镜提示词"""
- return load_prompt('storyboard', 'shot', lang)
+ """获取分镜提取提示词"""
+ from prompts.loader import load_prompt_with_fallback
+ return load_prompt_with_fallback('storyboard', 'shot', lang, 'zh')
+
+
+def _get_expand_prompt(lang: str = 'zh') -> str:
+ """获取剧本扩写提示词"""
+ from prompts.loader import load_prompt_with_fallback
+ return load_prompt_with_fallback('storyboard', 'expand', lang, 'zh')
def _get_continue_prompt(lang: str = 'zh') -> str:
"""获取续写分镜提示词"""
from prompts.loader import load_prompt_with_fallback
return load_prompt_with_fallback('storyboard', 'continue', lang, 'zh')
-
-
-def _get_prompt(name: str) -> str:
- """Helper to get prompts"""
- if name == 'SHOT_PROMPT_ZH':
- return load_prompt('storyboard', 'shot', 'zh')
- elif name == 'SHOT_PROMPT_EN':
- return load_prompt('storyboard', 'shot', 'en')
- raise AttributeError(f"module has no attribute {name!r}")
class StoryboardAgent(AgentInterface):
@@ -284,7 +282,9 @@
settings_map = {s["name"]: s for s in script_json.get("settings", [])}
is_zh = any('\u4e00' <= c <= '\u9fff' for c in script_json.get("title", ""))
- prompt_template = _get_prompt('SHOT_PROMPT_ZH') if is_zh else _get_prompt('SHOT_PROMPT_EN')
+ lang = 'zh' if is_zh else 'en'
+ shot_prompt_template = _get_shot_prompt(lang)
+ expand_prompt_template = _get_expand_prompt(lang)
self._report_progress("分镜", "读取剧本数据...", 5)
@@ -292,8 +292,8 @@
enable_concurrency = input_data.get("enable_concurrency", True)
from config_model import get_max_concurrency
# LLM 调用的并发数
- concurrency = get_max_concurrency("llm", enable_concurrency)
- logger.info(f"[StoryboardAgent] enable_concurrency={enable_concurrency}, concurrency={concurrency}")
+ concurrency = get_max_concurrency(llm_model, enable_concurrency)
+ logger.info(f"[StoryboardAgent] enable_concurrency={enable_concurrency}, concurrency={concurrency} for model={llm_model}")
# 用于按场景顺序存储结果的字典
shots_results: Dict[int, List[dict]] = {}
@@ -308,7 +308,7 @@
location = scene.get("location", "")
scene_chars = scene.get("characters", [])
- plot = scene.get("plot", "")
+ original_plot = scene.get("plot", "")
# 角色外貌描述
char_descs = []
@@ -322,12 +322,33 @@
setting_info = settings_map.get(location, {})
setting_desc = setting_info.get("description", location)
- prompt = prompt_template.format(
+ # 第一步:扩写剧本
+ logger.info(f"[StoryboardAgent] Expanding scene {sn}...")
+ expand_prompt = expand_prompt_template.format(
+ title=script_json.get("title", ""),
+ style=style,
+ location=location,
+ characters=", ".join(scene_chars),
+ plot=original_plot,
+ char_descriptions=char_desc_text,
+ setting_description=setting_desc,
+ script=json.dumps(script_json, ensure_ascii=False, indent=2)
+ )
+
+ expanded_plot = original_plot
+ try:
+ expanded_plot = self._cancellable_query(llm, expand_prompt, model=llm_model, task_id=sid)
+ logger.info(f"[StoryboardAgent] Scene {sn} expanded.")
+ except Exception as e:
+ logger.error(f"Scene {sn} expansion failed: {e}")
+
+ # 第二步:生成分镜 (使用扩写后的内容)
+ prompt = shot_prompt_template.format(
style=style,
scene_number=sn,
location=location,
characters=", ".join(scene_chars),
- plot=plot,
+ expanded_plot=expanded_plot,
char_descriptions=char_desc_text,
setting_description=setting_desc,
)
@@ -353,8 +374,8 @@
"duration": 15,
"characters": scene_chars,
"location": location,
- "plot": plot,
- "visual_prompt": plot,
+ "plot": original_plot,
+ "visual_prompt": original_plot,
}]
# 为每个分镜添加全局标识
diff --git a/aigc-director/aigc-claw/backend/core/agents/video_agent.py b/aigc-director/aigc-claw/backend/core/agents/video_agent.py
index 3f76391..57d2e37 100644
--- a/aigc-director/aigc-claw/backend/core/agents/video_agent.py
+++ b/aigc-director/aigc-claw/backend/core/agents/video_agent.py
@@ -391,6 +391,8 @@
# 优先使用 input_data 中已有的 clips(包含用户修改的 description)
existing_clips = input_data.get("clips", [])
clip_descriptions = {c['id']: c['description'] for c in existing_clips if c.get('id') and c.get('description')}
+ clip_durations = {c['id']: c.get('duration', 10) for c in existing_clips if c.get('id')}
+
video_sound = input_data.get("video_sound", "on")
video_shot_type = input_data.get("video_shot_type", "multi")
sound_param = "" if video_sound == "off" else video_sound
@@ -406,7 +408,26 @@
s2i = story_data.get('scene2image', {})
- # 从 storyboard 获取时长数据(用户修改已同步到 clips 中)
+ # 1. 如果 input_data 传了 clips,则优先使用 input_data 中的结构
+ # 即使 scene2image 还没写回,也能根据 input_data 生成
+ if existing_clips:
+ logger.info(f"Using clips from input_data, count: {len(existing_clips)}")
+ # 补全 s2i 中可能缺失的项(例如新分镜)
+ for clip in existing_clips:
+ cid = clip['id']
+ if cid not in s2i:
+ s2i[cid] = {
+ "plot": clip.get('description', ''),
+ "duration": clip.get('duration', 10),
+ }
+ else:
+ # 更新已有项的时长和描述(以 input_data 为准)
+ if cid in clip_descriptions:
+ s2i[cid]['plot'] = clip_descriptions[cid]
+ if cid in clip_durations:
+ s2i[cid]['duration'] = clip_durations[cid]
+
+ # 从 storyboard 获取时长数据(用于兜底更新)
storyboard = story_data.get('storyboard', {})
storyboard_shots_list = storyboard.get('shots', [])
shot_duration_map = {s.get('shot_id'): s.get('duration', 10) for s in storyboard_shots_list if s.get('shot_id')}
diff --git a/aigc-director/aigc-claw/backend/prompts/loader.py b/aigc-director/aigc-claw/backend/prompts/loader.py
index a4222b3..47ab94f 100644
--- a/aigc-director/aigc-claw/backend/prompts/loader.py
+++ b/aigc-director/aigc-claw/backend/prompts/loader.py
@@ -24,7 +24,7 @@
提示词内容字符串
Example:
- prompt = load_prompt('logline', 'generate', 'zh')
+ prompt = load_prompt('script', 'logline_generate', 'zh')
"""
# 尝试加载语言版本
file_path = os.path.join(PROMPTS_DIR, category, f"{name}_{lang}.txt")
@@ -32,7 +32,13 @@
with open(file_path, 'r', encoding='utf-8') as f:
return f.read().strip()
- # 回退到中文版本
+ # 回退到带 _zh 的版本
+ file_path = os.path.join(PROMPTS_DIR, category, f"{name}_zh.txt")
+ if os.path.exists(file_path):
+ with open(file_path, 'r', encoding='utf-8') as f:
+ return f.read().strip()
+
+ # 回退到不带后缀的通用版本
file_path = os.path.join(PROMPTS_DIR, category, f"{name}.txt")
if os.path.exists(file_path):
with open(file_path, 'r', encoding='utf-8') as f:
@@ -64,6 +70,12 @@
with open(file_path, 'r', encoding='utf-8') as f:
return f.read().strip()
+ # 最后尝试不带后缀的版本
+ file_path = os.path.join(PROMPTS_DIR, category, f"{name}.txt")
+ if os.path.exists(file_path):
+ with open(file_path, 'r', encoding='utf-8') as f:
+ return f.read().strip()
+
raise FileNotFoundError(f"Prompt not found: {category}/{name}_{lang}.txt")
diff --git a/aigc-director/aigc-claw/backend/prompts/logline/generate_en.txt b/aigc-director/aigc-claw/backend/prompts/logline/generate_en.txt
deleted file mode 100644
index 3cc88ac..0000000
--- a/aigc-director/aigc-claw/backend/prompts/logline/generate_en.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-You are a senior producer. Expand the following idea into 3 different Loglines.
-Requirements:
-- Define the protagonist (Who), Goal, core Conflict, and Twist
-- Identify the story's Theme
-- Each Logline should use 'What if...' format
-- The 3 Loglines should be diverse in style and focus
-
-Input: {idea}
-
-Output ONLY a JSON array with exactly 3 elements (no code block markers, no other text):
-[{{"logline":"What if...","who":"protagonist","goal":"goal","conflict":"conflict","twist":"twist","theme":"theme"}}]
diff --git a/aigc-director/aigc-claw/backend/prompts/script/act_extract_en.txt b/aigc-director/aigc-claw/backend/prompts/script/act_extract_en.txt
new file mode 100644
index 0000000..2053540
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/act_extract_en.txt
@@ -0,0 +1,54 @@
+You are a professional script analyst. Read the following Act {act_number} step outline carefully and extract it into a structured JSON format.
+
+Step outline:
+{outline}
+
+Output ONLY valid JSON in the following structure (no code block markers, no comments, no other text):
+
+
+
+{{
+ "characters": [
+ {{
+ "name": "Full name",
+ "character_id": "char_ plus 8 random alphanumeric",
+ "description": "Visual description: hair, eyes, build, clothing details, 50-80 words",
+ "personality": ["trait1", "trait2", "trait3"],
+ "motivation": "Core motivation",
+ "arc_description": "Character growth arc",
+ "role": "protagonist or supporting or background",
+ "age": "age",
+ "species": "human or specific animal"
+ }}
+ ],
+ "settings": [
+ {{
+ "name": "Location name (Indoor) or Location name (Outdoor)",
+ "setting_id": "set_ plus 8 random alphanumeric",
+ "description": "Layout, colors, lighting, atmosphere details, 80-120 words, no people or animals"
+ }}
+ ],
+ "scenes": [
+ {{
+ "scene_number": {scene_start},
+ "act": {act_number},
+ "location": "Must be a name defined in settings",
+ "characters": ["character names matching characters array"],
+ "plot": "Complete detailed scene plot with dialogue, actions and expressions, no word limit"
+ }}
+ ]
+}}
+
+
+
+Important rules:
+1. Character names in scenes must exactly match names in characters array
+2. Scene locations must be names defined in settings array
+3. Setting names must include (Indoor) or (Outdoor)
+4. All scenes' act field must be {act_number}
+5. scene_number starts from {scene_start} and increments
+6. Character descriptions need enough visual detail for AI image generation
+7. Setting descriptions need enough visual detail for AI background generation
+8. No group characters, every character is an individual
+9. Scene 'plot' field must fully express all content, do not truncate
+10. Output ONLY the JSON
diff --git a/aigc-director/aigc-claw/backend/prompts/script/act_extract_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/act_extract_zh.txt
new file mode 100644
index 0000000..920c238
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/act_extract_zh.txt
@@ -0,0 +1,54 @@
+你是一个专业的剧本分析师。请仔细阅读以下第{act_number}幕的分场大纲,从中提取并整理为标准JSON格式。
+
+分场大纲:
+{outline}
+
+请严格按照以下JSON结构输出(直接输出纯JSON,不要用```包裹,不要添加注释或任何其他文字):
+
+
+
+{{
+ "characters": [
+ {{
+ "name": "角色全名",
+ "character_id": "char_加8位随机字母数字",
+ "description": "外貌描写: 含发型、体型、服装颜色和款式等视觉特征, 不要描述眼睛颜色, 面部不要有文字等特殊符号, 形象要正常(可以前卫时髦但不能恐怖灵异), 50-80字, 不要用比喻",
+ "personality": ["性格特征1", "性格特征2", "性格特征3"],
+ "motivation": "角色核心动机",
+ "arc_description": "角色成长弧线",
+ "role": "主角 或 配角 或 背景",
+ "age": "年龄",
+ "species": "人类 或 具体动物种类"
+ }}
+ ],
+ "settings": [
+ {{
+ "name": "场景名称(室内) 或 场景名称(室外)",
+ "setting_id": "set_加8位随机字母数字",
+ "description": "环境布局、色彩、光线、氛围等视觉细节, 80-120字, 不要包含人物或动物"
+ }}
+ ],
+ "scenes": [
+ {{
+ "scene_number": {scene_start},
+ "act": {act_number},
+ "location": "必须是settings中已定义的场景名称",
+ "characters": ["出场角色名(必须与characters中的name一致)"],
+ "plot": "该场景完整详细的剧情, 含对话、动作和表情描写, 必须完整表达分场内容, 无字数限制"
+ }}
+ ]
+}}
+
+
+
+重要规则:
+1. characters中的name必须与scenes中的角色名完全一致
+2. scenes中的location必须是settings中已定义的场景名称之一
+3. settings的name需标注(室内)或(室外)
+4. 所有scene的act字段必须为{act_number}
+5. scene_number从{scene_start}开始递增
+6. 角色的description要有足够视觉细节用于AI图像生成
+7. setting的description要有足够视觉细节用于AI背景图生成
+8. 不要生成群体角色(如"邻居们"),每个角色都是独立个体
+9. scene的plot字段必须完整表达该分场的全部内容
+10. 只输出纯JSON
diff --git a/aigc-director/aigc-claw/backend/prompts/script/beat_sheet_en.txt b/aigc-director/aigc-claw/backend/prompts/script/beat_sheet_en.txt
index a591d6e..c6b4b0b 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/beat_sheet_en.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/beat_sheet_en.txt
@@ -6,11 +6,14 @@
Act 3 - Dark Night of the Soul: Protagonist suffers the biggest blow, hits rock bottom
Act 4 - Finale: Protagonist gains epiphany, final confrontation, story resolves
-Ensure: tight logic, escalating conflict, clear turning points in each act.
+Ensure: tight logic, escalating conflict, and clear turning points in each act. Crucially, you must preserve and integrate key details, specific imagery, or core creative ideas (User Idea) from the original input.
Storyline:
{draft}
+User Core Idea/Specific Requirements:
+{idea}
+
Story style: {style}
-Output the 4-act beat sheet directly. Start each act with '[Act X - Name]' heading. Detail the plot points, character development and key turning points for each act.
+Output the 4-act beat sheet directly. Start each act with '[Act X - Name]' heading. Detail the plot points, character development and key turning points for each act.
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/beat_sheet_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/beat_sheet_zh.txt
index f9c9a59..f0c5ea3 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/beat_sheet_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/beat_sheet_zh.txt
@@ -6,11 +6,14 @@
第三幕 - 灵魂黑夜(Dark Night of the Soul):主角遭受最大打击,陷入低谷
第四幕 - 高潮决战(Finale):主角获得顿悟,最终决战,故事收束
-请确保:逻辑严密、冲突逐步升级、每一幕有清晰的转折点。
+请确保:逻辑严密、冲突逐步升级、每一幕有清晰的转折点。务必保留并整合用户原始输入中的关键细节、特定意象或核心创意(User Idea)。
-故事线:
+故事大纲:
{draft}
+
+用户核心创意/细节要求:
+{idea}
故事风格:{style}
-请直接输出四幕节拍表,每一幕用"【第X幕 - 名称】"标记开始,详细描述该幕的情节要点、角色发展和关键转折。
+请直接输出四幕节拍表,每一幕用"【第X幕 - 名称】"标记开始,详细描述该幕的情节要点、角色发展和关键转折。
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/consolidate_en.txt b/aigc-director/aigc-claw/backend/prompts/script/consolidate_en.txt
new file mode 100644
index 0000000..056304b
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/consolidate_en.txt
@@ -0,0 +1,21 @@
+You are a script review expert. Review the following settings and characters lists and identify entries that should be merged.
+
+Merge rules:
+- Settings merge: If two settings are the same physical location (just different camera angles), merge them into one. E.g., 'Train interior', 'Train aisle', 'Train panorama' are all the same car.
+ Different physical spaces should NOT be merged.
+- Character merge: If the same character appears with slightly different descriptions, merge them.
+- Keep the most detailed description after merging.
+
+Current settings:
+{settings_json}
+
+Current characters:
+{characters_json}
+
+Output ONLY valid JSON (no code blocks):
+{{
+ "setting_merges": {{"merged_setting_name": "target_setting_name", ...}},
+ "character_merges": {{"merged_char_name": "target_char_name", ...}}
+}}
+
+If nothing to merge, return empty objects {{}}. Output ONLY the JSON.
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/consolidate_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/consolidate_zh.txt
new file mode 100644
index 0000000..0e3528e
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/consolidate_zh.txt
@@ -0,0 +1,24 @@
+你是剧本审校专家。请审查以下剧本中的场景列表和角色列表,找出可以合并的条目。
+
+合并规则:
+- 场景合并:如果两个场景在物理空间上是同一个地点(只是拍摄角度、景别不同),应合并为一个
+ 例如:「车厢内」「车厢过道」「车厢全景」都是同一节车厢 → 合并为「车厢内」
+ 例如:「咖啡馆吧台」「咖啡馆角落」→ 合并为「咖啡馆」
+ 注意:不同物理空间不能合并(如「车厢内」和「车厢连接处」是不同空间)
+- 角色合并:如果同名角色出现多次(可能描述略有不同),合并为一个
+- 合并后保留最详细的描述
+
+当前场景列表:
+{settings_json}
+
+当前角色列表:
+{characters_json}
+
+请输出纯JSON(不要用```包裹),格式如下:
+{{
+ "setting_merges": {{"被合并的场景名": "合并到的目标场景名", ...}},
+ "character_merges": {{"被合并的角色名": "合并到的目标角色名", ...}}
+}}
+
+如果没有需要合并的条目,对应字段返回空对象 {{}}。
+只输出纯JSON,不要添加任何其他文字。
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/logline/check_en.txt b/aigc-director/aigc-claw/backend/prompts/script/logline_check_en.txt
similarity index 100%
rename from aigc-director/aigc-claw/backend/prompts/logline/check_en.txt
rename to aigc-director/aigc-claw/backend/prompts/script/logline_check_en.txt
diff --git a/aigc-director/aigc-claw/backend/prompts/logline/check_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/logline_check_zh.txt
similarity index 100%
rename from aigc-director/aigc-claw/backend/prompts/logline/check_zh.txt
rename to aigc-director/aigc-claw/backend/prompts/script/logline_check_zh.txt
diff --git a/aigc-director/aigc-claw/backend/prompts/script/logline_extract_en.txt b/aigc-director/aigc-claw/backend/prompts/script/logline_extract_en.txt
new file mode 100644
index 0000000..0a2b96e
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/logline_extract_en.txt
@@ -0,0 +1,7 @@
+You are a senior producer. Extract the Logline and five story elements from the following text.
+The Logline should use 'What if...' format.
+
+Text: {idea}
+
+Output ONLY valid JSON (no code block markers, no other text):
+{{"logline":"What if...","who":"protagonist","goal":"goal","conflict":"conflict","twist":"twist","theme":"theme"}}
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/logline/extract_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/logline_extract_zh.txt
similarity index 100%
rename from aigc-director/aigc-claw/backend/prompts/logline/extract_zh.txt
rename to aigc-director/aigc-claw/backend/prompts/script/logline_extract_zh.txt
diff --git a/aigc-director/aigc-claw/backend/prompts/script/logline_generate_en.txt b/aigc-director/aigc-claw/backend/prompts/script/logline_generate_en.txt
new file mode 100644
index 0000000..bbf7f8e
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/logline_generate_en.txt
@@ -0,0 +1,14 @@
+You are a senior producer. Expand the following idea into 3 different Loglines.
+Requirements:
+- Define the protagonist (Who), Goal, core Conflict, and Twist
+- Identify the story's Theme
+- Expand into the following three fixed styles, and prefix the logline with the 【Style】 tag:
+ 1. Web Novel (Fast-paced/Gratifying)
+ 2. Suspense/Mind-bending
+ 3. Philosophical/Contemplative
+- The 3 Loglines should be diverse in style and focus
+
+Input: {idea}
+
+Output ONLY a JSON array with exactly 3 elements (no code block markers, no other text):
+[{{"logline":"【Style Name】Story outline content","who":"protagonist","goal":"goal","conflict":"conflict","twist":"twist","theme":"theme"}}]
diff --git a/aigc-director/aigc-claw/backend/prompts/logline/generate_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/logline_generate_zh.txt
similarity index 61%
rename from aigc-director/aigc-claw/backend/prompts/logline/generate_zh.txt
rename to aigc-director/aigc-claw/backend/prompts/script/logline_generate_zh.txt
index a6062a2..caf3828 100644
--- a/aigc-director/aigc-claw/backend/prompts/logline/generate_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/logline_generate_zh.txt
@@ -2,11 +2,14 @@
要求:
- 明确主角(Who)、目标(Goal)、核心障碍(Conflict)和反转(Twist)
- 确定故事的 Theme(潜在主题)
-- Logline 按照"如果…会怎样"的句式描述
+- 固定扩写以下三个方向,并在 logline 前面增加【风格】标注:
+ 1. 网络爽文
+ 2. 悬疑烧脑
+ 3. 哲理思辨
- 3 个 Logline 应风格各异、各有侧重
输入内容:{idea}
请严格按如下 JSON 数组格式输出(直接输出纯JSON,不要用```包裹,不要添加任何其他文字):
-[{{"logline":"如果...会怎样","who":"主角描述","goal":"目标","conflict":"核心障碍","twist":"反转","theme":"潜在主题"}}]
+[{{"logline":"【风格名】故事大纲内容","who":"主角描述","goal":"目标","conflict":"核心障碍","twist":"反转","theme":"潜在主题"}}]
输出恰好 3 个元素的 JSON 数组。
diff --git a/aigc-director/aigc-claw/backend/prompts/script/meta_extract_en.txt b/aigc-director/aigc-claw/backend/prompts/script/meta_extract_en.txt
new file mode 100644
index 0000000..b4c9ea2
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/meta_extract_en.txt
@@ -0,0 +1,6 @@
+You are a professional script analyst. Here is the complete 4-act beat sheet:
+
+{beat_sheet}
+
+Extract the following information as pure JSON (no code blocks):
+{{"title":"Story title (short)","logline":"One sentence summary","genre":["genre1","genre2"],"synopsis":"Complete synopsis (100-200 words)","mood":"Overall mood"}}
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/meta_extract_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/meta_extract_zh.txt
new file mode 100644
index 0000000..c4d3b7c
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/meta_extract_zh.txt
@@ -0,0 +1,6 @@
+你是专业的剧本分析师。以下是完整的四幕节拍表:
+
+{beat_sheet}
+
+请从中提取以下信息,以纯JSON格式输出(不要用```包裹):
+{{"title":"故事标题(2-8字)","logline":"一句话概括故事(30字以内)","genre":["类型1","类型2"],"synopsis":"完整故事梗概(100-200字)","mood":"影片情绪基调"}}
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/micro_beat_sheet_en.txt b/aigc-director/aigc-claw/backend/prompts/script/micro_beat_sheet_en.txt
index 8e7c31a..daaabc9 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/micro_beat_sheet_en.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/micro_beat_sheet_en.txt
@@ -10,6 +10,9 @@
Storyline:
{draft}
+User Core Idea/Specific Requirements (Must preserve and integrate):
+{idea}
+
Story style: {style}
-Output a compact plot summary directly, describing scene progression, core actions and emotional shifts.
+Output a compact plot summary directly, describing scene progression, core actions and emotional shifts.
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/micro_beat_sheet_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/micro_beat_sheet_zh.txt
index 1768982..e70d585 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/micro_beat_sheet_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/micro_beat_sheet_zh.txt
@@ -10,6 +10,9 @@
故事线:
{draft}
+用户核心创意/细节要求(务必保留并整合):
+{idea}
+
故事风格:{style}
-请直接输出紧凑的剧情概要,描述场景发展、核心动作和情感转折。
+请直接输出紧凑的剧情概要,描述场景发展、核心动作和情感转折。
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/micro_meta_extract_en.txt b/aigc-director/aigc-claw/backend/prompts/script/micro_meta_extract_en.txt
new file mode 100644
index 0000000..3dceddf
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/micro_meta_extract_en.txt
@@ -0,0 +1,6 @@
+You are a professional script analyst. Here is the micro-film plot summary:
+
+{beat_sheet}
+
+Extract the following information as pure JSON (no code blocks):
+{{"title":"Story title (short)","logline":"One sentence summary","genre":["genre1","genre2"],"synopsis":"Complete synopsis (50-100 words)","mood":"Overall mood"}}
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/micro_meta_extract_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/micro_meta_extract_zh.txt
new file mode 100644
index 0000000..f242133
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/micro_meta_extract_zh.txt
@@ -0,0 +1,6 @@
+你是专业的剧本分析师。以下是微电影剧情概要:
+
+{beat_sheet}
+
+请从中提取以下信息,以纯JSON格式输出(不要用```包裹):
+{{"title":"故事标题(2-8字)","logline":"一句话概括故事(30字以内)","genre":["类型1","类型2"],"synopsis":"完整故事梗概(50-100字)","mood":"影片情绪基调"}}
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/micro_step_outline_en.txt b/aigc-director/aigc-claw/backend/prompts/script/micro_step_outline_en.txt
new file mode 100644
index 0000000..6fa4910
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/micro_step_outline_en.txt
@@ -0,0 +1,24 @@
+You are a scene director. Here is the micro-film plot summary:
+
+{beat_sheet}
+
+Convert it into a detailed step outline.
+
+Format for each scene:
+[Scene number]. [Location (Indoor/Outdoor)] - [Day/Night]
+[Core Action]: Detailed description including dialogue, actions and expressions.
+[Emotional Shift]: Protagonist's emotional change from start to end (+/-).
+[Characters Present]: All characters appearing in this scene.
+
+Requirements:
+- Each character needs detailed physical descriptions (hair, eyes, build, clothing)
+- **IMPORTANT: Physical descriptions must be STATIC and consistent throughout the entire story - do NOT change with plot development**
+ - For example: do NOT write "wearing torn clothes" which changes with the plot
+ - Instead write: "wearing a blue shirt and black pants" which is a fixed clothing description
+- Each scene needs detailed environment, layout, color and atmosphere descriptions
+- 3-6 scenes total, compact and fast-paced
+- Dialogue marked with double quotes, natural and vivid
+- Scene numbers start from 1 and increment
+- Story style: {style}
+
+Output the step outline directly, without extra notes.
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/micro_step_outline_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/micro_step_outline_zh.txt
index 7b9846c..065f83d 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/micro_step_outline_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/micro_step_outline_zh.txt
@@ -1,8 +1,6 @@
-你是微电影编剧专家。请根据以下故事线,将故事压缩为一个紧凑的单幕剧情概要。
+你是分场导演。以下是微电影剧情概要:
-{draft}
-
-故事风格:{style}
+{beat_sheet}
请将其转化为详细的分场大纲。
@@ -18,8 +16,9 @@
- 例如:不要写"他穿着破碎的衣服"这种随情节变化的描写
- 应该写:"他身穿蓝色衬衫,黑色长裤"这种固定的服装描述
- 每个场景都要有详细的环境、布局、色彩与氛围描写
-- 分场数量根据情节长度和节奏自行决定,确保叙事节奏合理
+- 分场数量 3-6 场,叙事紧凑快节奏
- 对话用双引号标注,对话内容真实生动
- 场次编号从 1 开始递增
+- 故事风格:{style}
-请直接输出分场大纲。
+请直接输出分场大纲,不要添加额外说明。
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/step_outline_en.txt b/aigc-director/aigc-claw/backend/prompts/script/step_outline_en.txt
index 0bb770e..2a1a5e1 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/step_outline_en.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/step_outline_en.txt
@@ -21,4 +21,4 @@
- Scene numbers start from {scene_start} and increment
- Story style: {style}
-Output the step outline directly, without act headings or extra notes.
+Output the step outline directly, without act headings or extra notes.
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/step_outline_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/step_outline_zh.txt
index b1a2f84..e59141e 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/step_outline_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/step_outline_zh.txt
@@ -21,4 +21,4 @@
- 场次编号从 {scene_start} 开始递增
- 故事风格:{style}
-请直接输出分场大纲,不要添加幕次标题或额外说明。
+请直接输出分场大纲,不要添加幕次标题或额外说明。
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/storyboard/expand_zh.txt b/aigc-director/aigc-claw/backend/prompts/storyboard/expand_zh.txt
new file mode 100644
index 0000000..c71735d
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/storyboard/expand_zh.txt
@@ -0,0 +1,41 @@
+你是一位天才电影编剧。请注意,你当前处理的仅仅是【完整剧本】中的【一个独立场景】。
+你的任务是将这个初版的场景大纲,“扩写”为一段极具画面感、戏剧冲突和完整对话的详细剧本素材(Detailed Scene Script),不要越界去创作后续剧情。
+
+---
+
+【要求】
+
+1. 扩写后的内容必须保持与原剧本《{title}》的整体风格《{style}》一致,目标只是丰富这一个特定场景。
+2. 戏剧性增强:通过具体的动作、神态、环境变化来体现角色的内心冲突。
+3. 角色完整性:必须使用角色全名。确保每个角色的对话都符合其性格设定。
+4. 本场景补充核心要素:
+ - 动作:描述角色在此次场景内的具体物理行为(如:他颤抖着手点燃了烟,火光映照出他深陷的眼窝)。
+ - 对话:为这一个场景构思符合该大纲发展的精彩台词。对话必须用引号标注。
+ - 内心独白:如果是单人镜头,务必通过自言自语或极度细腻的动作描写来展现其内心戏。
+ - 环境细节:描述当前环境中的光影、声音、氛围对剧情的影响。
+5. 长度要求:不少于 1000 字,确保内容足以支撑拆分为多个分镜。
+6. 禁止产出 JSON:请直接输出一段纯文本的、流式的剧本叙述。
+
+---
+
+【完整剧本】
+
+{script}
+
+你只需要参考这个剧本,了解完整情节,然后用于接下来的【场景扩写】
+
+---
+
+【场景扩写】
+
+本场景的内容是【完整剧本】中的一部分,你只需要专注于扩写这个场景的内容即可,不要越界去创作这个场景前后的剧情。
+
+出场角色:{characters}
+角色设定:{char_descriptions}
+
+背景位置:{location}
+背景设定:{setting_description}
+
+场景大纲:{plot}
+
+请扩写这个场景,注意输出的情节必须是发生在这个场景中的,只给出续写后的纯文本内容,不要包含其他文字。
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/storyboard/shot_zh.txt b/aigc-director/aigc-claw/backend/prompts/storyboard/shot_zh.txt
index e1e1db2..8932e0a 100644
--- a/aigc-director/aigc-claw/backend/prompts/storyboard/shot_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/storyboard/shot_zh.txt
@@ -1,17 +1,26 @@
-你是一位专业的影视分镜师。根据以下场景信息,将该场景拆分为若干分镜(shot)。
+你是一位专业的影视分镜师。你的任务是将以下经过由于编剧润色后的详细剧本场景(Detailed Scene Script),拆分为【3到5个】极具生产力的核心分镜(shot)。
要求:
-1. 每个分镜时长为 5、10 或 15 秒(根据内容复杂度选择)
-2. 每个分镜描述一个独立的画面段落(一个动作/一句对话/一个反应)
-3. plot 字段必须按时间顺序描述:角色动作、表情、对话(用引号标注)、背景音效
-4. visual_prompt 字段是适合AI图像生成的视觉描述,包含角色站位、姿态、表情、环境光线、色调、构图
-5. 保持{style}风格
-6. 用角色全名,不要用代词
+1. 【数量控制】:每个场景必须且只能拆分为 3 到 5 个分镜。优先保留最具戏剧冲突和视觉张力的瞬间。
+2. 【核心必填:完整台词】:除非是专门的渲染空镜头,否则【每个分镜】的 plot 必须包含剧本中的对话/人物独白。严禁出现只有动作而没有声音叙事的分镜。台词是情节推动的核心,不要浪费镜头素材!
+3. 每个分镜时长为 5、10 或 15 秒(根据内容复杂度选择)。
+4. 每个分镜描述一个独立的画面段落(一个动作/一句对话/一个反应)。
+5. 核心要求:必须包含并保留角色的对话与内心独白。即使是单人镜头,也应通过画外音或自言自言表达内心转折,确保叙事逻辑顺畅。
+6. plot 字段必须严格按时间顺序拆解,包含以下要素:
+ - 完整对话:必须提取剧本中的核心台词,用双引号标注。确保对话应与动作、表情同步描述,体现角色边说边做的真实感。
+ - 动作细节与情感表达:描述该分镜内的身体动作与面部微表情变化过程。
+ - 画面纯净度:禁止在 plot 描述中包含文字信息(如招牌文字、手机屏幕文本等)。
+7. visual_prompt 是用于生成“首帧参考图”的关键。必须满足以下视觉逻辑:
+ - 画面纯净:严禁提及任何具体的文本、字符或文字描述,防止AI生成时出现乱码。
+ - 动作起点:描述分镜开始瞬间的状态,确保后续视频生成动作连贯。
+ - 视觉一致性:相邻分镜要有镜头光影和环境细节的关联,避免拼接突变。
+ - 包含:明确镜头位置(过肩、特写等)、角色站位、姿态、表情、口型、光线色调。
+8. 保持{style}风格,用角色全名。
场景编号:{scene_number}
场景位置:{location}
出场角色:{characters}
-场景剧情:{plot}
+该场景的剧本:{expanded_plot}
角色外貌参考:
{char_descriptions}
@@ -20,6 +29,6 @@
{setting_description}
请直接输出JSON数组(不要用```包裹),每个元素格式如下:
-[{{"shot_number":1,"duration":5,"characters":["角色名"],"location":"场景位置","plot":"按时间顺序描述: 角色动作、表情、对话、背景音效,50-100字","visual_prompt":"AI图像生成用的视觉描述,含站位、姿态、表情、光线、构图,80-120字"}}]
+[{{"shot_number":1,"duration":5,"characters":["角色名"],"location":"场景位置","plot":"包含台词、动作、表情、音效的描述,80-150字","visual_prompt":"视觉描述,含镜头位、站位、构图、光影,80-150字"}}]
-注意:duration只能是5、10、15三个值之一。
+注意:duration只能是5、10、15三个值之一。每个场景分镜数限制在3-5个。
diff --git a/aigc-director/aigc-claw/backend/refactor_agent.py b/aigc-director/aigc-claw/backend/refactor_agent.py
new file mode 100644
index 0000000..e469b28
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/refactor_agent.py
@@ -0,0 +1,42 @@
+import os
+import re
+
+path = r'd:\Projects\AIGC-Claw\aigc-director\aigc-claw\backend\core\agents\script_agent.py'
+with open(path, 'r', encoding='utf-8') as f:
+ text = f.read()
+
+# 1. 删除所有以 _PROMPT_ZH/EN 结尾的字符串定义
+# 匹配: LOGLINE_GENERATE_PROMPT_ZH = """..."""
+# 注意:使用正则清理,但不准删除 Class 本身
+# 我们识别以三引号包裹的文本块进行精准删除
+pattern = r'[A-Z0-9_]+_PROMPT_(ZH|EN)\s*=\s*\"\"\"[\s\S]*?\"\"\"'
+text = re.sub(pattern, '', text)
+
+# 2. 注入提示词加载器
+if "def _get_script_prompt" not in text:
+ header = 'from datetime import datetime, timezone\nfrom typing import Any, Optional, Dict\n\nfrom prompts.loader import load_prompt_with_fallback\n\ndef _get_script_prompt(name: str, lang: str = "zh") -> str:\n return load_prompt_with_fallback("script", name, lang, "zh")\n'
+ text = text.replace('from datetime import datetime, timezone\nfrom typing import Any, Optional, Dict', header)
+
+# 3. 批量替换引用: (NAME_ZH if is_zh else NAME_EN)
+# 找出这种常见模式
+pairs = re.findall(r'\(([A-Z_0-9]+)_ZH\s+if\s+is_zh\s+else\s+\1_EN\)', text)
+for base in set(pairs):
+ clean = base.replace('_PROMPT', '').lower()
+ old = f'({base}_ZH if is_zh else {base}_EN)'
+ new = f'_get_script_prompt(\"{clean}\", \"zh\" if is_zh else \"en\")'
+ text = text.replace(old, new)
+
+# 4. 替换单纯的 xxx_PROMPT_ZH/EN (如果还带 .format 的话)
+singles = re.findall(r'([A-Z_0-9]+_PROMPT)_(ZH|EN)', text)
+for base, lang in set(singles):
+ clean = base.replace('_PROMPT', '').lower()
+ l = lang.lower()
+ text = text.replace(f'{base}_{lang}', f'_get_script_prompt(\"{clean}\", \"{l}\")')
+
+# 5. 确保 ACT_NAMES_ZH/EN 保留 (因为它们不是 Prompt 文字,而是映射表)
+# 以上正则不应删除非三引号的 ACT_NAMES
+
+with open(path, 'w', encoding='utf-8') as f:
+ f.write(text)
+
+print("CLEAN REFACTOR FINISHED: Kept 1000+ lines logic, synced external prompts.")
diff --git a/aigc-director/aigc-claw/backend/remove_prompts.py b/aigc-director/aigc-claw/backend/remove_prompts.py
new file mode 100644
index 0000000..0228803
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/remove_prompts.py
@@ -0,0 +1,18 @@
+import os
+import re
+
+path = r'd:\Projects\AIGC-Claw\aigc-director\aigc-claw\backend\core\agents\script_agent.py'
+with open(path, 'r', encoding='utf-8') as f:
+ text = f.read()
+
+# Fix the broken variable assignments
+bad_patterns = [
+ r'_get_script_prompt\([^)]+\)\s*=\s*\([\s\S]*?\n\)\n', # _get_script_prompt(...) = (\n...\n)
+ r'MICRO__get_script_prompt\([^)]+\)\s*=\s*\([\s\S]*?\n\)\n',
+]
+for p in bad_patterns:
+ text = re.sub(p, '', text)
+
+with open(path, 'w', encoding='utf-8') as f:
+ f.write(text)
+print("Removed broken assignment definitions.")
diff --git a/aigc-director/aigc-claw/backend/tool/image_client.py b/aigc-director/aigc-claw/backend/tool/image_client.py
index eec968c..78f6019 100644
--- a/aigc-director/aigc-claw/backend/tool/image_client.py
+++ b/aigc-director/aigc-claw/backend/tool/image_client.py
@@ -12,11 +12,11 @@
from tool.image_gpt import ImageGPT
from tool.image_processor import ImageProcessor
except ImportError:
- from image_dashscope import DashScopeClient
- from image_jimeng import JiMengClient
- from image_seedream import SeedreamClient
- from image_gpt import ImageGPT
- from image_processor import ImageProcessor
+ from .image_dashscope import DashScopeClient
+ from .image_jimeng import JiMengClient
+ from .image_seedream import SeedreamClient
+ from .image_gpt import ImageGPT
+ from .image_processor import ImageProcessor
class ImageClient:
def __init__(self,
diff --git a/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx b/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx
index 209ecbf..c7236a1 100644
--- a/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx
+++ b/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx
@@ -959,14 +959,18 @@
} catch { /* ignore */ }
}
- // 如果 current_stage 不在 completedStages 中,也需要显示(可能是 stage_completed 或 running 状态)
+ // 如果 current_stage 不在 completedStages 中,也需要显示(可能是 stage_completed、running 或 error 状态)
if (currentStage && !completedStages.includes(currentStage)) {
+ const isError = status.status === 'error';
+ const isWaiting = status.status === 'waiting_in_stage';
+ const isCompleted = status.status === 'stage_completed';
+
newStates[currentStage] = {
- status: status.status === 'waiting_in_stage' ? 'waiting' : (status.status === 'stage_completed' ? 'completed' : 'running'),
+ status: isError ? 'error' : (isWaiting ? 'waiting' : (isCompleted ? 'completed' : 'running')),
progress: 100,
- progressMessage: status.status === 'waiting_in_stage' ? '等待确认' : (status.status === 'stage_completed' ? '已完成' : '进行中'),
+ progressMessage: isError ? '执行失败' : (isWaiting ? '等待确认' : (isCompleted ? '已完成' : '进行中')),
artifact: null,
- error: null,
+ error: isError ? (status.error || '执行出错') : null,
};
try {
const artResult = await getArtifact(sid, currentStage);
diff --git a/aigc-director/aigc-claw/frontend/components/stages/StageActions.tsx b/aigc-director/aigc-claw/frontend/components/stages/StageActions.tsx
index 591b9c8..4f24ace 100644
--- a/aigc-director/aigc-claw/frontend/components/stages/StageActions.tsx
+++ b/aigc-director/aigc-claw/frontend/components/stages/StageActions.tsx
@@ -50,15 +50,12 @@
// 重新生成/继续生成按钮:在 waiting / completed / error 状态下显示
const showRegen = onRegenerate && (status === 'waiting' || status === 'completed' || status === 'error');
- // 判断按钮是否可用
- let canRegenerate = isRunning;
- if (isContinueStage) {
- // 阶段2、4、5:如果没有待生成的项,禁止点击
- canRegenerate = canRegenerate || !hasPendingItems;
- } else if (isRegenStage) {
- // 阶段1、3:如果后续阶段已开始,禁止点击
- canRegenerate = canRegenerate || hasNextStageStarted;
- }
+ // 判断按钮是否禁用
+ const isButtonDisabled = isRunning || (
+ status !== 'error' && (
+ isContinueStage ? !hasPendingItems : (isRegenStage ? hasNextStageStarted : false)
+ )
+ );
// 其余按钮在 waiting、running、completed 状态显示
const showActions = status === 'waiting' || status === 'running' || status === 'completed';
@@ -87,9 +84,9 @@
{showRegen && (
<button
onClick={onRegenerate}
- disabled={canRegenerate}
+ disabled={isButtonDisabled}
className="flex items-center gap-2 px-4 py-2 bg-white border border-orange-300 text-orange-600 rounded-lg text-sm font-medium hover:bg-orange-50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
- title={isContinueStage && !hasPendingItems ? '所有项已生成完毕' : (isRegenStage && hasNextStageStarted ? '后续阶段已开始,无法重新生成' : '')}
+ title={isButtonDisabled ? (status === 'error' ? '重新尝试生成' : (isContinueStage && !hasPendingItems ? '所有项已生成完毕' : (isRegenStage && hasNextStageStarted ? '后续阶段已开始,无法重新生成' : ''))) : ''}
>
{isContinueStage ? <Play className="w-4 h-4" /> : <RefreshCw className="w-4 h-4" />}
{isContinueStage ? '继续生成' : '重新生成'}
diff --git a/search.log b/search.log
new file mode 100644
index 0000000..5b63216
--- /dev/null
+++ b/search.log
Binary files differ
--
Gitblit v1.8.0