Skip to content

Commit

Permalink
fix: workflow edge check
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Aug 29, 2024
1 parent b8fdf9f commit aad7d89
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,15 @@ export const runToolWithFunctionCall = async (
// console.log(tokens, 'tool');

// Run tool status
workflowStreamResponse?.({
event: SseResponseEventEnum.flowNodeStatus,
data: {
status: 'running',
name: node.name
}
});
if (node.showStatus) {
workflowStreamResponse?.({
event: SseResponseEventEnum.flowNodeStatus,
data: {
status: 'running',
name: node.name
}
});
}

// tool assistant
const toolAssistants = toolsRunResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,15 @@ export const runToolWithPromptCall = async (
})();

// Run tool status
workflowStreamResponse?.({
event: SseResponseEventEnum.flowNodeStatus,
data: {
status: 'running',
name: node.name
}
});
if (node.showStatus) {
workflowStreamResponse?.({
event: SseResponseEventEnum.flowNodeStatus,
data: {
status: 'running',
name: node.name
}
});
}

// 合并工具调用的结果,使用 functionCall 格式存储。
const assistantToolMsgParams: ChatCompletionAssistantMessageParam = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,15 @@ export const runToolWithToolChoice = async (
// console.log(tokens, 'tool');

// Run tool status
workflowStreamResponse?.({
event: SseResponseEventEnum.flowNodeStatus,
data: {
status: 'running',
name: node.name
}
});
if (node.showStatus) {
workflowStreamResponse?.({
event: SseResponseEventEnum.flowNodeStatus,
data: {
status: 'running',
name: node.name
}
});
}

// tool assistant
const toolAssistants = toolsRunResponse
Expand Down
6 changes: 5 additions & 1 deletion packages/service/core/workflow/dispatch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,11 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons

const flat = result.flat().filter(Boolean) as unknown as {
node: RuntimeNodeItemType;
runStatus: 'run' | 'skip';
result: Record<string, any>;
}[];
if (flat.length === 0) return;
// If there are no running nodes, the workflow is complete
if (!flat.some((item) => item.runStatus === 'run')) return;

// Update the node output at the end of the run and get the next nodes
const nextNodes = flat.map((item) => nodeOutput(item.node, item.result)).flat();
Expand Down Expand Up @@ -454,6 +456,7 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons

return {
node,
runStatus: 'run',
result: {
...dispatchRes,
[DispatchNodeResponseKeyEnum.nodeResponse]: formatResponseData
Expand All @@ -467,6 +470,7 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons

return {
node,
runStatus: 'skip',
result: {
[DispatchNodeResponseKeyEnum.skipHandleId]: targetEdges.map((item) => item.sourceHandle)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ const NodeDebugResponse = React.memo(function NodeDebugResponse({
</Box>
)}
</Flex>
{/* result */}
{/* Result card */}
{debugResult.showResult && (
<Card
className="nowheel"
Expand All @@ -587,12 +587,11 @@ const NodeDebugResponse = React.memo(function NodeDebugResponse({
top={0}
zIndex={10}
w={'420px'}
minH={'300px'}
maxH={'100%'}
maxH={'max(100%,500px)'}
border={'base'}
>
{/* Status header */}
<Flex h={'54x'} px={4} mb={1} py={3} alignItems={'center'} borderBottom={'base'}>
<Flex h={'54x'} px={4} py={3} alignItems={'center'}>
<MyIcon mr={1} name={'core/workflow/debugResult'} w={'20px'} color={'primary.600'} />
<Box fontWeight={'bold'} flex={'1'}>
{t('common:core.workflow.debug.Run result')}
Expand Down Expand Up @@ -627,18 +626,20 @@ const NodeDebugResponse = React.memo(function NodeDebugResponse({
</Button>
)}
</Flex>
{/* Show result */}
<Box overflowY={'auto'}>
{!debugResult.message && !response && (
<EmptyTip text={t('common:core.workflow.debug.Not result')} pt={2} pb={5} />
)}
{debugResult.message && (
<Box color={'red.600'} px={3} py={4}>
{debugResult.message}
</Box>
)}
{response && <WholeResponseContent activeModule={response} showDetail />}
</Box>
{/* Response list */}
{debugResult.status !== 'skipped' && (
<Box borderTop={'base'} mt={1} overflowY={'auto'} minH={'250px'}>
{!debugResult.message && !response && (
<EmptyTip text={t('common:core.workflow.debug.Not result')} pt={2} pb={5} />
)}
{debugResult.message && (
<Box color={'red.600'} px={3} py={4}>
{debugResult.message}
</Box>
)}
{response && <WholeResponseContent activeModule={response} showDetail />}
</Box>
)}
</Card>
)}
<ConfirmModal />
Expand Down

0 comments on commit aad7d89

Please sign in to comment.