MCPcopy Create free account
hub / github.com/astercloud/aster / executeWorkflow

Method executeWorkflow

pkg/workflow/workflow_agent.go:87–114  ·  view source on GitHub ↗

executeWorkflow 执行 workflow(非流式)

(ctx context.Context, input *WorkflowInput)

Source from the content-addressed store, hash-verified

85
86// executeWorkflow 执行 workflow(非流式)
87func (wa *WorkflowAgent) executeWorkflow(ctx context.Context, input *WorkflowInput) (any, error) {
88 var finalOutput any
89 var finalError error
90
91 reader := wa.workflow.Execute(ctx, input)
92 for {
93 event, err := reader.Recv()
94 if err != nil {
95 if errors.Is(err, io.EOF) {
96 break
97 }
98 finalError = err
99 continue
100 }
101
102 if event.Type == EventWorkflowCompleted {
103 if data, ok := event.Data.(map[string]any); ok {
104 finalOutput = data["output"]
105 }
106 }
107 }
108
109 if finalError != nil {
110 return nil, finalError
111 }
112
113 return wa.formatOutput(finalOutput), nil
114}
115
116// executeStreamingWorkflow 执行 workflow(流式)
117func (wa *WorkflowAgent) executeStreamingWorkflow(ctx context.Context, input *WorkflowInput) (any, error) {

Callers 2

CreateWorkflowToolMethod · 0.95
RunMethod · 0.95

Calls 3

formatOutputMethod · 0.95
RecvMethod · 0.80
ExecuteMethod · 0.65

Tested by

no test coverage detected