bug fix
Browse files- ChatWithDemonstrationsFlow.py +17 -5
- ChatWithDemonstrationsFlow.yaml +1 -3
- demo.yaml +0 -6
- run.py +1 -6
ChatWithDemonstrationsFlow.py
CHANGED
@@ -71,23 +71,35 @@ class ChatWithDemonstrationsFlow(CompositeFlow):
|
|
71 |
|
72 |
# #~~~~~~~~~~~Solution 2 - Non-Blocking ~~~~~~~
|
73 |
if self.flow_state["last_state"] is None:
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
self.subflows["demonstration_flow"].get_reply(
|
76 |
-
|
77 |
)
|
78 |
self.flow_state["last_state"] = "demonstration_flow"
|
79 |
|
80 |
elif self.flow_state["last_state"] == "demonstration_flow":
|
|
|
|
|
|
|
|
|
|
|
81 |
self.subflows["chat_flow"].get_reply(
|
82 |
-
|
83 |
)
|
|
|
84 |
self.flow_state["last_state"] = "chat_flow"
|
85 |
|
86 |
else:
|
87 |
self.flow_state["last_state"] = None
|
88 |
-
|
89 |
reply = self.package_output_message(
|
90 |
-
self.flow_state["
|
91 |
response = self.output_interface(input_message).data
|
92 |
)
|
93 |
|
|
|
71 |
|
72 |
# #~~~~~~~~~~~Solution 2 - Non-Blocking ~~~~~~~
|
73 |
if self.flow_state["last_state"] is None:
|
74 |
+
|
75 |
+
self.flow_state["initial_message"] = input_message
|
76 |
+
|
77 |
+
msg = self.package_input_message(
|
78 |
+
input_message.data
|
79 |
+
)
|
80 |
+
|
81 |
self.subflows["demonstration_flow"].get_reply(
|
82 |
+
msg,
|
83 |
)
|
84 |
self.flow_state["last_state"] = "demonstration_flow"
|
85 |
|
86 |
elif self.flow_state["last_state"] == "demonstration_flow":
|
87 |
+
|
88 |
+
msg = self.package_input_message(
|
89 |
+
input_message.data
|
90 |
+
)
|
91 |
+
|
92 |
self.subflows["chat_flow"].get_reply(
|
93 |
+
msg,
|
94 |
)
|
95 |
+
|
96 |
self.flow_state["last_state"] = "chat_flow"
|
97 |
|
98 |
else:
|
99 |
self.flow_state["last_state"] = None
|
100 |
+
|
101 |
reply = self.package_output_message(
|
102 |
+
self.flow_state["initial_message"],
|
103 |
response = self.output_interface(input_message).data
|
104 |
)
|
105 |
|
ChatWithDemonstrationsFlow.yaml
CHANGED
@@ -1,17 +1,15 @@
|
|
1 |
|
2 |
name: "ChatAtomic_Flow_with_Demonstrations"
|
3 |
description: "A sequential flow that answers questions with demonstrations"
|
4 |
-
|
5 |
subflows_config:
|
6 |
demonstration_flow:
|
7 |
-
_target_: flow_modules.aiflows.ChatWithDemonstrationsFlowModule.DemonstrationsAtomicFlow.instantiate_from_default_config
|
8 |
flow_class_name: flow_modules.aiflows.ChatWithDemonstrationsFlowModule.DemonstrationsAtomicFlow
|
9 |
flow_endpoint: DemonstrationsAtomicFlow
|
10 |
user_id: local
|
11 |
name: "DemonstrationsAtomicFlow"
|
12 |
description: "A flow that answers questions with demonstrations"
|
13 |
chat_flow:
|
14 |
-
_target_: flow_modules.aiflows.ChatFlowModule.ChatAtomicFlow.instantiate_from_default_config
|
15 |
name: "ChatAtomicFlow"
|
16 |
description: "A flow that answers questions"
|
17 |
flow_class_name: flow_modules.aiflows.ChatFlowModule.ChatAtomicFlow
|
|
|
1 |
|
2 |
name: "ChatAtomic_Flow_with_Demonstrations"
|
3 |
description: "A sequential flow that answers questions with demonstrations"
|
4 |
+
_target_: flow_modules.aiflows.ChatWithDemonstrationsFlowModule.ChatWithDemonstrationsFlow.instantiate_from_default_config
|
5 |
subflows_config:
|
6 |
demonstration_flow:
|
|
|
7 |
flow_class_name: flow_modules.aiflows.ChatWithDemonstrationsFlowModule.DemonstrationsAtomicFlow
|
8 |
flow_endpoint: DemonstrationsAtomicFlow
|
9 |
user_id: local
|
10 |
name: "DemonstrationsAtomicFlow"
|
11 |
description: "A flow that answers questions with demonstrations"
|
12 |
chat_flow:
|
|
|
13 |
name: "ChatAtomicFlow"
|
14 |
description: "A flow that answers questions"
|
15 |
flow_class_name: flow_modules.aiflows.ChatFlowModule.ChatAtomicFlow
|
demo.yaml
CHANGED
@@ -9,10 +9,7 @@ output_interface: # Connector between the Flow's output and the caller
|
|
9 |
|
10 |
subflows_config:
|
11 |
demonstration_flow:
|
12 |
-
_target_: flow_modules.aiflows.ChatWithDemonstrationsFlowModule.DemonstrationsAtomicFlow.instantiate_from_default_config
|
13 |
name: "proxy of DemonstrationsAtomicFlow"
|
14 |
-
flow_endpoint: DemonstrationsAtomicFlow
|
15 |
-
user_id: local
|
16 |
description: "A flow that answers questions with demonstrations"
|
17 |
data:
|
18 |
- query_data:
|
@@ -35,11 +32,8 @@ subflows_config:
|
|
35 |
- response
|
36 |
|
37 |
chat_flow:
|
38 |
-
_target_: flow_modules.aiflows.ChatFlowModule.ChatAtomicFlow.instantiate_from_default_config
|
39 |
name: "proxy SimpleQA_Flow"
|
40 |
description: "A flow that answers questions"
|
41 |
-
flow_endpoint: ChatAtomicFlow
|
42 |
-
user_id: local
|
43 |
# ~~~ Input interface specification ~~~
|
44 |
input_interface_non_initialized:
|
45 |
- "question"
|
|
|
9 |
|
10 |
subflows_config:
|
11 |
demonstration_flow:
|
|
|
12 |
name: "proxy of DemonstrationsAtomicFlow"
|
|
|
|
|
13 |
description: "A flow that answers questions with demonstrations"
|
14 |
data:
|
15 |
- query_data:
|
|
|
32 |
- response
|
33 |
|
34 |
chat_flow:
|
|
|
35 |
name: "proxy SimpleQA_Flow"
|
36 |
description: "A flow that answers questions"
|
|
|
|
|
37 |
# ~~~ Input interface specification ~~~
|
38 |
input_interface_non_initialized:
|
39 |
- "question"
|
run.py
CHANGED
@@ -79,13 +79,8 @@ if __name__ == "__main__":
|
|
79 |
data = {"id": 0, "question": "What is the capital of France?"} # This can be a list of samples
|
80 |
# data = {"id": 0, "question": "Who was the NBA champion in 2023?"} # This can be a list of samples
|
81 |
|
82 |
-
#option1: use the FlowMessage class
|
83 |
-
input_message = FlowMessage(
|
84 |
-
data=data,
|
85 |
-
)
|
86 |
|
87 |
-
|
88 |
-
#input_message = proxy_flow.package_input_message(data = data)
|
89 |
|
90 |
#7. ~~~ Run inference ~~~
|
91 |
future = proxy_flow.get_reply_future(input_message)
|
|
|
79 |
data = {"id": 0, "question": "What is the capital of France?"} # This can be a list of samples
|
80 |
# data = {"id": 0, "question": "Who was the NBA champion in 2023?"} # This can be a list of samples
|
81 |
|
|
|
|
|
|
|
|
|
82 |
|
83 |
+
input_message = proxy_flow.package_input_message(data = data)
|
|
|
84 |
|
85 |
#7. ~~~ Run inference ~~~
|
86 |
future = proxy_flow.get_reply_future(input_message)
|