ouput single round is dict
Browse files- ControllerExecutorFlow.py +16 -8
ControllerExecutorFlow.py
CHANGED
@@ -72,9 +72,11 @@ class ControllerExecutorFlow(CompositeFlow):
|
|
72 |
"status": "unfinished"
|
73 |
})
|
74 |
|
75 |
-
def _single_round_controller_executor(self,
|
76 |
|
77 |
-
|
|
|
|
|
78 |
|
79 |
if controller_reply["command"] == "finish":
|
80 |
return {
|
@@ -87,21 +89,27 @@ class ControllerExecutorFlow(CompositeFlow):
|
|
87 |
"observation": self.ask_subflow(controller_reply["command"], controller_reply["command_args"]).get_data()
|
88 |
}
|
89 |
|
90 |
-
return
|
|
|
|
|
|
|
91 |
|
92 |
def run(self,input_data):
|
93 |
|
94 |
-
|
|
|
|
|
|
|
95 |
|
96 |
for round in range(self.flow_config["max_rounds"]):
|
97 |
-
|
98 |
|
99 |
-
if
|
100 |
-
return
|
101 |
|
102 |
self._on_reach_max_round()
|
103 |
return {
|
104 |
"EARLY_EXIT": False,
|
105 |
-
"answer": executor_reply["observation"],
|
106 |
"status": "unfinished"
|
107 |
}
|
|
|
72 |
"status": "unfinished"
|
73 |
})
|
74 |
|
75 |
+
def _single_round_controller_executor(self, reply: Dict[str,Any]) -> Dict[str,Any]:
|
76 |
|
77 |
+
in_data = reply["executor_reply"]
|
78 |
+
|
79 |
+
controller_reply = self.ask_subflow("Controller", in_data).get_data()
|
80 |
|
81 |
if controller_reply["command"] == "finish":
|
82 |
return {
|
|
|
89 |
"observation": self.ask_subflow(controller_reply["command"], controller_reply["command_args"]).get_data()
|
90 |
}
|
91 |
|
92 |
+
return {
|
93 |
+
"controller_reply": controller_reply,
|
94 |
+
"executor_reply": executor_reply
|
95 |
+
}
|
96 |
|
97 |
def run(self,input_data):
|
98 |
|
99 |
+
reply = {
|
100 |
+
"executor_reply": input_data,
|
101 |
+
"controller_reply": None
|
102 |
+
}
|
103 |
|
104 |
for round in range(self.flow_config["max_rounds"]):
|
105 |
+
reply = self._single_round_controller_executor(reply)
|
106 |
|
107 |
+
if reply.get("EARLY_EXIT",False):
|
108 |
+
return reply
|
109 |
|
110 |
self._on_reach_max_round()
|
111 |
return {
|
112 |
"EARLY_EXIT": False,
|
113 |
+
"answer": reply["executor_reply"]["observation"],
|
114 |
"status": "unfinished"
|
115 |
}
|