Skip to content

Commit

Permalink
feat: 工作流编排支持并行 #1154
Browse files Browse the repository at this point in the history
  • Loading branch information
shaohuzhang1 committed Oct 12, 2024
1 parent 2c3fecf commit 26dafe9
Show file tree
Hide file tree
Showing 6 changed files with 264 additions and 112 deletions.
3 changes: 2 additions & 1 deletion apps/application/flow/i_step_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def write_context(step_variable: Dict, global_variable: Dict, node, workflow):
if step_variable is not None:
for key in step_variable:
node.context[key] = step_variable[key]
if workflow.is_result() and 'answer' in step_variable:
if workflow.is_result(node, NodeResult(step_variable, global_variable)) and 'answer' in step_variable:
answer = step_variable['answer']
yield answer
workflow.answer += answer
Expand Down Expand Up @@ -166,6 +166,7 @@ def get_flow_params_serializer_class(self) -> Type[serializers.Serializer]:
def get_write_error_context(self, e):
self.status = 500
self.err_message = str(e)
self.context['run_time'] = time.time() - self.context['start_time']

def write_error_context(answer, status=200):
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _write_context(node_variable: Dict, workflow_variable: Dict, node: INode, wo
node.context['history_message'] = node_variable['history_message']
node.context['question'] = node_variable['question']
node.context['run_time'] = time.time() - node.context['start_time']
if workflow.is_result():
if workflow.is_result(node, NodeResult(node_variable, workflow_variable)):
workflow.answer += answer


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def write_context(step_variable: Dict, global_variable: Dict, node, workflow):
if step_variable is not None:
for key in step_variable:
node.context[key] = step_variable[key]
if workflow.is_result() and 'result' in step_variable:
if workflow.is_result(node, NodeResult(step_variable, global_variable)) and 'result' in step_variable:
result = str(step_variable['result']) + '\n'
yield result
workflow.answer += result
Expand Down
Loading

0 comments on commit 26dafe9

Please sign in to comment.