From 36d50f25052f71fb80ae8cfb3116c001f83216b5 Mon Sep 17 00:00:00 2001
From: hit-cxf <2024111082@stu.hit.edu.cn>
Date: Thu, 09 Apr 2026 18:49:11 +0800
Subject: [PATCH] aigc-claw-v3 新增无限续写功能
---
aigc-director/aigc-claw/backend/tool/llm_dashscope.py | 4 +
aigc-director/aigc-claw/backend/prompts/storyboard/shot_zh.txt | 1
aigc-director/aigc-claw/backend/prompts/script/act_extract_sequel_en.txt | 30 ++++++++++
aigc-director/aigc-claw/backend/prompts/script/meta_extract_sequel_en.txt | 54 ++++++++++++++++++
aigc-director/aigc-claw/backend/prompts/script/generate_script_en.txt | 5 +
aigc-director/aigc-claw/backend/prompts/script/smart_continue_script_zh.txt | 3
aigc-director/aigc-claw/backend/tool/llm_gemini.py | 2
aigc-director/aigc-claw/backend/prompts/script/meta_extract_en.txt | 28 ++++++--
aigc-director/aigc-claw/backend/prompts/script/meta_extract_sequel_zh.txt | 33 +++++++++--
aigc-director/aigc-claw/backend/prompts/script/generate_script_zh.txt | 3
aigc-director/aigc-claw/backend/tool/llm_deepseek.py | 4 +
11 files changed, 147 insertions(+), 20 deletions(-)
diff --git a/aigc-director/aigc-claw/backend/prompts/script/act_extract_sequel_en.txt b/aigc-director/aigc-claw/backend/prompts/script/act_extract_sequel_en.txt
new file mode 100644
index 0000000..78a18eb
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/act_extract_sequel_en.txt
@@ -0,0 +1,30 @@
+You are a professional script analyst. Your task is to accurately split the continued (sequel) script content into a JSON array based on episode labels (e.g., "Episode {start_episode_num}", etc.).
+
+---
+
+[SCRIPT INPUT]
+
+{sequel_script}
+
+---
+
+[SPLITTING REQUIREMENTS]
+
+1. Please categorize the input script content into the corresponding `episode_number`. This continuation starts from Episode {start_episode_num}.
+2. For `act_title`, please summarize a concise title within 10 words.
+3. For `content`, please include the full original script text of that episode (including scene descriptions, action instructions, and character dialogues).
+
+**NOTICE (STRICTLY FOLLOW):**
+1. **Output Format**: You must and only output a pure JSON array. Markdown formats (such as ```json blocks), explanatory text, or closing remarks are strictly prohibited.
+2. Ensure the JSON structure is complete and valid.
+
+---
+
+[OUTPUT FORMAT EXAMPLE (ONLY return this JSON array)]
+[
+ {{
+ "episode_number": {start_episode_num},
+ "act_title": "Episode Title",
+ "content": "Detailed script content..."
+ }}
+]
diff --git a/aigc-director/aigc-claw/backend/prompts/script/generate_script_en.txt b/aigc-director/aigc-claw/backend/prompts/script/generate_script_en.txt
index a82799a..56f5129 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/generate_script_en.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/generate_script_en.txt
@@ -6,10 +6,13 @@
For example: `**x-x Day/Night Int/Ext Scene Name**`
The next line specifies `Characters: xxx, xxx`, followed by a blank line.
3. **Action and Visual Descriptions**: Action descriptions must start with "<action>" (e.g., "<action>Lin Yichen stares at the screen, dark circles under his eyes..."). Never write psychological activities that cannot be filmed.
-4. **Vivid and Concise Dialogue**: Dialogues should fit the character's identity and emotions. Emotion and action hints are written in parentheses after the character's name. Example: `Lin Yichen (sneering): ...`
+4. **Vivid Dialogue and Synchronized Monologue**: Dialogues should fit the character's identity and emotions. Emotion and action hints are written in parentheses after the character's name. Example: `Lin Yichen (sneering): ...`
+ * **Text Synchronization Technique**: If key visual text appears in the script (such as text on the wall, email subject, SMS content, etc.), a line of character dialogue must be added (can be normal dialogue, reading aloud, off-screen voice OS, or inner-monologue VO). **The dialogue must output the complete and specific text body; using generic terms like "reading the SMS content" or "seeing the text" is strictly prohibited.** Example: `Lin Yichen (reading aloud): Honey, let's break up.` (Instead of: `Lin Yichen: [Reads the SMS]`).
5. **Strong Dramatic Satisfaction**: The opening should quickly cut into the core conflict (such as being fired, betrayed, humiliated), and then swiftly enter the counterattack/entrepreneurship/face-slapping phase. The pace must be fast and emotions high.
6. **Visual Contrast**: Use the contrast between bottom-level dilapidated scenes and top-level luxurious scenes to enhance dramatic tension.
7. **No Separate Lore/Settings**: Do not write character bios or background outlines. Start the script text directly.
+8. **Use Dialogue to Drive the Plot**: Use more dialogue, monologues, and off-screen voices to express the character's thoughts, drive the plot development, and create conflicts.
+9. **Script Length Requirements**: Each episode is 1-2 minutes long, roughly 20-30 actions or dialogues (i.e., 20-30 lines per episode). Pay attention to controlling the length of each episode's script.
---
[Script Example (Learn its action, dialogue, and rhythmic structure)]:
diff --git a/aigc-director/aigc-claw/backend/prompts/script/generate_script_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/generate_script_zh.txt
index cf36b76..62a55e9 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/generate_script_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/generate_script_zh.txt
@@ -7,7 +7,8 @@
每集可以只有一个场景,也可以有多个场景。如果不同剧集中需要在相同场景拍摄,请确保场景名称完全一致。
下一行写明`人物:xxx, xxx`,再下一行空出。
3. **动作与视觉描述**:动作描述必须以“<action>”开头,描述客观存在的物理动作和镜头画面(如“<action>林逸尘盯着屏幕,眼眶乌青,手指在键盘上飞快敲击。”)。绝不写无法拍出的心理活动。
-4. **生动的对话**:对白要符合人物的身份与情绪,情绪和动作提示写在角色名后的括号里。例如:`林逸尘(冷笑):……`
+4. **生动的对话与同步独白**:对白要符合人物的身份与情绪,情绪和动作提示写在角色名后的括号里。例如:`林逸尘(冷笑):……`
+ * **文字同步技巧**:剧本中若出现墙上的字、邮件题目、短信内容等关键视觉文字,必须增加一行角色的台词(可以是正常对白、画外音OS或内心独白VO)。**台词必须包含完整的文字内容,绝对禁止使用“读出短信内容”、“显示文字”等概括性代词指代。** 例如:`林逸尘(读出内容):亲爱的,我们分手吧。`
5. **强烈的剧作爽感**:开场迅速切入核心冲突(如被开除、被背叛、被羞辱等最低谷),然后迅速进入反击/创业/打脸环节,节奏必须要快,情绪拉满。
6. **场景与视觉反差**:利用底层破败场景与顶层奢华场景的落差,增强戏剧张力。
7. **不要单独的设定集**:不需要写人物小传或大纲背景,直接开始写剧本正文。
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
index 8c9dd85..f138e61 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/meta_extract_en.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/meta_extract_en.txt
@@ -2,25 +2,37 @@
{script_text}
-Please extract the following information, specifically building the [Global Asset Tone (Core Characters and Main Settings)]. Their appearances and layouts will remain unchanged throughout the drama. Additionally, tell me how many total episodes and their titles.
-Output ONLY pure JSON format (direct JSON, no ``` wrappers, no extra text):
+[Design Requirements (Strictly Follow)]:
+1. **Output Format**: Must and only output a pure JSON object. Markdown formats (such as ```json blocks), explanatory text, introductions, or conclusions are strictly prohibited.
+2. **Extraction Object**: Extract all [Characters] and [Settings] that appear in the script with dialogues or key actions. Ignore group/extra characters.
+3. **Character Description**:
+ - Use the "age + gender + hairstyle/jewelry + clothing + body type + facial features/expression" format.
+ - Core Features: Must include hairstyle, body type, clothing color and style, etc.
+ - Prohibition: No sci-fi or fantasy elements; appearance must be normal.
+ - Style: 30-50 words, plain and direct language, no metaphors or literary rhetoric.
+4. **Setting Description**:
+ - Use the "space type + lighting direction and color + core furniture/decor (texture/material) + atmosphere" format.
+ - Style: 30-50 words, concrete and shootable description.
+ - Example: "Modern minimalist office, cold moonlight spills through floor-to-ceiling windows, the desk is cold-toned solid wood, atmosphere is quiet and serious."
+
+---
+[Output Format Example (ONLY return this JSON object)]:
{{
- "title": "Story Title (2-8 words)",
- "logline": "Complete story synopsis (100-200 words)",
- "total_episodes": 4, // Actual total number of episodes present in text
+ "title": "Story Title",
+ "logline": "One-sentence story outline",
"genre": ["genre1", "genre2"],
"mood": "Emotional tone",
"characters": [
{{
"name": "Full name of protagonist/major supporting character",
- "description": "Appearance: age+gender+hairstyle/jewelry+clothing+body type+facial features. Must be objective visual description, no metaphors, 30-50 words.",
+ "description": "Appearance description, requirements see [Design Requirements]",
"species": "Human or specific animal species"
}}
],
"settings": [
{{
- "name": "Main Setting Name (Int) or (Ext)",
- "description": "General setting description: core functional areas, main furniture/objects, spatial perception, color palette and lighting. No characters, 30-50 words."
+ "name": "Specific Setting Name",
+ "description": "General setting description, requirements see [Design Requirements]"
}}
]
}}
\ No newline at end of file
diff --git a/aigc-director/aigc-claw/backend/prompts/script/meta_extract_sequel_en.txt b/aigc-director/aigc-claw/backend/prompts/script/meta_extract_sequel_en.txt
new file mode 100644
index 0000000..3ca9547
--- /dev/null
+++ b/aigc-director/aigc-claw/backend/prompts/script/meta_extract_sequel_en.txt
@@ -0,0 +1,54 @@
+You are an experienced film and television production coordinator. Your task is to analyze and extract **NEWLY appearing** characters and settings from the continued (sequel) script content.
+
+---
+
+[INPUT]
+
+[Original Character List] (If an extracted character is already in this list, DO NOT add it to the new characters list):
+{existing_chars}
+
+[Original Setting List] (If an extracted setting already exists or can easily be merged into a known setting, DO NOT add it to the new settings list):
+{existing_settings}
+
+[New Sequel Script Content]:
+{sequel_script}
+
+---
+
+[DESIGN REQUIREMENTS]
+
+1. **Output Format**: You must output ONLY a pure JSON object. Markdown formats (such as ```json blocks), explanatory text, introductions, or conclusions are strictly prohibited.
+2. **Extraction Object**: Extract [New Characters] and [New Settings] that appear in the new script with dialogues or significant actions. Ignore extras or background groups.
+3. **Character Description**:
+ - Use the "age + gender + hairstyle/jewelry + clothing + body type + facial features/expression" format.
+ - Core Features: Must include hairstyle, body type, clothing color and style, etc.
+ - Style: 30-50 words, plain and direct language, no metaphors or artistic rhetoric.
+4. **Setting Description**:
+ - Use the "space type + lighting direction and color + core furniture/decor (texture/material) + atmosphere" format.
+ - Style: 30-50 words, concrete and shootable description.
+
+---
+
+[OUTPUT REQUIREMENTS]
+
+Please determine if there are new major characters or new core locations in the [New Sequel Script Content] based on the [Original Character List] and [Original Setting List]. If they exist, extract them and return them in a strict JSON structure.
+If new items exist, populate the respective lists. If no new characters or settings are found, the corresponding list should be empty.
+Output ONLY pure JSON (no markdown triple backticks, no extra commentary).
+
+The return JSON format must match exactly:
+
+{{
+ "new_characters": [
+ {{
+ "name": "Full name of the new character",
+ "description": "Appearance description, requirements see [DESIGN REQUIREMENTS]",
+ "role": "one of main/supporting/minor"
+ }}
+ ],
+ "new_settings": [
+ {{
+ "name": "New location name",
+ "description": "General setting description, requirements see [DESIGN REQUIREMENTS]"
+ }}
+ ]
+}}
diff --git a/aigc-director/aigc-claw/backend/prompts/script/meta_extract_sequel_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/meta_extract_sequel_zh.txt
index 42fe1fe..b75fa42 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/meta_extract_sequel_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/meta_extract_sequel_zh.txt
@@ -1,16 +1,37 @@
你是一位经验丰富的影视统筹助理。你的任务是从续写的连贯新剧本内容中,分析并提取**全新出现**的角色和场景。
-已知目前的角色清单(如果提取的人物和现有清单重复,请**不要**将其加入新人物列表,除非该人物有显著重大突破导致他需要作为新记录):
+---
+
+【输入】
+
+【原角色清单】(如果提取的人物和现有清单重复,请**不要**将其加入新人物列表):
{existing_chars}
-已知目前的场景清单(如果是已经存在或者能轻易并入已知场景的,**不要**加入新场景列表中):
+【原场景清单】(如果是已经存在或者能轻易并入已知场景的,**不要**加入新场景列表中):
{existing_settings}
-这是新续写的剧本内容:
+【新续写剧本内容】:
{sequel_script}
+---
+
+【设计要求】
+
+1. **输出格式**:必须且仅能输出一个纯净的 JSON 对象。严禁包含任何 Markdown 格式(如 ```json 代码块)、解释性文字、开场白或结尾。
+2. **提取对象**:提取新剧本中出现的、有台词或重要动作的【新角色】和【新场景】。注意忽略群体角色。
+3. **角色描述**:
+ - 采用“年龄+性别+发型/首饰+服装+体型+面部特征/神态”的概括性写法。
+ - 包含发型、体型、服装颜色和款式等视觉特征。
+ - 风格要求:30-50字,语言平实直接,禁止使用艺术化修辞。
+4. **场地布置**:
+ - 采用“空间类型+光效方向与颜色+核心陈设(质感/材质)+环境氛围”的概括性写法。
+ - 风格要求:30-50字,描述具体且具备可拍摄感。
+
+---
+
【输出要求】
-请你判断基于这些已有基础之上产生的新内容,里面是否存在新的主要角色和新出现的核心地点场景。如果存在,请提取出来,并按照严格的 JSON 结构返回。
+
+请你判断基于【原角色清单】【原场景清单】,【新续写剧本内容】中是否存在新的主要角色和新出现的核心地点场景。如果存在,请提取出来,并按照严格的 JSON 结构返回。
如果有,请存入对应列表。如果没有新人物或新场景,则对应列表为空。
请直接输出 JSON 格式(不要使用 markdown 的 ``` 包裹,并且不要含有额外文字)。
@@ -20,14 +41,14 @@
"new_characters": [
{{
"name": "新角色全名",
- "description": "对新角色的外貌、性格、特征以及在续集中作用的详细说明",
+ "description": "外貌描写,要求参见【设计要求】",
"role": "main/supporting/minor中的一种分类"
}}
],
"new_settings": [
{{
"name": "新地点名称",
- "description": "场景环境的地理、氛围、以及发生哪些续集故事的简述"
+ "description": "概括性场地描述,要求参见【设计要求】"
}}
]
}}
diff --git a/aigc-director/aigc-claw/backend/prompts/script/smart_continue_script_zh.txt b/aigc-director/aigc-claw/backend/prompts/script/smart_continue_script_zh.txt
index cda1e12..3f50b42 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/smart_continue_script_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/smart_continue_script_zh.txt
@@ -23,7 +23,8 @@
例如:`**a-b 日/夜 内/外 场景名称**`,其中a代表所属剧集,b代表剧集下的场景。
下一行写明`人物:xxx, xxx`,再下一行空出。
5. **动作与视觉描述**:动作描述必须以“<action>”开头,描述客观存在的物理动作和镜头画面(如“<action>林逸尘盯着屏幕,眼眶乌青,手指在键盘上飞快敲击。”)。绝不写无法拍出的心理活动。
-6. **生动的对话**:对白要符合人物的身份与情绪,情绪和动作提示写在角色名后的括号里。例如:`林逸尘(冷笑):……`
+6. **生动的对话与同步独白**:对白要符合人物的身份与情绪,情绪和动作提示写在角色名后的括号里。例如:`林逸尘(冷笑):……`
+ * **文字同步技巧**:剧本中涉及视觉文字(如墙上的挂画、匿名短信、电脑邮件、遗嘱等),必须紧接一行该角色的台词(可以是正常对白、读数、画外音OS或内心独白VO)。**台词必须输出完整的、具体的文字正文,绝对禁止使用“短信内容”、“黑板上的字”等代词来概括。**
7. **时长要求**:一集的时长在1-2分钟,大概是20-30个动作或台词(即每集剧本20-30行),注意控制每集剧本的篇幅。
【输出要求】
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 344ba06..021938a 100644
--- a/aigc-director/aigc-claw/backend/prompts/storyboard/shot_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/storyboard/shot_zh.txt
@@ -2,6 +2,7 @@
### 核心任务
剧本中每一行描述对应一个分镜。若干分镜组合成一个拍摄片段。
+**严禁重复输出相同内容,严禁陷入死循环(如连续输出重复的 shot_number 或内容)。** 若剧本单行内容极长,请在单个分镜内完整表述,不要拆分。
### 约束要求(严格遵守):
1. **输出格式**:必须且仅能输出一个纯净的 JSON 数组。严谨包含 ```json 代码块或其他引导性文字。
diff --git a/aigc-director/aigc-claw/backend/tool/llm_dashscope.py b/aigc-director/aigc-claw/backend/tool/llm_dashscope.py
index d9ee882..ed42745 100644
--- a/aigc-director/aigc-claw/backend/tool/llm_dashscope.py
+++ b/aigc-director/aigc-claw/backend/tool/llm_dashscope.py
@@ -39,6 +39,7 @@
dashscope.api_key = self.api_key
self.max_attempts = 3
+ self.max_tokens = 4096
def query(self, prompt: str, image_urls: list = None, model: str = "qwen3.5-vl", web_search: bool = False):
"""
@@ -76,7 +77,8 @@
"model": api_model,
"messages": messages,
"result_format": "message",
- "stream": False
+ "stream": False,
+ "max_tokens": self.max_tokens
}
# Add web search if enabled
if web_search:
diff --git a/aigc-director/aigc-claw/backend/tool/llm_deepseek.py b/aigc-director/aigc-claw/backend/tool/llm_deepseek.py
index 882b895..34b34e2 100644
--- a/aigc-director/aigc-claw/backend/tool/llm_deepseek.py
+++ b/aigc-director/aigc-claw/backend/tool/llm_deepseek.py
@@ -19,6 +19,7 @@
base_url=self.base_url
)
self.max_attempts = 3
+ self.max_tokens = 8000
def query(self, prompt, image_urls=[], model="deepseek-chat", web_search=False):
"""
@@ -39,7 +40,8 @@
request_params = {
"model": model,
"messages": messages,
- "stream": False
+ "stream": False,
+ "max_tokens": self.max_tokens
}
response = self.client.chat.completions.create(**request_params)
diff --git a/aigc-director/aigc-claw/backend/tool/llm_gemini.py b/aigc-director/aigc-claw/backend/tool/llm_gemini.py
index 9562649..ef59ad7 100644
--- a/aigc-director/aigc-claw/backend/tool/llm_gemini.py
+++ b/aigc-director/aigc-claw/backend/tool/llm_gemini.py
@@ -34,7 +34,7 @@
self.api_key = api_key or os.getenv("GEMINI_API_KEY", "")
self.client = OpenAI(api_key=self.api_key, base_url=self.base_url)
self.max_attempts = 10
- self.max_tokens = 20000
+ self.max_tokens = 8192
def query(self, prompt: str, image_urls: List[str] = [], model: str = "gemini-2.5-flash") -> str:
"""
--
Gitblit v1.8.0