From 8ea0647c968cfc82821bf2d99a32df09f6fab8f1 Mon Sep 17 00:00:00 2001
From: hit-cxf <2024111082@stu.hit.edu.cn>
Date: Thu, 02 Apr 2026 20:43:11 +0800
Subject: [PATCH] 修复了视频长宽比的问题 完善了人物场景提示词

---
 aigc-director/aigc-claw/backend/core/agents/video_agent.py           |   16 +-
 aigc-director/aigc-claw/backend/core/agents/character_agent.py       |    5 
 aigc-director/aigc-claw/backend/prompts/reference/first_frame_zh.txt |   21 ++--
 aigc-director/aigc-claw/backend/api_server.py                        |    7 
 aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx        |   27 ++++
 aigc-director/aigc-claw/backend/tool/image_client.py                 |   56 +++++++++-
 aigc-director/aigc-claw/backend/tool/video_client.py                 |    5 
 aigc-director/aigc-claw/backend/tool/video_kling.py                  |    2 
 aigc-director/aigc-claw/backend/core/agents/base_agent.py            |   39 +++++++
 aigc-director/aigc-claw/backend/prompts/script/act_extract_zh.txt    |   24 ++++
 aigc-director/aigc-claw/backend/prompts/reference/first_frame_en.txt |   23 ++--
 aigc-director/aigc-claw/backend/core/agents/reference_agent.py       |   73 +++++++++++---
 aigc-director/aigc-claw/frontend/lib/workflowApi.ts                  |    2 
 13 files changed, 232 insertions(+), 68 deletions(-)

diff --git a/aigc-director/aigc-claw/backend/api_server.py b/aigc-director/aigc-claw/backend/api_server.py
index 0db61f5..85762cc 100644
--- a/aigc-director/aigc-claw/backend/api_server.py
+++ b/aigc-director/aigc-claw/backend/api_server.py
@@ -965,6 +965,7 @@
     model: str
     prompt: str
     image: str  # 参考图片URL或base64
+    ratio: Optional[str] = "16:9"
 
 
 class SandboxVideoRequest(BaseModel):
@@ -1070,8 +1071,8 @@
     import traceback
     client = ImageClient()
     try:
-        print(f"[T2I] Generating image with model: {req.model}, prompt: {req.prompt[:50]}...")
-        result = client.generate_image(req.prompt, model=req.model, image_paths=None)
+        print(f"[T2I] Generating image with model: {req.model}, prompt: {req.prompt[:50]}..., ratio: {req.ratio}")
+        result = client.generate_image(req.prompt, model=req.model, image_paths=None, video_ratio=req.ratio)
         print(f"[T2I] Result: {result}")
         # result 是图片路径列表
         # 保存到历史记录
@@ -1095,7 +1096,7 @@
     from tool.image_client import ImageClient
     client = ImageClient()
     try:
