fix(workflow): issues in workflow parallels

This commit is contained in:
takatost
2024-08-16 22:47:58 +08:00
parent 352c45c8a2
commit 5d7865737f
3 changed files with 26 additions and 22 deletions

View File

@ -320,14 +320,18 @@ class GraphEngine:
break
yield event
if isinstance(event, ParallelBranchRunSucceededEvent):
succeeded_count += 1
if succeeded_count == len(threads):
q.put(None)
if isinstance(event, NodeRunSucceededEvent) and event.node_data.title == 'LLM 4':
print("LLM 4 succeeded")
continue
elif isinstance(event, ParallelBranchRunFailedEvent):
raise GraphRunFailedError(event.error)
if event.parallel_id == parallel_id:
if isinstance(event, ParallelBranchRunSucceededEvent):
succeeded_count += 1
if succeeded_count == len(threads):
q.put(None)
continue
elif isinstance(event, ParallelBranchRunFailedEvent):
raise GraphRunFailedError(event.error)
except queue.Empty:
continue

View File

@ -40,7 +40,7 @@ class AnswerStreamProcessor(StreamProcessor):
if event.in_iteration_id:
yield event
continue
if event.route_node_state.node_id in self.current_stream_chunk_generating_node_ids:
stream_out_answer_node_ids = self.current_stream_chunk_generating_node_ids[
event.route_node_state.node_id
@ -55,6 +55,8 @@ class AnswerStreamProcessor(StreamProcessor):
yield event
elif isinstance(event, NodeRunSucceededEvent):
yield event
if event.node_data.title == 'LLM 4':
print("LLM 4 succeeded1")
if event.route_node_state.node_id in self.current_stream_chunk_generating_node_ids:
# update self.route_position after all stream event finished
for answer_node_id in self.current_stream_chunk_generating_node_ids[event.route_node_state.node_id]: