CreateWorkflowTool 创建 workflow 执行工具
( session *WorkflowSession, executionInput *WorkflowInput, stream bool, )
| 55 | |
| 56 | // CreateWorkflowTool 创建 workflow 执行工具 |
| 57 | func (wa *WorkflowAgent) CreateWorkflowTool( |
| 58 | session *WorkflowSession, |
| 59 | executionInput *WorkflowInput, |
| 60 | stream bool, |
| 61 | ) WorkflowToolFunc { |
| 62 | return func(ctx context.Context, query string) (any, error) { |
| 63 | if wa.workflow == nil { |
| 64 | return nil, errors.New("no workflow attached to agent") |
| 65 | } |
| 66 | |
| 67 | workflowInput := &WorkflowInput{ |
| 68 | Input: query, |
| 69 | AdditionalData: executionInput.AdditionalData, |
| 70 | Images: executionInput.Images, |
| 71 | Videos: executionInput.Videos, |
| 72 | Audio: executionInput.Audio, |
| 73 | Files: executionInput.Files, |
| 74 | SessionID: session.ID, |
| 75 | SessionState: session.State, |
| 76 | } |
| 77 | |
| 78 | if stream { |
| 79 | return wa.executeStreamingWorkflow(ctx, workflowInput) |
| 80 | } |
| 81 | |
| 82 | return wa.executeWorkflow(ctx, workflowInput) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // executeWorkflow 执行 workflow(非流式) |
| 87 | func (wa *WorkflowAgent) executeWorkflow(ctx context.Context, input *WorkflowInput) (any, error) { |
nothing calls this directly
no test coverage detected