执行循环节点 参数: node: 节点实体 inputs: 输入数据(来自前驱节点) context: 执行上下文 返回: 所有迭代结果的数组
(self, node: Node, inputs: dict[str, Any], context: dict[str, Any])
| 54 | } |
| 55 | |
| 56 | async def execute(self, node: Node, inputs: dict[str, Any], context: dict[str, Any]) -> Any: |
| 57 | """执行循环节点 |
| 58 | |
| 59 | 参数: |
| 60 | node: 节点实体 |
| 61 | inputs: 输入数据(来自前驱节点) |
| 62 | context: 执行上下文 |
| 63 | |
| 64 | 返回: |
| 65 | 所有迭代结果的数组 |
| 66 | """ |
| 67 | loop_type = node.config.get("type", "") |
| 68 | |
| 69 | if not loop_type: |
| 70 | raise DomainError("Loop 节点缺少循环类型") |
| 71 | |
| 72 | if loop_type == "for_each": |
| 73 | return await self._for_each_loop(node.config, inputs, context) |
| 74 | elif loop_type == "range": |
| 75 | return await self._range_loop(node.config, inputs, context) |
| 76 | elif loop_type == "while": |
| 77 | return await self._while_loop(node.config, inputs, context) |
| 78 | else: |
| 79 | raise DomainError(f"不支持的循环类型: {loop_type}") |
| 80 | |
| 81 | async def _for_each_loop( |
| 82 | self, config: dict, inputs: dict[str, Any], context: dict[str, Any] |
nothing calls this directly
no test coverage detected