nbaldwin commited on
Commit
2cec66f
1 Parent(s): 4348c0d

changed location of early exit

Browse files
Files changed (1) hide show
  1. ControllerExecutorFlow.py +29 -22
ControllerExecutorFlow.py CHANGED
@@ -131,28 +131,15 @@ class ControllerExecutorFlow(CompositeFlow):
131
  self.subflows["Controller"].send_message_async(message, pipe_to= self.flow_config["flow_ref"])
132
 
133
  def call_executor(self):
134
-
135
- #detect and early exit
136
- if self.flow_state["command"] == "finish":
137
-
138
- self._state_update_dict(
139
- {
140
- "EARLY_EXIT": True,
141
- "answer": self.flow_state["command_args"]["answer"],
142
- "status": "finished"
143
- }
144
- )
145
- self.generate_reply()
146
-
147
  #call executor
148
- else:
149
- executor_branch_to_call = self.flow_state["command"]
150
- message = self._package_input_message(
151
- data = self.flow_state["command_args"],
152
- dst_flow = executor_branch_to_call
153
- )
154
-
155
- self.subflows[executor_branch_to_call].send_message_async(message, pipe_to= self.flow_config["flow_ref"])
156
 
157
 
158
  def register_data_to_state(self, input_message):
@@ -166,12 +153,27 @@ class ControllerExecutorFlow(CompositeFlow):
166
  self.flow_state["observation"] = input_message.data
167
 
168
  else:
 
169
  self._state_update_dict(
170
  {
171
  "command": input_message.data["command"],
172
  "command_args": input_message.data["command_args"]
173
  }
174
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
  def run(self,input_message: FlowMessage):
177
  """ Runs the WikiSearch Atomic Flow. It's used to execute a Wikipedia search and get page summaries.
@@ -184,11 +186,16 @@ class ControllerExecutorFlow(CompositeFlow):
184
 
185
  flow_to_call = self.get_next_flow_to_call()
186
 
187
- if flow_to_call == "Controller":
 
 
 
188
  self.call_controller()
 
189
  elif flow_to_call == "Executor":
190
  self.call_executor()
191
  self.flow_state["current_round"] += 1
 
192
  else:
193
  self._on_reach_max_round()
194
  self.generate_reply()
 
131
  self.subflows["Controller"].send_message_async(message, pipe_to= self.flow_config["flow_ref"])
132
 
133
  def call_executor(self):
134
+
 
 
 
 
 
 
 
 
 
 
 
 
135
  #call executor
136
+ executor_branch_to_call = self.flow_state["command"]
137
+ message = self._package_input_message(
138
+ data = self.flow_state["command_args"],
139
+ dst_flow = executor_branch_to_call
140
+ )
141
+
142
+ self.subflows[executor_branch_to_call].send_message_async(message, pipe_to= self.flow_config["flow_ref"])
 
143
 
144
 
145
  def register_data_to_state(self, input_message):
 
153
  self.flow_state["observation"] = input_message.data
154
 
155
  else:
156
+
157
  self._state_update_dict(
158
  {
159
  "command": input_message.data["command"],
160
  "command_args": input_message.data["command_args"]
161
  }
162
  )
163
+
164
+ #detect and early exit
165
+ if self.flow_state["command"] == "finish":
166
+
167
+ self._state_update_dict(
168
+ {
169
+ "EARLY_EXIT": True,
170
+ "answer": self.flow_state["command_args"]["answer"],
171
+ "status": "finished"
172
+ }
173
+ )
174
+ self.flow_state["early_exit_flag"] = True
175
+
176
+
177
 
178
  def run(self,input_message: FlowMessage):
179
  """ Runs the WikiSearch Atomic Flow. It's used to execute a Wikipedia search and get page summaries.
 
186
 
187
  flow_to_call = self.get_next_flow_to_call()
188
 
189
+ if self.flow_state.get("early_exit_flag",False):
190
+ self.generate_reply()
191
+
192
+ elif flow_to_call == "Controller":
193
  self.call_controller()
194
+
195
  elif flow_to_call == "Executor":
196
  self.call_executor()
197
  self.flow_state["current_round"] += 1
198
+
199
  else:
200
  self._on_reach_max_round()
201
  self.generate_reply()