diff --git a/packages/service/core/workflow/dispatch/index.ts b/packages/service/core/workflow/dispatch/index.ts index a108cadb8..cba7e68fe 100644 --- a/packages/service/core/workflow/dispatch/index.ts +++ b/packages/service/core/workflow/dispatch/index.ts @@ -37,7 +37,7 @@ import { dispatchQueryExtension } from './tools/queryExternsion'; import { dispatchRunPlugin } from './plugin/run'; import { dispatchPluginInput } from './plugin/runInput'; import { dispatchPluginOutput } from './plugin/runOutput'; -import { removeSystemVariable, valueTypeFormat } from './utils'; +import { formatHttpError, removeSystemVariable, valueTypeFormat } from './utils'; import { filterWorkflowEdges, checkNodeRunStatus, @@ -72,6 +72,7 @@ import { dispatchLoopEnd } from './loop/runLoopEnd'; import { dispatchLoopStart } from './loop/runLoopStart'; import { dispatchFormInput } from './interactive/formInput'; import { dispatchToolParams } from './agent/runTool/toolParams'; +import { responseWrite } from '../../../common/response'; const callbackMap: Record = { [FlowNodeTypeEnum.workflowStart]: dispatchWorkflowStart, @@ -548,7 +549,21 @@ export async function dispatchWorkFlow(data: Props): Promise = await (async () => { if (callbackMap[node.flowNodeType]) { - return callbackMap[node.flowNodeType](dispatchData); + try { + return await callbackMap[node.flowNodeType](dispatchData); + } catch (error) { + // Get source handles of outgoing edges + const targetEdges = runtimeEdges.filter((item) => item.source === node.nodeId); + const skipHandleIds = targetEdges.map((item) => item.sourceHandle); + + // Skip all edges and return error + return { + [DispatchNodeResponseKeyEnum.nodeResponse]: { + error: formatHttpError(error) + }, + [DispatchNodeResponseKeyEnum.skipHandleId]: skipHandleIds + }; + } } return {}; })(); diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx index 78855b298..f54a42531 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx @@ -525,6 +525,12 @@ const ChatBox = ( generatingMessage: (e) => generatingMessage({ ...e, autoTTSResponse }), variables: requestVariables }); + if (responseData?.[responseData.length - 1]?.error) { + toast({ + title: responseData[responseData.length - 1].error?.message, + status: 'error' + }); + } isNewChatReplace.current = isNewChat; diff --git a/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/context.tsx b/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/context.tsx index 10c501095..934347c47 100644 --- a/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/context.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/context.tsx @@ -235,6 +235,12 @@ const PluginRunContextProvider = ({ ...variables } }); + if (responseData?.[responseData.length - 1]?.error) { + toast({ + title: responseData[responseData.length - 1].error?.message, + status: 'error' + }); + } setHistories((state) => state.map((item, index) => {