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

Method executeStreamingWorkflow

pkg/workflow/workflow_agent.go:117–138  ·  view source on GitHub ↗

executeStreamingWorkflow 执行 workflow(流式)

(ctx context.Context, input *WorkflowInput)

Source from the content-addressed store, hash-verified

115
116// executeStreamingWorkflow 执行 workflow(流式)
117func (wa *WorkflowAgent) executeStreamingWorkflow(ctx context.Context, input *WorkflowInput) (any, error) {
118 resultChan := make(chan any, 100)
119
120 go func() {
121 defer close(resultChan)
122
123 reader := wa.workflow.Execute(ctx, input)
124 for {
125 event, err := reader.Recv()
126 if err != nil {
127 if errors.Is(err, io.EOF) {
128 break
129 }
130 resultChan <- map[string]any{"error": err.Error()}
131 continue
132 }
133 resultChan <- event
134 }
135 }()
136
137 return resultChan, nil
138}
139
140// formatOutput 格式化输出为字符串
141func (wa *WorkflowAgent) formatOutput(output any) string {

Callers 1

CreateWorkflowToolMethod · 0.95

Calls 3

RecvMethod · 0.80
ExecuteMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected