From 8a90a9bd5dc65526bdd5f2af99d797508bf5a497 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 27 Dec 2024 18:28:41 +0800 Subject: [PATCH 1/6] fix: in steam mode trigger the error in change list --- .../workflow/run/utils/format-log/index.ts | 3 ++- .../run/utils/format-log/parallel/index.ts | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/web/app/components/workflow/run/utils/format-log/index.ts b/web/app/components/workflow/run/utils/format-log/index.ts index 6beae5eb2b..4e8f6c33c2 100644 --- a/web/app/components/workflow/run/utils/format-log/index.ts +++ b/web/app/components/workflow/run/utils/format-log/index.ts @@ -3,9 +3,10 @@ import formatIterationNode from './iteration' import formatParallelNode from './parallel' import formatRetryNode from './retry' import formatAgentNode from './agent' +import { cloneDeep } from 'lodash-es' const formatToTracingNodeList = (list: NodeTracing[], t: any) => { - const allItems = [...list].sort((a, b) => a.index - b.index) + const allItems = cloneDeep([...list]).sort((a, b) => a.index - b.index) /* * First handle not change list structure node * Because Handle struct node will put the node in different 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 9501eec7ec..245337dc0c 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 @@ -69,8 +69,10 @@ function addTitle({ } // list => group by parallel_id(parallel tree). -const format = (list: NodeTracing[], t: any): NodeTracing[] => { - // console.log(list) +const format = (list: NodeTracing[], t: any, isPrint?: boolean): NodeTracing[] => { + if (isPrint) + console.log(list) + const result: NodeTracing[] = [...list] const parallelFirstNodeMap: Record = {} // list to tree by parent_parallel_start_node_id and branch by parallel_start_node_id. Each parallel may has more than one branch. @@ -119,6 +121,7 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => { // append to parallel start node and after the same branch const parallelStartNode = result.find(item => item.node_id === parallelFirstNodeMap[parallel_id]) + if (parallelStartNode && parallelStartNode.parallelDetail && parallelStartNode!.parallelDetail!.children) { const sameBranchNodesLastIndex = parallelStartNode.parallelDetail.children.findLastIndex((node) => { const currStartNodeId = node.parallel_start_node_id ?? node.execution_metadata?.parallel_start_node_id ?? null @@ -153,12 +156,14 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => { }) // print node structure for debug - // filteredInParallelSubNodes.forEach((node) => { - // const now = Date.now() - // console.log(`----- p: ${now} start -----`) - // printNodeStructure(node, 0) - // console.log(`----- p: ${now} end -----`) - // }) + if (isPrint) { + filteredInParallelSubNodes.forEach((node) => { + const now = Date.now() + console.log(`----- p: ${now} start -----`) + printNodeStructure(node, 0) + console.log(`----- p: ${now} end -----`) + }) + } addTitle({ list: filteredInParallelSubNodes, From b5ad9a58f7432038d3a21717caf667862bdcf75f Mon Sep 17 00:00:00 2001 From: JzoNg Date: Mon, 30 Dec 2024 10:22:44 +0800 Subject: [PATCH 2/6] default value for multiple tool selector --- .../plugin-detail-panel/multiple-tool-selector/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/app/components/plugins/plugin-detail-panel/multiple-tool-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/multiple-tool-selector/index.tsx index 6adf26ee79..036aa098ea 100644 --- a/web/app/components/plugins/plugin-detail-panel/multiple-tool-selector/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/multiple-tool-selector/index.tsx @@ -25,7 +25,7 @@ type Props = { const MultipleToolSelector = ({ disabled, - value, + value = [], label, required, tooltip, From 84febd5e94f85ff53e1eabd6fe9de9f36120f47f Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Mon, 30 Dec 2024 10:23:03 +0800 Subject: [PATCH 3/6] fix: agent log structure --- .../workflow/run/agent-log/agent-log-item.tsx | 4 ++- .../run/agent-log/agent-log-trigger.tsx | 6 ++-- .../run/agent-log/agent-result-panel.tsx | 13 ++++++-- web/app/components/workflow/run/hooks.ts | 33 ++++++++++++++++--- web/app/components/workflow/run/node.tsx | 8 ++--- .../components/workflow/run/result-panel.tsx | 13 +++++--- .../workflow/run/special-result-panel.tsx | 17 ++++++---- .../components/workflow/run/tracing-panel.tsx | 12 ++++--- 8 files changed, 74 insertions(+), 32 deletions(-) diff --git a/web/app/components/workflow/run/agent-log/agent-log-item.tsx b/web/app/components/workflow/run/agent-log/agent-log-item.tsx index d9e7616e8c..26c734874d 100644 --- a/web/app/components/workflow/run/agent-log/agent-log-item.tsx +++ b/web/app/components/workflow/run/agent-log/agent-log-item.tsx @@ -12,9 +12,11 @@ import { CodeLanguage } from '@/app/components/workflow/nodes/code/types' type AgentLogItemProps = { item: AgentLogItemWithChildren + onShowAgentOrToolLog: (detail: AgentLogItemWithChildren) => void } const AgentLogItem = ({ item, + onShowAgentOrToolLog, }: AgentLogItemProps) => { const { label, @@ -51,7 +53,7 @@ const AgentLogItem = ({
/
/
diff --git a/web/app/components/workflow/run/agent-log/agent-log-trigger.tsx b/web/app/components/workflow/run/agent-log/agent-log-trigger.tsx index 150d1d713d..825f59f085 100644 --- a/web/app/components/workflow/run/agent-log/agent-log-trigger.tsx +++ b/web/app/components/workflow/run/agent-log/agent-log-trigger.tsx @@ -6,7 +6,7 @@ import type { type AgentLogTriggerProps = { nodeInfo: NodeTracing - onShowAgentOrToolLog: (detail: AgentLogItemWithChildren) => void + onShowAgentOrToolLog: (detail?: AgentLogItemWithChildren) => void } const AgentLogTrigger = ({ nodeInfo, diff --git a/web/app/components/workflow/run/agent-log/agent-result-panel.tsx b/web/app/components/workflow/run/agent-log/agent-result-panel.tsx index 8055ec3486..fe40d751d3 100644 --- a/web/app/components/workflow/run/agent-log/agent-result-panel.tsx +++ b/web/app/components/workflow/run/agent-log/agent-result-panel.tsx @@ -3,21 +3,25 @@ import AgentLogNav from './agent-log-nav' import type { AgentLogItemWithChildren } from '@/types/workflow' type AgentResultPanelProps = { - agentOrToolLogIdStack: string[] + agentOrToolLogItemStack: { id: string; label: string }[] agentOrToolLogListMap: Record - onShowAgentOrToolLog: (detail: AgentLogItemWithChildren) => void + onShowAgentOrToolLog: (detail?: AgentLogItemWithChildren) => void } const AgentResultPanel = ({ - agentOrToolLogIdStack, + agentOrToolLogItemStack, agentOrToolLogListMap, onShowAgentOrToolLog, }: AgentResultPanelProps) => { - const top = agentOrToolLogIdStack[agentOrToolLogIdStack.length - 1] - const list = agentOrToolLogListMap[top] + const top = agentOrToolLogItemStack[agentOrToolLogItemStack.length - 1] + const list = agentOrToolLogListMap[top.id] return (
- + {
{ diff --git a/web/app/components/workflow/run/hooks.ts b/web/app/components/workflow/run/hooks.ts index d14e39ce47..b9c879a204 100644 --- a/web/app/components/workflow/run/hooks.ts +++ b/web/app/components/workflow/run/hooks.ts @@ -33,22 +33,27 @@ export const useLogs = () => { setIterationResultDurationMap(iterDurationMap) }, [setShowIteratingDetailTrue, setIterationResultList, setIterationResultDurationMap]) - const [agentOrToolLogIdStack, setAgentOrToolLogIdStack] = useState([]) - const agentOrToolLogIdStackRef = useRef(agentOrToolLogIdStack) + const [agentOrToolLogItemStack, setAgentOrToolLogItemStack] = useState<{ id: string; label: string }[]>([]) + const agentOrToolLogItemStackRef = useRef(agentOrToolLogItemStack) const [agentOrToolLogListMap, setAgentOrToolLogListMap] = useState>({}) const agentOrToolLogListMapRef = useRef(agentOrToolLogListMap) - const handleShowAgentOrToolLog = useCallback((detail: AgentLogItemWithChildren) => { - const { id, children } = detail - let currentAgentOrToolLogIdStack = agentOrToolLogIdStackRef.current.slice() - const index = currentAgentOrToolLogIdStack.findIndex(logId => logId === id) + const handleShowAgentOrToolLog = useCallback((detail?: AgentLogItemWithChildren) => { + if (!detail) { + setAgentOrToolLogItemStack([]) + agentOrToolLogItemStackRef.current = [] + return + } + const { id, label, children } = detail + let currentAgentOrToolLogItemStack = agentOrToolLogItemStackRef.current.slice() + const index = currentAgentOrToolLogItemStack.findIndex(logItem => logItem.id === id) if (index > -1) - currentAgentOrToolLogIdStack = currentAgentOrToolLogIdStack.slice(0, index + 1) + currentAgentOrToolLogItemStack = currentAgentOrToolLogItemStack.slice(0, index + 1) else - currentAgentOrToolLogIdStack = [...currentAgentOrToolLogIdStack.slice(), id] + currentAgentOrToolLogItemStack = [...currentAgentOrToolLogItemStack.slice(), { id, label }] - setAgentOrToolLogIdStack(currentAgentOrToolLogIdStack) - agentOrToolLogIdStackRef.current = currentAgentOrToolLogIdStack + setAgentOrToolLogItemStack(currentAgentOrToolLogItemStack) + agentOrToolLogItemStackRef.current = currentAgentOrToolLogItemStack if (children) { setAgentOrToolLogListMap({ @@ -56,10 +61,10 @@ export const useLogs = () => { [id]: children, }) } - }, [setAgentOrToolLogIdStack, setAgentOrToolLogListMap]) + }, [setAgentOrToolLogItemStack, setAgentOrToolLogListMap]) return { - showSpecialResultPanel: showRetryDetail || showIteratingDetail || !!agentOrToolLogIdStack.length, + showSpecialResultPanel: showRetryDetail || showIteratingDetail || !!agentOrToolLogItemStack.length, showRetryDetail, setShowRetryDetailTrue, setShowRetryDetailFalse, @@ -76,7 +81,7 @@ export const useLogs = () => { setIterationResultDurationMap, handleShowIterationResultList, - agentOrToolLogIdStack, + agentOrToolLogItemStack, agentOrToolLogListMap, handleShowAgentOrToolLog, } diff --git a/web/app/components/workflow/run/node.tsx b/web/app/components/workflow/run/node.tsx index 010a3db22a..2fdab2bb7b 100644 --- a/web/app/components/workflow/run/node.tsx +++ b/web/app/components/workflow/run/node.tsx @@ -34,7 +34,7 @@ type Props = { hideProcessDetail?: boolean onShowIterationDetail?: (detail: NodeTracing[][], iterDurationMap: IterationDurationMap) => void onShowRetryDetail?: (detail: NodeTracing[]) => void - onShowAgentOrToolLog?: (detail: AgentLogItemWithChildren) => void + onShowAgentOrToolLog?: (detail?: AgentLogItemWithChildren) => void notShowIterationNav?: boolean } diff --git a/web/app/components/workflow/run/result-panel.tsx b/web/app/components/workflow/run/result-panel.tsx index 727536ced3..a39bfe40ab 100644 --- a/web/app/components/workflow/run/result-panel.tsx +++ b/web/app/components/workflow/run/result-panel.tsx @@ -34,7 +34,7 @@ type ResultPanelProps = { execution_metadata?: any handleShowIterationResultList?: (detail: NodeTracing[][], iterDurationMap: any) => void onShowRetryDetail?: (detail: NodeTracing[]) => void - handleShowAgentOrToolLog?: (detail: AgentLogItemWithChildren) => void + handleShowAgentOrToolLog?: (detail?: AgentLogItemWithChildren) => void } const ResultPanel: FC = ({ diff --git a/web/app/components/workflow/run/special-result-panel.tsx b/web/app/components/workflow/run/special-result-panel.tsx index ec3e93417c..f32487146d 100644 --- a/web/app/components/workflow/run/special-result-panel.tsx +++ b/web/app/components/workflow/run/special-result-panel.tsx @@ -17,9 +17,9 @@ export type SpecialResultPanelProps = { iterationResultList?: NodeTracing[][] iterationResultDurationMap?: IterationDurationMap - agentOrToolLogIdStack?: string[] + agentOrToolLogItemStack?: { id: string; label: string }[] agentOrToolLogListMap?: Record - handleShowAgentOrToolLog?: (detail: AgentLogItemWithChildren) => void + handleShowAgentOrToolLog?: (detail?: AgentLogItemWithChildren) => void } const SpecialResultPanel = ({ showRetryDetail, @@ -31,7 +31,7 @@ const SpecialResultPanel = ({ iterationResultList, iterationResultDurationMap, - agentOrToolLogIdStack, + agentOrToolLogItemStack, agentOrToolLogListMap, handleShowAgentOrToolLog, }: SpecialResultPanelProps) => { @@ -55,9 +55,9 @@ const SpecialResultPanel = ({ ) } { - !!agentOrToolLogIdStack?.length && agentOrToolLogListMap && handleShowAgentOrToolLog && ( + !!agentOrToolLogItemStack?.length && agentOrToolLogListMap && handleShowAgentOrToolLog && ( diff --git a/web/app/components/workflow/run/tracing-panel.tsx b/web/app/components/workflow/run/tracing-panel.tsx index 557c58c532..d65b7b73eb 100644 --- a/web/app/components/workflow/run/tracing-panel.tsx +++ b/web/app/components/workflow/run/tracing-panel.tsx @@ -79,7 +79,7 @@ const TracingPanel: FC = ({ iterationResultDurationMap, handleShowIterationResultList, - agentOrToolLogIdStack, + agentOrToolLogItemStack, agentOrToolLogListMap, handleShowAgentOrToolLog, } = useLogs() @@ -158,7 +158,7 @@ const TracingPanel: FC = ({ iterationResultList={iterationResultList} iterationResultDurationMap={iterationResultDurationMap} - agentOrToolLogIdStack={agentOrToolLogIdStack} + agentOrToolLogItemStack={agentOrToolLogItemStack} agentOrToolLogListMap={agentOrToolLogListMap} handleShowAgentOrToolLog={handleShowAgentOrToolLog} /> From 98a03b0593632b8b842f40d108fb7da23a7b6ddc Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Mon, 30 Dec 2024 11:25:28 +0800 Subject: [PATCH 6/6] fix: agent log structure --- .../workflow/run/agent-log/agent-log-nav.tsx | 21 +++++++++++-------- .../run/agent-log/agent-result-panel.tsx | 1 - 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/web/app/components/workflow/run/agent-log/agent-log-nav.tsx b/web/app/components/workflow/run/agent-log/agent-log-nav.tsx index 50501ef026..a56730a45a 100644 --- a/web/app/components/workflow/run/agent-log/agent-log-nav.tsx +++ b/web/app/components/workflow/run/agent-log/agent-log-nav.tsx @@ -5,16 +5,13 @@ import type { AgentLogItemWithChildren } from '@/types/workflow' type AgentLogNavProps = { agentOrToolLogItemStack: { id: string; label: string }[] - agentOrToolLogListMap: Record onShowAgentOrToolLog: (detail?: AgentLogItemWithChildren) => void } const AgentLogNav = ({ agentOrToolLogItemStack, - agentOrToolLogListMap, onShowAgentOrToolLog, }: AgentLogNavProps) => { - const top = agentOrToolLogItemStack[agentOrToolLogItemStack.length - 1] - const options = agentOrToolLogListMap[top.id] + const options = agentOrToolLogItemStack.slice(2) return (
@@ -37,11 +34,17 @@ const AgentLogNav = ({ Agent strategy -
/
- + { + !!options.length && ( + <> +
/
+ + + ) + }
/
Run Actions diff --git a/web/app/components/workflow/run/agent-log/agent-result-panel.tsx b/web/app/components/workflow/run/agent-log/agent-result-panel.tsx index fe40d751d3..3028384f4a 100644 --- a/web/app/components/workflow/run/agent-log/agent-result-panel.tsx +++ b/web/app/components/workflow/run/agent-log/agent-result-panel.tsx @@ -19,7 +19,6 @@ const AgentResultPanel = ({
{