Skip to content

Commit ad6ba1c

Browse files
crazywoolajiangzhijie
authored and
jiangzhijie
committed
Fix/10199 application error a client side exception has occurred see the browser console for more information (langgenius#10211)
1 parent 2943879 commit ad6ba1c

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts

+14-17
Original file line numberDiff line numberDiff line change
@@ -105,32 +105,29 @@ const useOneStepRun = <T>({
105105
const availableNodesIncludeParent = getBeforeNodesInSameBranchIncludeParent(id)
106106
const allOutputVars = toNodeOutputVars(availableNodes, isChatMode, undefined, undefined, conversationVariables)
107107
const getVar = (valueSelector: ValueSelector): Var | undefined => {
108-
let res: Var | undefined
109108
const isSystem = valueSelector[0] === 'sys'
110-
const targetVar = isSystem ? allOutputVars.find(item => !!item.isStartNode) : allOutputVars.find(v => v.nodeId === valueSelector[0])
109+
const targetVar = allOutputVars.find(item => isSystem ? !!item.isStartNode : item.nodeId === valueSelector[0])
111110
if (!targetVar)
112111
return undefined
112+
113113
if (isSystem)
114114
return targetVar.vars.find(item => item.variable.split('.')[1] === valueSelector[1])
115115

116116
let curr: any = targetVar.vars
117-
if (!curr)
118-
return
117+
for (let i = 1; i < valueSelector.length; i++) {
118+
const key = valueSelector[i]
119+
const isLast = i === valueSelector.length - 1
119120

120-
valueSelector.slice(1).forEach((key, i) => {
121-
const isLast = i === valueSelector.length - 2
122-
// conversation variable is start with 'conversation.'
123-
curr = curr?.find((v: any) => v.variable.replace('conversation.', '') === key)
124-
if (isLast) {
125-
res = curr
126-
}
127-
else {
128-
if (curr?.type === VarType.object || curr?.type === VarType.file)
129-
curr = curr.children
130-
}
131-
})
121+
if (Array.isArray(curr))
122+
curr = curr.find((v: any) => v.variable.replace('conversation.', '') === key)
123+
124+
if (isLast)
125+
return curr
126+
else if (curr?.type === VarType.object || curr?.type === VarType.file)
127+
curr = curr.children
128+
}
132129

133-
return res
130+
return undefined
134131
}
135132

136133
const checkValid = checkValidFns[data.type]

0 commit comments

Comments
 (0)