= ({
showSteps,
exceptionCounts,
execution_metadata,
- retry_events,
+ handleShowIterationResultList,
onShowRetryDetail,
+ onShowAgentResultList,
}) => {
const { t } = useTranslation()
+ const isIterationNode = nodeInfo?.node_type === BlockEnum.Iteration
+ const isRetryNode = hasRetryNode(nodeInfo?.node_type) && nodeInfo?.retryDetail
+ const isAgentNode = nodeInfo?.node_type === BlockEnum.Agent
return (
@@ -62,23 +69,32 @@ const ResultPanel: FC = ({
exceptionCounts={exceptionCounts}
/>
- {
- retry_events?.length && onShowRetryDetail && (
-
-
-
- )
- }
+
+ {
+ isIterationNode && handleShowIterationResultList && (
+
+ )
+ }
+ {
+ isRetryNode && onShowRetryDetail && (
+
+ )
+ }
+ {
+ isAgentNode && onShowAgentResultList && (
+
+ )
+ }
+
void
- retryResultList: NodeTracing[]
+export type SpecialResultPanelProps = {
+ showRetryDetail?: boolean
+ setShowRetryDetailFalse?: () => void
+ retryResultList?: NodeTracing[]
- showIteratingDetail: boolean
- setShowIteratingDetailFalse: () => void
- iterationResultList: NodeTracing[][]
- iterationResultDurationMap: IterationDurationMap
+ showIteratingDetail?: boolean
+ setShowIteratingDetailFalse?: () => void
+ iterationResultList?: NodeTracing[][]
+ iterationResultDurationMap?: IterationDurationMap
- agentResultList: AgentLogItemWithChildren[]
- setAgentResultList: (list: AgentLogItemWithChildren[]) => void
+ agentResultList?: AgentLogItemWithChildren[]
+ setAgentResultList?: (list: AgentLogItemWithChildren[]) => void
}
const SpecialResultPanel = ({
showRetryDetail,
@@ -36,7 +36,7 @@ const SpecialResultPanel = ({
return (
<>
{
- showRetryDetail && (
+ !!showRetryDetail && !!retryResultList?.length && setShowRetryDetailFalse && (
= ({
onShowIterationDetail={handleShowIterationResultList}
onShowRetryDetail={handleShowRetryResultList}
onShowAgentResultList={setAgentResultList}
- justShowIterationNavArrow={true}
- justShowRetryNavArrow={true}
hideInfo={hideNodeInfo}
hideProcessDetail={hideNodeProcessDetail}
/>
diff --git a/web/app/components/workflow/run/utils/format-log/agent/index.ts b/web/app/components/workflow/run/utils/format-log/agent/index.ts
index 7bbe0aa57f..255dc16c5c 100644
--- a/web/app/components/workflow/run/utils/format-log/agent/index.ts
+++ b/web/app/components/workflow/run/utils/format-log/agent/index.ts
@@ -1,6 +1,8 @@
import { BlockEnum } from '@/app/components/workflow/types'
import type { AgentLogItem, AgentLogItemWithChildren, NodeTracing } from '@/types/workflow'
+const supportedAgentLogNodes = [BlockEnum.Agent, BlockEnum.Tool]
+
const listToTree = (logs: AgentLogItem[]) => {
if (!logs || logs.length === 0)
return []
@@ -24,7 +26,7 @@ const listToTree = (logs: AgentLogItem[]) => {
}
const format = (list: NodeTracing[]): NodeTracing[] => {
const result: NodeTracing[] = list.map((item) => {
- if (item.node_type === BlockEnum.Agent && item.execution_metadata?.agent_log && item.execution_metadata?.agent_log.length > 0)
+ if (supportedAgentLogNodes.includes(item.node_type) && item.execution_metadata?.agent_log && item.execution_metadata?.agent_log.length > 0)
item.agentLog = listToTree(item.execution_metadata.agent_log)
return item
diff --git a/web/app/components/workflow/run/utils/format-log/parallel/index.ts b/web/app/components/workflow/run/utils/format-log/parallel/index.ts
index a341362e10..9501eec7ec 100644
--- a/web/app/components/workflow/run/utils/format-log/parallel/index.ts
+++ b/web/app/components/workflow/run/utils/format-log/parallel/index.ts
@@ -1,22 +1,25 @@
import { BlockEnum } from '@/app/components/workflow/types'
import type { NodeTracing } from '@/types/workflow'
-function printNodeStructure(node: NodeTracing, level: number) {
- const indent = ' '.repeat(level)
+function printNodeStructure(node: NodeTracing, depth: number) {
+ const indent = ' '.repeat(depth)
console.log(`${indent}${node.title}`)
if (node.parallelDetail?.children) {
node.parallelDetail.children.forEach((child) => {
- printNodeStructure(child, level + 1)
+ printNodeStructure(child, depth + 1)
})
}
}
function addTitle({
- list, level, parallelNumRecord,
+ list, depth, belongParallelIndexInfo,
}: {
- list: NodeTracing[], level: number, parallelNumRecord: Record
+ list: NodeTracing[],
+ depth: number,
+ belongParallelIndexInfo?: string,
}, t: any) {
let branchIndex = 0
+ const hasMoreThanOneParallel = list.filter(node => node.parallelDetail?.isParallelStartNode).length > 1
list.forEach((node) => {
const parallel_id = node.parallel_id ?? node.execution_metadata?.parallel_id ?? null
const parallel_start_node_id = node.parallel_start_node_id ?? node.execution_metadata?.parallel_start_node_id ?? null
@@ -26,15 +29,20 @@ function addTitle({
return
const isParallelStartNode = node.parallelDetail?.isParallelStartNode
- if (isParallelStartNode)
- parallelNumRecord.num++
- const letter = parallelNumRecord.num > 1 ? String.fromCharCode(64 + level) : ''
- const parallelLevelInfo = `${parallelNumRecord.num}${letter}`
+ const parallelIndexLetter = (() => {
+ if (!isParallelStartNode || !hasMoreThanOneParallel)
+ return ''
+
+ const index = 1 + list.filter(node => node.parallelDetail?.isParallelStartNode).findIndex(item => item.node_id === node.node_id)
+ return String.fromCharCode(64 + index)
+ })()
+
+ const parallelIndexInfo = `${depth}${parallelIndexLetter}`
if (isParallelStartNode) {
node.parallelDetail!.isParallelStartNode = true
- node.parallelDetail!.parallelTitle = `${t('workflow.common.parallel')}-${parallelLevelInfo}`
+ node.parallelDetail!.parallelTitle = `${t('workflow.common.parallel')}-${parallelIndexInfo}`
}
const isBrachStartNode = parallel_start_node_id === node.node_id
@@ -47,14 +55,14 @@ function addTitle({
}
}
- node.parallelDetail!.branchTitle = `${t('workflow.common.branch')}-${parallelLevelInfo}-${branchLetter}`
+ node.parallelDetail!.branchTitle = `${t('workflow.common.branch')}-${belongParallelIndexInfo}-${branchLetter}`
}
if (node.parallelDetail?.children && node.parallelDetail.children.length > 0) {
addTitle({
list: node.parallelDetail.children,
- level: level + 1,
- parallelNumRecord,
+ depth: depth + 1,
+ belongParallelIndexInfo: parallelIndexInfo,
}, t)
}
})
@@ -70,7 +78,7 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => {
const parallel_id = node.parallel_id ?? node.execution_metadata?.parallel_id ?? null
const parent_parallel_id = node.parent_parallel_id ?? node.execution_metadata?.parent_parallel_id ?? null
const branchStartNodeId = node.parallel_start_node_id ?? node.execution_metadata?.parallel_start_node_id ?? null
- const parent_parallel_start_node_id = node.parent_parallel_start_node_id ?? node.execution_metadata?.parent_parallel_start_node_id ?? null
+ const parentParallelBranchStartNodeId = node.parent_parallel_start_node_id ?? node.execution_metadata?.parent_parallel_start_node_id ?? null
const isNotInParallel = !parallel_id || node.node_type === BlockEnum.End
if (isNotInParallel)
return
@@ -87,16 +95,24 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => {
if (isRootLevel)
return
- const parentParallelStartNode = result.find(item => item.node_id === parent_parallel_start_node_id)
- // append to parent parallel start node
+ const parentParallelStartNode = result.find(item => item.node_id === parentParallelBranchStartNodeId)
+ // append to parent parallel start node and after the same branch
if (parentParallelStartNode) {
if (!parentParallelStartNode?.parallelDetail) {
parentParallelStartNode!.parallelDetail = {
children: [],
}
}
- if (parentParallelStartNode!.parallelDetail.children)
- parentParallelStartNode!.parallelDetail.children.push(node)
+ if (parentParallelStartNode!.parallelDetail.children) {
+ const sameBranchNodesLastIndex = parentParallelStartNode.parallelDetail.children.findLastIndex((node) => {
+ const currStartNodeId = node.parallel_start_node_id ?? node.execution_metadata?.parallel_start_node_id ?? null
+ return currStartNodeId === parentParallelBranchStartNodeId
+ })
+ if (sameBranchNodesLastIndex !== -1)
+ parentParallelStartNode!.parallelDetail.children.splice(sameBranchNodesLastIndex + 1, 0, node)
+ else
+ parentParallelStartNode!.parallelDetail.children.push(node)
+ }
}
return
}
@@ -144,14 +160,9 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => {
// console.log(`----- p: ${now} end -----`)
// })
- const parallelNumRecord: Record = {
- num: 0,
- }
-
addTitle({
list: filteredInParallelSubNodes,
- level: 1,
- parallelNumRecord,
+ depth: 1,
}, t)
return filteredInParallelSubNodes
diff --git a/web/i18n/en-US/plugin.ts b/web/i18n/en-US/plugin.ts
index 38ec6d9be7..a706f8f042 100644
--- a/web/i18n/en-US/plugin.ts
+++ b/web/i18n/en-US/plugin.ts
@@ -73,6 +73,7 @@ const translation = {
placeholder: 'Select a tool...',
auth: 'AUTHORIZATION',
settings: 'TOOL SETTINGS',
+ empty: 'Click the \'+\' button to add tools. You can add multiple tools.',
},
configureApp: 'Configure App',
configureModel: 'Configure model',
diff --git a/web/i18n/zh-Hans/plugin.ts b/web/i18n/zh-Hans/plugin.ts
index 8185f37b40..4b7c764d9f 100644
--- a/web/i18n/zh-Hans/plugin.ts
+++ b/web/i18n/zh-Hans/plugin.ts
@@ -73,6 +73,7 @@ const translation = {
placeholder: '选择工具',
auth: '授权',
settings: '工具设置',
+ empty: '点击 "+" 按钮添加工具。您可以添加多个工具。',
},
configureApp: '应用设置',
configureModel: '模型设置',