| | |
| | | return |
| | | |
| | | # 如果有 progress 回调(纯文字阶段),也定期保存 |
| | | # 这样前端可以实时看到文字生成进度 |
| | | current_time = time.time() |
| | | if current_time - last_save_time["time"] >= SAVE_INTERVAL: |
| | | last_save_time["time"] = current_time |
| | |
| | | |
| | | try: |
| | | result = await agent.process(input_data, intervention=intervention) |
| | | if not isinstance(result, dict): |
| | | logger.error(f"[execute_stage] Agent {stage.value} returned non-dict result: {type(result)}") |
| | | result = {"payload": result} |
| | | |
| | | state.artifacts[stage.value] = result.get("payload") |
| | | |
| | | # 第三阶段修改分镜时:同步更新第四、第五阶段的相关内容 |
| | | if stage.value == "storyboard" and intervention and "modified_storyboard" in intervention: |
| | | # 只有在 storyboard 阶段明确有修改时才执行同步 |
| | | if stage.value == "storyboard" and isinstance(intervention, dict) and "modified_storyboard" in intervention: |
| | | modified_shots = intervention["modified_storyboard"] |
| | | if isinstance(modified_shots, list): |
| | | shot_durations = {s.get('shot_id'): s.get('duration', 10) |
| | |
| | | if state.meta: |
| | | for k, v in state.meta.items(): |
| | | if v is not None: |
| | | data[k] = v |
| | | # 转换并保持原始类型(尤其是布尔值) |
| | | if isinstance(v, str) and v.lower() == 'true': |
| | | data[k] = True |
| | | elif isinstance(v, str) and v.lower() == 'false': |
| | | data[k] = False |
| | | else: |
| | | data[k] = v |
| | | |
| | | # 原子写入:先写临时文件,再重命名 |
| | | dir_path = os.path.dirname(path) |