changed naming of messaging methods
Browse files- ChatWithDemonstrationsFlow.py +23 -8
- DemonstrationsAtomicFlow.py +2 -2
- run.py +2 -2
ChatWithDemonstrationsFlow.py
CHANGED
@@ -56,26 +56,41 @@ class ChatWithDemonstrationsFlow(CompositeFlow):
|
|
56 |
def run(self,input_message):
|
57 |
|
58 |
# #~~~~~~~~~~~Solution 1 - Blocking ~~~~~~~
|
59 |
-
# future = self.subflows["demonstration_flow"].
|
60 |
|
61 |
-
# answer = self.subflows["chat_flow"].
|
62 |
-
|
|
|
|
|
|
|
63 |
|
64 |
# #~~~~~~~~~~~Solution 2 - Non-Blocking ~~~~~~~
|
65 |
if self.flow_state["last_flow_called"] is None:
|
66 |
self.flow_state["input_message"] = input_message
|
67 |
-
self.subflows["demonstration_flow"].
|
|
|
|
|
|
|
68 |
self.flow_state["last_flow_called"] = "demonstration_flow"
|
69 |
|
70 |
elif self.flow_state["last_flow_called"] == "demonstration_flow":
|
71 |
-
self.subflows["chat_flow"].
|
|
|
|
|
|
|
72 |
self.flow_state["last_flow_called"] = "chat_flow"
|
73 |
|
74 |
else:
|
75 |
self.flow_state["last_flow_called"] = None
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
)
|
80 |
|
81 |
|
|
|
56 |
def run(self,input_message):
|
57 |
|
58 |
# #~~~~~~~~~~~Solution 1 - Blocking ~~~~~~~
|
59 |
+
# future = self.subflows["demonstration_flow"].get_reply_future(input_message)
|
60 |
|
61 |
+
# answer = self.subflows["chat_flow"].get_reply_future(future.get_message())
|
62 |
+
|
63 |
+
#reply = self.package_output_message(input_message, self.output_interface(answer.get_data()))
|
64 |
+
|
65 |
+
# self.send_message(reply, is_reply=True)
|
66 |
|
67 |
# #~~~~~~~~~~~Solution 2 - Non-Blocking ~~~~~~~
|
68 |
if self.flow_state["last_flow_called"] is None:
|
69 |
self.flow_state["input_message"] = input_message
|
70 |
+
self.subflows["demonstration_flow"].get_reply(
|
71 |
+
input_message,
|
72 |
+
self.get_instance_id(),
|
73 |
+
)
|
74 |
self.flow_state["last_flow_called"] = "demonstration_flow"
|
75 |
|
76 |
elif self.flow_state["last_flow_called"] == "demonstration_flow":
|
77 |
+
self.subflows["chat_flow"].get_reply(
|
78 |
+
input_message,
|
79 |
+
self.get_instance_id(),
|
80 |
+
)
|
81 |
self.flow_state["last_flow_called"] = "chat_flow"
|
82 |
|
83 |
else:
|
84 |
self.flow_state["last_flow_called"] = None
|
85 |
+
|
86 |
+
reply = self.package_output_message(
|
87 |
+
self.flow_state["input_message"],
|
88 |
+
response = self.output_interface(input_message).data
|
89 |
+
)
|
90 |
+
|
91 |
+
self.send_message(
|
92 |
+
reply,
|
93 |
+
is_reply = True
|
94 |
)
|
95 |
|
96 |
|
DemonstrationsAtomicFlow.py
CHANGED
@@ -191,8 +191,8 @@ class DemonstrationsAtomicFlow(AtomicFlow):
|
|
191 |
:rtype: Dict[str, Any]
|
192 |
"""
|
193 |
input_data = input_message.data
|
194 |
-
reply = self.
|
195 |
input_message=input_message,
|
196 |
response = {**{"demonstrations": self._get_io_pairs(input_data=input_data)},**input_data}
|
197 |
)
|
198 |
-
self.
|
|
|
191 |
:rtype: Dict[str, Any]
|
192 |
"""
|
193 |
input_data = input_message.data
|
194 |
+
reply = self.package_output_message(
|
195 |
input_message=input_message,
|
196 |
response = {**{"demonstrations": self._get_io_pairs(input_data=input_data)},**input_data}
|
197 |
)
|
198 |
+
self.send_message(reply, is_reply = True)
|
run.py
CHANGED
@@ -98,10 +98,10 @@ if __name__ == "__main__":
|
|
98 |
)
|
99 |
|
100 |
#option2: use the proxy_flow
|
101 |
-
#input_message = proxy_flow.
|
102 |
|
103 |
#7. ~~~ Run inference ~~~
|
104 |
-
future = proxy_flow.
|
105 |
|
106 |
#uncomment this line if you would like to get the full message back
|
107 |
#reply_message = future.get_message()
|
|
|
98 |
)
|
99 |
|
100 |
#option2: use the proxy_flow
|
101 |
+
#input_message = proxy_flow.package_input_message(data = data)
|
102 |
|
103 |
#7. ~~~ Run inference ~~~
|
104 |
+
future = proxy_flow.get_reply_future(input_message)
|
105 |
|
106 |
#uncomment this line if you would like to get the full message back
|
107 |
#reply_message = future.get_message()
|