prepareInputMessage 准备输入消息
(execution *WorkflowExecution, node *NodeDef)
| 784 | |
| 785 | // prepareInputMessage 准备输入消息 |
| 786 | func (e *Engine) prepareInputMessage(execution *WorkflowExecution, node *NodeDef) (string, error) { |
| 787 | if node.Agent != nil && node.Agent.Inputs != nil { |
| 788 | // 使用输入映射构建消息 |
| 789 | var parts []string |
| 790 | for key, varPath := range node.Agent.Inputs { |
| 791 | if value, exists := execution.Context.Variables[varPath]; exists { |
| 792 | parts = append(parts, fmt.Sprintf("%s: %v", key, value)) |
| 793 | } |
| 794 | } |
| 795 | return strings.Join(parts, "\n"), nil |
| 796 | } |
| 797 | |
| 798 | // 使用工作流输入作为消息 |
| 799 | if len(execution.Context.Inputs) > 0 { |
| 800 | data, _ := json.Marshal(execution.Context.Inputs) |
| 801 | return string(data), nil |
| 802 | } |
| 803 | |
| 804 | return "", nil |
| 805 | } |
| 806 | |
| 807 | // processAgentEvent 处理Agent事件 |
| 808 | func (e *Engine) processAgentEvent(event *session.Event, outputs map[string]any) map[string]any { |