executeWorkflowDirect 直接执行工作流,简化参数传递
(c *gin.Context, workflowRequest *WorkflowRunRequest, agent *model.Agent, channel *model.Channel, modelName string)
| 221 | |
| 222 | // executeWorkflowDirect 直接执行工作流,简化参数传递 |
| 223 | func executeWorkflowDirect(c *gin.Context, workflowRequest *WorkflowRunRequest, agent *model.Agent, channel *model.Channel, modelName string) (*custom.WorkflowResponseData, error) { |
| 224 | // 根据渠道类型选择对应的工作流适配器 |
| 225 | if channel.Type == channeltype.Coze || channel.Type == model.ChannelApiTypeCozeStudio { |
| 226 | return executeCozeWorkflow(c, workflowRequest, agent, channel, modelName) |
| 227 | } |
| 228 | |
| 229 | if channel.Type == model.ChannelApiDify { |
| 230 | return executeDifyWorkflowByMode(c, workflowRequest, agent, channel, modelName) |
| 231 | } |
| 232 | |
| 233 | if channel.Type == channeltype.FastGPT || channel.Type == model.ChannelApiTypeFastGpt { |
| 234 | // 这个 fastgpt 是因为 适配器的默认给 0 了,所以这里要手动设置一下,实际上数据库里面不会存 1007 |
| 235 | return executeFastGPTWorkflow(c, workflowRequest, agent, channel, modelName) |
| 236 | } |
| 237 | |
| 238 | if channel.Type == model.ChannelApi53AI { |
| 239 | return executeAI53Workflow(c, workflowRequest, agent, channel, modelName) |
| 240 | } |
| 241 | |
| 242 | if channel.Type == model.ChannelApiTypeN8n { |
| 243 | return executeN8nWorkflow(c, workflowRequest, agent, channel, modelName) |
| 244 | } |
| 245 | |
| 246 | return nil, fmt.Errorf("不支持的渠道类型: %d", channel.Type) |
| 247 | } |
| 248 | |
| 249 | // handleWorkflowError 处理工作流HTTP错误响应 |
| 250 | func handleWorkflowError(resp *http.Response, workflowType string) error { |
no test coverage detected