-        result = client.generate_image(req.prompt, image_paths=[req.image], model=req.model)
+        result = client.generate_image(req.prompt, image_paths=[req.image], model=req.model, video_ratio=req.ratio)
         # 保存到历史记录
         record_id = _add_record(
             tool="i2i",
diff --git a/aigc-director/aigc-claw/backend/core/agents/base_agent.py b/aigc-director/aigc-claw/backend/core/agents/base_agent.py
index 9895dad..065ee3e 100644
--- a/aigc-director/aigc-claw/backend/core/agents/base_agent.py
+++ b/aigc-director/aigc-claw/backend/core/agents/base_agent.py
@@ -4,8 +4,11 @@
 """
 
 import logging
+import os
+import json
 from abc import ABC, abstractmethod
 from typing import Any, Optional, Dict, Callable
+from config import settings
 
 logger = logging.getLogger(__name__)
 
@@ -18,6 +21,42 @@
         self.cancellation_check: Optional[Callable] = None
         self.progress_callback: Optional[Callable] = None
 
+    def _merge_session_params(self, input_data: Any) -> Dict:
+        """从 session.json 补齐缺失的参数"""
+        if not isinstance(input_data, dict):
+            return {}
+            
+        sid = input_data.get("session_id")
+        if not sid:
+            return input_data
+
+        session_file = os.path.join(settings.SESSION_DIR, f"{sid}.json")
+        if not os.path.exists(session_file):
+            return input_data
+
+        try:
+            with open(session_file, 'r', encoding='utf-8') as f:
+                session_data = json.load(f)
+            
+            # 基础参数列表
+            keys_to_merge = [
+                "style", "video_ratio", "llm_model", "vlm_model", 
+                "image_t2i_model", "image_it2i_model", "video_model",
+                "video_style", "expand_idea"
+            ]
+            
+            merged_data = input_data.copy()
+            for key in keys_to_merge:
+                # 只有当 input_data 中缺失该参数时,才从 session 中补齐
+                if key not in merged_data or not merged_data[key]:
+                    if key in session_data:
+                        merged_data[key] = session_data[key]
+            
+            return merged_data
+        except Exception as e:
+            logger.error(f"Error merging session params: {e}")
+            return input_data
+
     def set_cancellation_check(self, fn: Callable):
         self.cancellation_check = fn
 
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 4dfedde..09de1cd 100644
--- a/aigc-director/aigc-claw/backend/core/agents/character_agent.py
+++ b/aigc-director/aigc-claw/backend/core/agents/character_agent.py
@@ -137,7 +137,8 @@
         else:
             base_prompt = self._setting_prompt(name, desc, style)
 
-        size = "1920*1080"
+        video_ratio = "16:9"
+        resolution = "1080P"
         current_prompt = base_prompt
 
         for iteration in range(max_iterations):
@@ -149,7 +150,7 @@
             try:
                 paths = img_client.generate_image(
                     prompt=current_prompt, model=t2i_model,
-                    session_id=str(sid), save_dir=save_dir, size=size,
+                    session_id=str(sid), save_dir=save_dir, video_ratio=video_ratio, resolution=resolution,
                 )
                 if not paths:
                     continue
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 300fbb2..bcb1107 100644
--- a/aigc-director/aigc-claw/backend/core/agents/reference_agent.py
+++ b/aigc-director/aigc-claw/backend/core/agents/reference_agent.py
@@ -178,7 +178,7 @@
     def _generate_one(self, img_client, sid: str, shot: dict,
                       first_frame_prompt: str, refs: List[str],
                       style: str, it2i_model: str, t2i_model: str,
-                      ref_size: str = "1920*1080", vlm_model: str = "qwen3.5-plus",
+                      video_ratio: str = "16:9", resolution: str = "1080P", vlm_model: str = "qwen3.5-plus",
                       character_description: str = "", setting_description: str = "",
                       max_versions: int = 3) -> tuple:
         """生成单个分镜参考图,返回 (shot_id, path_or_None, eval_result)
@@ -224,7 +224,8 @@
                     model=model,
                     session_id=str(sid),
                     save_dir=save_dir,
-                    size=ref_size,
+                    video_ratio=video_ratio,
+                    resolution=resolution,
                 )
                 if not paths:
                     continue
@@ -403,7 +404,7 @@
         }
 
     def _update_scene2image(self, sid: str, shots: list, result_file: str,
-                            first_frame_prompts: dict) -> None:
+                            first_frame_prompts: dict, selected_images: dict = None) -> None:
         """写回 scene2image 到结果文件
         scene2image[shot_id] = {
             local_path: 当前最新版本图片路径,
@@ -413,15 +414,24 @@
             duration: 分镜时长,
         }
         """
+        if selected_images is None:
+            selected_images = {}
+            
         with open(result_file, 'r', encoding='utf-8') as f:
             res = json.load(f)
-        scene_images = {}
+        scene_images = res.get(str(sid), {}).get('scene2image', {})
         for shot in shots:
             shot_id = shot['shot_id']
