cleaned up run
Browse files63 unmodified lines64656667686970717273747576777879808182838485868788899091929394959663 unmodified lines:param flow_config: The configuration of the flow (see Configuration Parameters).:param subflows: A list of subflows. Required when instantiating the subflow programmatically (it replaces subflows_config from flow_config)."""def __init__(self, flow_config: Dict[str, Any], subflows: Dict[str, Any] = None):super().__init__(flow_config, subflows)def set_up_flow_state(self):super().set_up_flow_state()def run(self,input_data):executor_reply = input_datafor round in range(self.flow_config["max_rounds"]):controller_reply = self.ask_subflow("Controller", executor_reply).get_data()if controller_reply["command"] == "finish":return {"EARLY_EXIT": True,"answer": controller_reply["command_args"]["answer"],"status": "finished"}executor_reply = {"observation": self.ask_subflow(controller_reply["command"], controller_reply["command_args"]).get_data()}return {"answer": "The maximum amount of rounds was reached before the model found an answer.","status": "unfinished"}63 unmodified lines64656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610763 unmodified lines:param flow_config: The configuration of the flow (see Configuration Parameters).:param subflows: A list of subflows. Required when instantiating the subflow programmatically (it replaces subflows_config from flow_config)."""def _on_reach_max_round(self):""" This method is called when the flow reaches the maximum amount of rounds. It updates the state of the flow and starts the process of terminating the flow."""self._state_update_dict({"answer": "The maximum amount of rounds was reached before the model found an answer.","status": "unfinished"})def _single_round_controller_executor(self, executor_reply: Dict[str,Any]) -> Dict[str,Any]:controller_reply = self.ask_subflow("Controller", executor_reply).get_data()if controller_reply["command"] == "finish":return {"EARLY_EXIT": True,"answer": controller_reply["command_args"]["answer"],"status": "finished"}executor_reply = {"observation": self.ask_subflow(controller_reply["command"], controller_reply["command_args"]).get_data()}return executor_replydef run(self,input_data):executor_reply = input_datafor round in range(self.flow_config["max_rounds"]):executor_reply = self._single_round_controller_executor(executor_reply)if executor_reply.get("EARLY_EXIT",False):return executor_replyself._on_reach_max_round()return {"EARLY_EXIT": False,"answer": executor_reply["observation"],"status": "unfinished"}
ControllerExecutorFlow.py+31-20