hit-cxf
2026-04-02 57e08ce2f0ecbac8a5efa8a3c13f0a157f0a8956
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', {})