-            versions = self._list_versions(sid, shot_id)
-            if versions:
+            # 优先使用实时传入的选定路径,否则寻找磁盘已有版本
+            selected = selected_images.get(shot_id)
+            if not selected:
+                versions = self._list_versions(sid, shot_id)
+                if versions:
+                    selected = versions[-1]
+            
+            if selected:
                 scene_images[shot_id] = {
-                    "local_path": versions[-1],
+                    "local_path": selected,
                     "prompt": first_frame_prompts.get(shot_id, shot.get('visual_prompt', '')),
                     "plot": shot.get('plot', ''),
                     "video_prompt": shot.get('visual_prompt', ''),
@@ -438,10 +448,14 @@
         from tool.image_client import ImageClient
         from tool.llm_client import LLM
 
+        # 从 session.json 补齐缺失的参数(关键修复:防止前端漏传导致的默认值回退)
+        input_data = self._merge_session_params(input_data)
+
         sid = input_data["session_id"]
+        
         style = input_data.get("style", "anime")
         video_ratio = input_data.get("video_ratio", "16:9")
-        ref_size = ratio_to_size(video_ratio)
+        resolution = input_data.get("resolution", "1080P")
         llm_model = input_data.get("llm_model", "") or settings.LLM_MODEL
         t2i = input_data.get("image_t2i_model", "") or settings.IMAGE_T2I_MODEL
         it2i = input_data.get("image_it2i_model", "") or settings.IMAGE_IT2I_MODEL
@@ -519,9 +533,12 @@
 
                 llm = LLM()
 
+                selected_images = {}
+
                 def regen_run():
                     total = len(regen_scenes)
                     done = 0
+                    nonlocal selected_images
                     # 每分镜5个步骤:准备(1)、生成(3)、完成(1)
                     steps_per_shot = 5
                     total_steps = total * steps_per_shot
@@ -551,7 +568,7 @@
                             fut = executor.submit(
                                 self._generate_one, img_client, sid,
                                 shot, prompt_map[shot_id], refs,
-                                style, it2i, t2i, ref_size, vlm_model,
+                                style, it2i, t2i, video_ratio, resolution, vlm_model,
                                 character_description=char_desc, setting_description=set_desc
                             )
                             futs[fut] = shot_id
@@ -566,6 +583,7 @@
                             step = done * steps_per_shot
                             pct = calc_pct_regen(step)
                             if result_path:
+                                selected_images[shot_id_done] = result_path
                                 versions = self._list_versions(sid, shot_id_done)
                                 self._report_progress("参考图", f"完成: {shot_id_done}", pct, data={
                                     "asset_complete": {
@@ -594,11 +612,11 @@
                 loop = asyncio.get_running_loop()
                 await loop.run_in_executor(None, regen_run)
 
-            # 重新生成后更新 scene2image(同步最新版本信息)
-            self._update_scene2image(sid, shots, result_file, {})
+                # 重新生成后更新 scene2image(同步最新版本信息)
+                self._update_scene2image(sid, fresh_shots, result_file, {}, selected_images)
 
-            self._report_progress("参考图", "完成", 100)
-            return self._build_payload(sid, shots)
+                self._report_progress("参考图", "完成", 100)
+                return self._build_payload(sid, fresh_shots)
 
         # ═══ 正常流程:全量生成 ═══
         self._report_progress("参考图", "加载分镜数据...", 5)
@@ -612,6 +630,7 @@
         def run():
             # 筛选需要生成的(跳过已有图的)
             pending_shots = []
+            selected_images = {}
             for shot in shots:
                 shot_id = shot['shot_id']
                 existing = self._list_versions(sid, shot_id)
@@ -638,10 +657,29 @@
             self._report_progress("参考图", "准备生成...", calc_pct(0))
 
             # 步骤2-6(每分镜):准备提示词
-            first_frame_prompts = {}  # shot_id → prompt
+            first_frame_prompts = {}  # shot_id -> prompt
+            style = input_data.get('video_style', '')
             for i, shot in enumerate(pending_shots):
                 shot_id = shot['shot_id']
-                ff_prompt = shot.get('visual_prompt', '')
+                visual_prompt = shot.get('visual_prompt', '')
+                
+                # Load the new translation/style prompt template
+                prompt_text = load_prompt('reference', "first_frame", 'zh' if is_zh else 'en').format(
+                    visual_prompt=visual_prompt, 
+                    style=style
+                )
+                
+                # Call LLM to translate and append style tags
+                try:
+                    ff_prompt_resp = llm.query(prompt_text, max_tokens=1000, temperature=0.7)
+                    if hasattr(ff_prompt_resp, 'content'):
+                        ff_prompt = ff_prompt_resp.content.strip()
+                    else:
+                        ff_prompt = str(ff_prompt_resp).strip()
+                except Exception as e:
+                    logger.error(f"Error generating first-frame prompt for {shot_id}: {e}")
+                    ff_prompt = visual_prompt  # Fallback to pure visual prompt
+                
                 first_frame_prompts[shot_id] = ff_prompt
                 logger.info(f"[{shot_id}] first-frame prompt: {ff_prompt[:80]}...")
                 step = i * steps_per_shot + 1
@@ -665,7 +703,7 @@
                     fut = executor.submit(
                         self._generate_one, img_client, sid,
                         shot, ff_prompt, refs,
-                        style, it2i, t2i, ref_size, vlm_model,
+                        style, it2i, t2i, video_ratio, resolution, vlm_model,
                         character_description=char_desc, setting_description=set_desc
                     )
                     futs[fut] = shot_id
@@ -682,6 +720,7 @@
                     step = done * steps_per_shot
                     pct = calc_pct(step)
                     if result_path:
+                        selected_images[shot_id_done] = result_path
                         versions = self._list_versions(sid, shot_id_done)
                         self._report_progress("参考图", f"完成: {shot_id_done}", pct, data={
                             "asset_complete": {
@@ -714,7 +753,7 @@
                 self._report_progress("参考图", "保存结果...", 96)
 
             # 写回结果文件
-            self._update_scene2image(sid, shots, result_file, first_frame_prompts)
+            self._update_scene2image(sid, shots, result_file, first_frame_prompts, selected_images)
 
         loop = asyncio.get_running_loop()
         try:
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 57d2e37..9c127a7 100644
--- a/aigc-director/aigc-claw/backend/core/agents/video_agent.py
+++ b/aigc-director/aigc-claw/backend/core/agents/video_agent.py
@@ -64,7 +64,8 @@
     def _generate_one(self, sid: str, shot_id: str, prompt: str,
                       img_path: str, video_model: str,
                       duration: int = 5, sound: str = "",
-                      shot_type: str = "multi") -> tuple:
+                      shot_type: str = "multi",
+                      video_ratio: str = "16:9") -> tuple:
         """生成单个分镜视频,返回 (shot_id, path_or_None)"""
         # 取消时直接跳过,不抛异常,以保留已生成的部分结果
         if self.cancellation_check and self.cancellation_check():
@@ -87,6 +88,7 @@
                 duration=duration,
                 sound=sound,
                 shot_type=shot_type,
+                video_ratio=video_ratio,
             )
             return shot_id, save_path
         except Exception as e:
@@ -380,6 +382,9 @@
 
     async def process(self, input_data: Any, intervention: Optional[Dict] = None) -> Dict:
         from config import settings
+        
+        # 从 session.json 补齐缺失的参数(关键修复:防止前端漏传导致的默认值回退)
+        input_data = self._merge_session_params(input_data)
 
         sid = input_data["session_id"]
         video_model = input_data.get("video_model", "") or settings.VIDEO_MODEL
@@ -395,10 +400,7 @@
         
         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
-
-        logger.info(f"VideoDirectorAgent: sid={sid}, video_model={video_model}, sound={video_sound}, shot_type={video_shot_type}")
-
+        video_ratio = input_data.get("video_ratio", "16:9")
         result_file = os.path.join(settings.RESULT_DIR, 'script', f'script_{sid}.json')
 
         # 读取数据
@@ -468,7 +470,7 @@
                             fut = executor.submit(
                                 self._generate_one, sid, shot_id, prompt,
                                 img_path, video_model, shot_duration,
-                                sound_param, video_shot_type
+                                sound_param, video_shot_type, video_ratio
                             )
                             futs[fut] = shot_id
                         for fut in as_completed(futs):
@@ -546,7 +548,7 @@
                     fut = executor.submit(
                         self._generate_one, sid, shot_id, prompt,
                         img_path, video_model, shot_duration,
-                        sound_param, video_shot_type,
+                        sound_param, video_shot_type, video_ratio
                     )
                     futs[fut] = shot_id
                 for fut in as_completed(futs):
diff --git a/aigc-director/aigc-claw/backend/prompts/reference/first_frame_en.txt b/aigc-director/aigc-claw/backend/prompts/reference/first_frame_en.txt
index 870d697..2268e70 100644
--- a/aigc-director/aigc-claw/backend/prompts/reference/first_frame_en.txt
+++ b/aigc-director/aigc-claw/backend/prompts/reference/first_frame_en.txt
@@ -1,16 +1,15 @@
-You are a professional AI image prompt engineer.
-I need to generate a **first-frame reference image** for a {duration}-second video clip.
+You are a professional AI prompt translator and optimizer.
+Please translate and optimize the following visual description into a pure English image generation prompt for an AI image model.
 
-Shot plot description:
-{plot}
-
-Shot visual description:
+Visual Description:
 {visual_prompt}
 
+Selected Style:
+{style}
+
 Requirements:
-1. Output a pure English image generation prompt for an AI image model
-2. Describe the **first frame** (static image) of the video, capturing the starting moment
-3. Must include: character appearance/pose/expression, environment, lighting/color tone, composition/shot type
-4. For {duration}s video: {duration_hint}
-5. 80-150 English words
-6. Output ONLY the prompt text, no explanations or markers
+1. The main body of the prompt MUST exclusively reflect the [Visual Description] above. Do not invent extraneous plot elements.
+2. Based on the [Selected Style], append appropriate English style descriptors and keywords.
+3. You must add quality-boosting prompt words (e.g., masterpiece, best quality, high resolution, cinematic composition, etc.).
+4. The output must be pure English, with traits ideally separated by commas.
+5. Output ONLY the optimized prompt text. Do NOT include any explanations, prefixes, or extra markers.
diff --git a/aigc-director/aigc-claw/backend/prompts/reference/first_frame_zh.txt b/aigc-director/aigc-claw/backend/prompts/reference/first_frame_zh.txt
index 60f6d3d..a9db037 100644
--- a/aigc-director/aigc-claw/backend/prompts/reference/first_frame_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/reference/first_frame_zh.txt
@@ -1,16 +1,15 @@
-你是一位专业的AI绘画提示词工程师。
-我需要为一段{duration}秒的视频生成**首帧参考图**。
-
-分镜剧情描述:
-{plot}
+你是一位专业的AI提示词翻译与优化专家。
+请将以下分镜视觉描述翻译成纯英文的图像生成提示词(image prompt),用于AI绘图模型。
 
 分镜视觉描述:
 {visual_prompt}
 
+用户选择的风格:
+{style}
+
 要求:
-1. 输出一段纯英文的图像生成提示词(image prompt),用于AI绘图模型
-2. 描述的是视频**第一帧**的静态画面,要体现动作的起始瞬间
-3. 必须包含:角色外貌/姿态/表情、场景环境、光线/色调、构图/景别
-4. {duration}秒视频:{duration_hint}
-5. 字数控制在80-150个英文单词
-6. 只输出提示词文本,不要任何解释或标记
+1. 提示词主体必须紧扣上述的【分镜视觉描述】进行翻译,提炼画面要素,不要自行脑补多余的剧情。
+2. 根据用户选择的【风格】,在提示词前后加上相应的英文风格描述词。
+3. 必须加上提升画面质量的提示词(例如:masterpiece, best quality, high resolution, cinematic composition等)。
+4. 语言必须是纯英文,以逗号分隔特征词。
+5. 只输出合并优化后的提示词文本,不要出现任何解释语、前缀或多余内容。
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
index 920c238..eb5eaa2 100644
--- a/aigc-director/aigc-claw/backend/prompts/script/act_extract_zh.txt
+++ b/aigc-director/aigc-claw/backend/prompts/script/act_extract_zh.txt
@@ -12,7 +12,7 @@
     {{
       "name": "角色全名",
       "character_id": "char_加8位随机字母数字",
-      "description": "外貌描写: 含发型、体型、服装颜色和款式等视觉特征, 不要描述眼睛颜色, 面部不要有文字等特殊符号, 形象要正常(可以前卫时髦但不能恐怖灵异), 50-80字, 不要用比喻",
+      "description": "外貌描写: 遵循角色描述规范, 30-50字",
       "personality": ["性格特征1", "性格特征2", "性格特征3"],
       "motivation": "角色核心动机",
       "arc_description": "角色成长弧线",
@@ -25,7 +25,7 @@
     {{
       "name": "场景名称(室内) 或 场景名称(室外)",
       "setting_id": "set_加8位随机字母数字",
-      "description": "环境布局、色彩、光线、氛围等视觉细节, 80-120字, 不要包含人物或动物"
+      "description": "概括性场景描述:核心功能区、核心家具/物件、空间感受、色调与光影。30-50字。"
     }}
   ],
   "scenes": [
@@ -47,8 +47,24 @@
 3. settings的name需标注(室内)或(室外)
 4. 所有scene的act字段必须为{act_number}
 5. scene_number从{scene_start}开始递增
-6. 角色的description要有足够视觉细节用于AI图像生成
-7. setting的description要有足够视觉细节用于AI背景图生成
+6. 角色描述规范:
+   - 采用“年龄+性别+发型/首饰+服装+体型+面部特征/神态”的概括性写法。
+   - 核心特征:必须包含发型、体型、服装颜色和款式等视觉特征。
+   - 示例:
+     - ”40多岁中年男性,大背头,穿着考究的深色西装,体型微胖,面相精明且神态傲慢。“
+     - ”20多岁男性,短发,戴黑框眼镜,五官清秀且透着坚毅,穿着程序员风格的休闲卫衣。“
+   - 外貌必须正常:严禁描述伤口、血迹、残疾或过于奇特畸形的外形。
+   - 头发颜色必须正常:如黑色、棕色、金色等,严禁描述“发根青黑”、“斑驳色块”等微观细节(模型无法理解)。
+   - 禁止项:不要描述眼睛颜色,面部不要有文字、刺青或特殊几何符号。
+   - 风格要求:30-50字,语言平实直接,禁止使用比喻或文学化修辞。
+7. 场景描述规范:
+   - 采用“场景定位+核心物件+空间感受+色调光影”的概括性写法。
+   - 示例:
+     - ”现代企业办公区,密集的工位,杂乱的桌面,狭窄的走廊。场景呈现压抑的冷蓝灰色调,缺乏自然光。”
+     - ”高端明亮的独立办公室及会议室,宽大的会议桌,通透的落地窗。场景呈现温暖明亮的金色调,充满生机与质感。”
+   - 严禁堆砌琐碎细节,强调视觉印象(例如“现代办公区,杂乱桌面,压抑冷蓝调”)。
+   - 字数要求:30-50字。
+   - 禁止项:严禁在场景描述中包含人物或动物。
 8. 不要生成群体角色(如"邻居们"),每个角色都是独立个体
 9. scene的plot字段必须完整表达该分场的全部内容
 10. 只输出纯JSON
diff --git a/aigc-director/aigc-claw/backend/tool/image_client.py b/aigc-director/aigc-claw/backend/tool/image_client.py
index 78f6019..b2e7d1b 100644
--- a/aigc-director/aigc-claw/backend/tool/image_client.py
+++ b/aigc-director/aigc-claw/backend/tool/image_client.py
@@ -68,27 +68,66 @@
         # Default save directory
         self.base_save_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "code", "result", "image_client")
 
-    def generate_image(self, 
-                       prompt: str, 
-                       image_paths: Optional[List[str]] = None, 
+    def generate_image(self,
+                       prompt: str,
+                       image_paths: Optional[List[str]] = None,
                        model: str = "wan2.6-t2i",
                        save_dir: Optional[str] = None,
                        session_id: Optional[str] = None,
-                       size: Optional[str] = "1920*1080") -> List[str]:
+                       video_ratio: Optional[str] = "16:9",
+                       resolution: Optional[str] = "1080P") -> List[str]:
         """
         Generate images based on prompt and optional reference images.
-        
+
         Args:
             prompt: Text prompt for generation.
             image_paths: List of local file paths or URLs for reference images.
             model: Model name to determine which provider to use.
             save_dir: Custom directory to save downloaded images.
             session_id: Session ID for organizing saved files (especially for JiMeng)
-            size: Desired size of the generated image, e.g., "1024*1024" or "1920*1080".
-            
+            video_ratio: Aspect ratio of the video, e.g., "16:9", "9:16", "4:3", "3:4", "1:1".
+            resolution: Resolution string, e.g., "720P", "1080P", "2K", "4K".
+
         Returns:
             List of absolute file paths of the generated images.
         """
+        # Determine size from video_ratio and resolution
+        size_map = {
+            "16:9": {
+                "720P": "1280*720",
+                "1080P": "1920*1080",
+                "2K": "2560*1440",
+                "4K": "3840*2160"
+            },
+            "9:16": {
+                "720P": "720*1280",
+                "1080P": "1080*1920",
+                "2K": "1440*2560",
+                "4K": "2160*3840"
+            },
+            "4:3": {
+                "720P": "960*720",
+                "1080P": "1440*1080",
+                "2K": "2560*1920",
+                "4K": "3840*2880"
+            },
+            "3:4": {
+                "720P": "720*960",
+                "1080P": "1080*1440",
+                "2K": "1920*2560",
+                "4K": "2880*3840"
+            },
+            "1:1": {
+                "720P": "720*720",
+                "1080P": "1080*1080",
+                "2K": "2560*2560",
+                "4K": "3840*3840"
+            }
+        }
+        
+        # Default fallback if ratio or resolution is not found
+        size = size_map.get(video_ratio, size_map["16:9"]).get(resolution, "1920*1080")
+
         if not model:
             model = "wan2.6-t2i"
 
@@ -103,6 +142,9 @@
                     else:
                         print(f" - {p}")
             print(f"Model: {model}")
+            print(f"Video Ratio: {video_ratio}")
+            print(f"Resolution: {resolution}")
+            print(f"Final Size: {size}")
             if session_id:
                 print(f"Session ID: {session_id}")
             print("-" * 30)
diff --git a/aigc-director/aigc-claw/backend/tool/video_client.py b/aigc-director/aigc-claw/backend/tool/video_client.py
index 5104c0d..bb87bd2 100644
--- a/aigc-director/aigc-claw/backend/tool/video_client.py
+++ b/aigc-director/aigc-claw/backend/tool/video_client.py
@@ -69,6 +69,7 @@
         duration: int = 5,
         shot_type: str = "multi",
         sound: str = "",
+        video_ratio: str = "16:9",
     ) -> str:
         """
         生成视频
@@ -107,7 +108,7 @@
         model_lower = model.lower()
 
         if "jimeng" in model_lower:
-            return self._generate_jimeng(prompt, image_path, save_path, model)
+            return self._generate_jimeng(prompt, image_path, save_path, model, video_ratio)
         elif "kling" in model_lower:
             return self._generate_kling(prompt, image_path, save_path, model, duration, sound)
         else:
@@ -139,12 +140,14 @@
         image_path: str,
         save_path: str,
         model: str,
+        video_ratio: str = "16:9",
     ) -> str:
         """通过即梦模型生成视频"""
         logger.info(f"VideoClient: 路由至即梦 model={model}")
         task_id = self.jimeng_client.generate_video(
             prompt=prompt,
             image_path=image_path,
+            aspect_ratio=video_ratio,
         )
 
         # 轮询获取结果
diff --git a/aigc-director/aigc-claw/backend/tool/video_kling.py b/aigc-director/aigc-claw/backend/tool/video_kling.py
index 00bc582..64da880 100644
--- a/aigc-director/aigc-claw/backend/tool/video_kling.py
+++ b/aigc-director/aigc-claw/backend/tool/video_kling.py
@@ -148,7 +148,7 @@
         prompt: str = "",
         negative_prompt: str = "",
         model_name: str = "kling-v3",
-        mode: str = "std",
+        mode: str = "pro",
         duration: str = "5",
         cfg_scale: float = 0.5,
         sound: str = "",
diff --git a/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx b/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx
index c7236a1..4b23251 100644
--- a/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx
+++ b/aigc-director/aigc-claw/frontend/components/WorkflowPanel.tsx
@@ -434,12 +434,15 @@
       const result = await startProject({
         idea: params.idea,
         style: params.style,
+        video_ratio: params.video_ratio,
         llm_model: params.llm_model,
         vlm_model: params.vlm_model,
         image_t2i_model: params.image_t2i_model,
         image_it2i_model: params.image_it2i_model,
         video_model: params.video_model,
         enable_concurrency: params.enable_concurrency,
+        web_search: params.web_search,
+        expand_idea: params.expand_idea,
       });
       setSessionId(result.session_id);
 
@@ -460,6 +463,7 @@
         idea: params.idea,
         session_id: result.session_id,
         style: params.style,
+        video_ratio: params.video_ratio,
         llm_model: params.llm_model,
         vlm_model: params.vlm_model,
         image_t2i_model: params.image_t2i_model,
@@ -540,6 +544,7 @@
           image_t2i_model: projectParams?.image_t2i_model,
           image_it2i_model: projectParams?.image_it2i_model,
           video_model: projectParams?.video_model,
+          video_ratio: projectParams?.video_ratio,
           video_sound: videoSound,
           video_shot_type: videoShotType,
         };
@@ -619,6 +624,20 @@
   // ── 用户介入修改 ──
   const handleIntervene = async (stageId: string, modifications: Record<string, any>) => {
     if (!sessionId) return;
+    
+    // 构建完整的 inputData 传给后端,确保比例等参数能传递
+    const inputData: Record<string, any> = {
+      ...modifications,
+      session_id: sessionId,
+      style: projectParams?.style,
+      video_ratio: projectParams?.video_ratio,
+      llm_model: projectParams?.llm_model,
+      vlm_model: projectParams?.vlm_model,
+      image_t2i_model: projectParams?.image_t2i_model,
+      image_it2i_model: projectParams?.image_it2i_model,
+      video_model: projectParams?.video_model,
+    };
+
     // 设置 running 状态以便显示进度条(如 Logline 选择后生成剧本)
     // 若选择了 Logline,将其保存到 artifact 以便 ScriptStage 在生成期间展示
     // 若选择了模式,保留已选 Logline 并设置 generating 状态
@@ -630,7 +649,7 @@
     setIsRunning(true);
     updateStageState(stageId, { status: 'running', progress: 0, progressMessage: '处理中...', ...(artifactPatch ? { artifact: artifactPatch } : {}) });
     try {
-      const response = await intervene(sessionId, stageId, modifications);
+      const response = await intervene(sessionId, stageId, inputData);
       for await (const event of parseStreamEvents(response)) {
         if (event.type === 'progress') {
           updateStageState(stageId, {
@@ -887,8 +906,7 @@
         image_t2i_model: projectParams?.image_t2i_model,
         image_it2i_model: projectParams?.image_it2i_model,
         video_model: projectParams?.video_model,
-        video_sound: videoSound,
-        video_shot_type: videoShotType,
+            video_ratio: projectParams?.video_ratio,
       };
 
       // 尝试获取场景数
@@ -992,6 +1010,7 @@
           video_model: s.video_model || '',
           expand_idea: s.expand_idea || false,
           enable_concurrency: s.enable_concurrency || false,
+          web_search: s.web_search || false,
         });
       }
 
@@ -1055,6 +1074,8 @@
         video_model: projectParams.video_model,
         video_ratio: projectParams.video_ratio,
         enable_concurrency: projectParams.enable_concurrency || false,
+        web_search: projectParams.web_search || false,
+        expand_idea: projectParams.expand_idea || false,
       }
     : undefined;
 
diff --git a/aigc-director/aigc-claw/frontend/lib/workflowApi.ts b/aigc-director/aigc-claw/frontend/lib/workflowApi.ts
index aab26a8..01937e2 100644
--- a/aigc-director/aigc-claw/frontend/lib/workflowApi.ts
+++ b/aigc-director/aigc-claw/frontend/lib/workflowApi.ts
@@ -62,6 +62,8 @@
   video_model?: string;
   scene_number?: number;
   enable_concurrency?: boolean;
+  web_search?: boolean;
+  expand_idea?: boolean;
 }): Promise<{ session_id: string; status: string; params: any }> {
   const resp = await fetch('/api/project/start', {
     method: 'POST',

--
Gitblit v1.8.0