diff --git a/agent/component/iteration.py b/agent/component/iteration.py index ae5c0b677..de630c1dd 100644 --- a/agent/component/iteration.py +++ b/agent/component/iteration.py @@ -57,12 +57,10 @@ class Iteration(ComponentBase, ABC): return cid def _invoke(self, **kwargs): - if self.check_if_canceled("Iteration processing"): - return - - arr = self._canvas.get_variable_value(self._param.items_ref) - if not isinstance(arr, list): - self.set_output("_ERROR", self._param.items_ref + " must be an array, but its type is "+str(type(arr))) + if not self.check_if_canceled("Iteration processing"): + arr = self._canvas.get_variable_value(self._param.items_ref) + if not isinstance(arr, list): + self.set_output("_ERROR", self._param.items_ref + " must be an array, but its type is "+str(type(arr))) def thoughts(self) -> str: return "Need to process {} items.".format(len(self._canvas.get_variable_value(self._param.items_ref))) diff --git a/agent/component/loop.py b/agent/component/loop.py index 484dfae82..dd04cd093 100644 --- a/agent/component/loop.py +++ b/agent/component/loop.py @@ -51,29 +51,27 @@ class Loop(ComponentBase, ABC): return cid def _invoke(self, **kwargs): - if self.check_if_canceled("Loop processing"): - return - - for item in self._param.loop_variables: - if any([not item.get("variable"), not item.get("input_mode"), not item.get("value"),not item.get("type")]): - assert "Loop Variable is not complete." - if item["input_mode"]=="variable": - self.set_output(item["variable"],self._canvas.get_variable_value(item["value"])) - elif item["input_mode"]=="constant": - self.set_output(item["variable"],item["value"]) - else: - if item["type"] == "number": - self.set_output(item["variable"], 0) - elif item["type"] == "string": - self.set_output(item["variable"], "") - elif item["type"] == "boolean": - self.set_output(item["variable"], False) - elif item["type"].startswith("object"): - self.set_output(item["variable"], {}) - elif item["type"].startswith("array"): - self.set_output(item["variable"], []) + if not self.check_if_canceled("Loop processing"): + for item in self._param.loop_variables: + if any([not item.get("variable"), not item.get("input_mode"), not item.get("value"),not item.get("type")]): + assert "Loop Variable is not complete." + if item["input_mode"]=="variable": + self.set_output(item["variable"],self._canvas.get_variable_value(item["value"])) + elif item["input_mode"]=="constant": + self.set_output(item["variable"],item["value"]) else: - self.set_output(item["variable"], "") + if item["type"] == "number": + self.set_output(item["variable"], 0) + elif item["type"] == "string": + self.set_output(item["variable"], "") + elif item["type"] == "boolean": + self.set_output(item["variable"], False) + elif item["type"].startswith("object"): + self.set_output(item["variable"], {}) + elif item["type"].startswith("array"): + self.set_output(item["variable"], []) + else: + self.set_output(item["variable"], "") def thoughts(self) -> str: