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/reference_agent.py |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

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', {})
 

--
Gitblit v1.8.0