mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-16 17:25:56 +08:00
fix: iteration and loop debug pass wrong struct
This commit is contained in:
parent
29df9ba48b
commit
801bf5ff70
@ -19,6 +19,7 @@ import useLoopSingleRunFormParams from '@/app/components/workflow/nodes/loop/use
|
|||||||
import useIfElseSingleRunFormParams from '@/app/components/workflow/nodes/if-else/use-single-run-form-params'
|
import useIfElseSingleRunFormParams from '@/app/components/workflow/nodes/if-else/use-single-run-form-params'
|
||||||
import useVariableAggregatorSingleRunFormParams from '@/app/components/workflow/nodes/variable-assigner/use-single-run-form-params'
|
import useVariableAggregatorSingleRunFormParams from '@/app/components/workflow/nodes/variable-assigner/use-single-run-form-params'
|
||||||
import useToolGetDataForCheckMore from '@/app/components/workflow/nodes/tool/use-get-data-for-check-more'
|
import useToolGetDataForCheckMore from '@/app/components/workflow/nodes/tool/use-get-data-for-check-more'
|
||||||
|
import { VALUE_SELECTOR_DELIMITER as DELIMITER } from '@/config'
|
||||||
|
|
||||||
// import
|
// import
|
||||||
import type { CommonNodeType, ValueSelector } from '@/app/components/workflow/types'
|
import type { CommonNodeType, ValueSelector } from '@/app/components/workflow/types'
|
||||||
@ -102,6 +103,8 @@ const useLastRun = <T>({
|
|||||||
}: Params<T>) => {
|
}: Params<T>) => {
|
||||||
const { conversationVars, systemVars, hasSetInspectVar } = useInspectVarsCrud()
|
const { conversationVars, systemVars, hasSetInspectVar } = useInspectVarsCrud()
|
||||||
const blockType = oneStepRunParams.data.type
|
const blockType = oneStepRunParams.data.type
|
||||||
|
const isIterationNode = blockType === BlockEnum.Iteration
|
||||||
|
const isLoopNode = blockType === BlockEnum.Loop
|
||||||
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
||||||
const {
|
const {
|
||||||
getData: getDataForCheckMore,
|
getData: getDataForCheckMore,
|
||||||
@ -148,9 +151,26 @@ const useLastRun = <T>({
|
|||||||
loopRunResult,
|
loopRunResult,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const toSubmitData = useCallback((data: Record<string, any>) => {
|
||||||
|
if(!isIterationNode && !isLoopNode)
|
||||||
|
return data
|
||||||
|
|
||||||
|
const allVarObject = singleRunParams?.allVarObject || {}
|
||||||
|
const formattedData: Record<string, any> = {}
|
||||||
|
Object.keys(allVarObject).forEach((key) => {
|
||||||
|
const [varSectorStr, nodeId] = key.split(DELIMITER)
|
||||||
|
formattedData[`${nodeId}.${allVarObject[key].inSingleRunPassedKey}`] = data[varSectorStr]
|
||||||
|
})
|
||||||
|
if(isIterationNode) {
|
||||||
|
const iteratorInputKey = `${id}.input_selector`
|
||||||
|
formattedData[iteratorInputKey] = data[iteratorInputKey]
|
||||||
|
}
|
||||||
|
return formattedData
|
||||||
|
}, [isIterationNode, isLoopNode, singleRunParams?.allVarObject, id])
|
||||||
|
|
||||||
const callRunApi = async (data: Record<string, any>) => {
|
const callRunApi = async (data: Record<string, any>) => {
|
||||||
await handleSyncWorkflowDraft(true)
|
await handleSyncWorkflowDraft(true)
|
||||||
doCallRunApi(data)
|
doCallRunApi(toSubmitData(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
const [tabType, setTabType] = useState<TabType>(TabType.settings)
|
const [tabType, setTabType] = useState<TabType>(TabType.settings)
|
||||||
|
@ -8,9 +8,9 @@ import { getNodeInfoById, getNodeUsedVarPassToServerKey, getNodeUsedVars, isSyst
|
|||||||
import { InputVarType } from '@/app/components/workflow/types'
|
import { InputVarType } from '@/app/components/workflow/types'
|
||||||
import formatTracing from '@/app/components/workflow/run/utils/format-log'
|
import formatTracing from '@/app/components/workflow/run/utils/format-log'
|
||||||
import type { NodeTracing } from '@/types/workflow'
|
import type { NodeTracing } from '@/types/workflow'
|
||||||
|
import { VALUE_SELECTOR_DELIMITER as DELIMITER } from '@/config'
|
||||||
|
|
||||||
const i18nPrefix = 'workflow.nodes.iteration'
|
const i18nPrefix = 'workflow.nodes.iteration'
|
||||||
const DELIMITER = '@@@@@'
|
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
id: string,
|
id: string,
|
||||||
@ -47,7 +47,7 @@ const useSingleRunFormParams = ({
|
|||||||
})
|
})
|
||||||
}, [iteratorInputKey, runInputData, setRunInputData])
|
}, [iteratorInputKey, runInputData, setRunInputData])
|
||||||
|
|
||||||
const { usedOutVars } = (() => {
|
const { usedOutVars, allVarObject } = (() => {
|
||||||
const vars: ValueSelector[] = []
|
const vars: ValueSelector[] = []
|
||||||
const varObjs: Record<string, boolean> = {}
|
const varObjs: Record<string, boolean> = {}
|
||||||
const allVarObject: Record<string, {
|
const allVarObject: Record<string, {
|
||||||
@ -93,6 +93,7 @@ const useSingleRunFormParams = ({
|
|||||||
}))
|
}))
|
||||||
return {
|
return {
|
||||||
usedOutVars: res,
|
usedOutVars: res,
|
||||||
|
allVarObject,
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
@ -143,6 +144,7 @@ const useSingleRunFormParams = ({
|
|||||||
return {
|
return {
|
||||||
forms,
|
forms,
|
||||||
nodeInfo,
|
nodeInfo,
|
||||||
|
allVarObject,
|
||||||
getDependentVars,
|
getDependentVars,
|
||||||
getDependentVar,
|
getDependentVar,
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,7 @@ import { getNodeInfoById, getNodeUsedVarPassToServerKey, getNodeUsedVars, isSyst
|
|||||||
import type { InputVar, ValueSelector, Variable } from '../../types'
|
import type { InputVar, ValueSelector, Variable } from '../../types'
|
||||||
import type { CaseItem, Condition, LoopNodeType } from './types'
|
import type { CaseItem, Condition, LoopNodeType } from './types'
|
||||||
import { ValueType } from '@/app/components/workflow/types'
|
import { ValueType } from '@/app/components/workflow/types'
|
||||||
|
import { VALUE_SELECTOR_DELIMITER as DELIMITER } from '@/config'
|
||||||
const DELIMITER = '@@@@@'
|
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
id: string
|
id: string
|
||||||
@ -36,17 +35,17 @@ const useSingleRunFormParams = ({
|
|||||||
const { isNodeInLoop } = useIsNodeInLoop(id)
|
const { isNodeInLoop } = useIsNodeInLoop(id)
|
||||||
|
|
||||||
const { getLoopNodeChildren, getBeforeNodesInSameBranch } = useWorkflow()
|
const { getLoopNodeChildren, getBeforeNodesInSameBranch } = useWorkflow()
|
||||||
const iterationChildrenNodes = getLoopNodeChildren(id)
|
const loopChildrenNodes = getLoopNodeChildren(id)
|
||||||
const beforeNodes = getBeforeNodesInSameBranch(id)
|
const beforeNodes = getBeforeNodesInSameBranch(id)
|
||||||
const canChooseVarNodes = [...beforeNodes, ...iterationChildrenNodes]
|
const canChooseVarNodes = [...beforeNodes, ...loopChildrenNodes]
|
||||||
|
|
||||||
const { usedOutVars } = (() => {
|
const { usedOutVars, allVarObject } = (() => {
|
||||||
const vars: ValueSelector[] = []
|
const vars: ValueSelector[] = []
|
||||||
const varObjs: Record<string, boolean> = {}
|
const varObjs: Record<string, boolean> = {}
|
||||||
const allVarObject: Record<string, {
|
const allVarObject: Record<string, {
|
||||||
inSingleRunPassedKey: string
|
inSingleRunPassedKey: string
|
||||||
}> = {}
|
}> = {}
|
||||||
iterationChildrenNodes.forEach((node) => {
|
loopChildrenNodes.forEach((node) => {
|
||||||
const nodeVars = getNodeUsedVars(node).filter(item => item && item.length > 0)
|
const nodeVars = getNodeUsedVars(node).filter(item => item && item.length > 0)
|
||||||
nodeVars.forEach((varSelector) => {
|
nodeVars.forEach((varSelector) => {
|
||||||
if (varSelector[0] === id) { // skip loop node itself variable: item, index
|
if (varSelector[0] === id) { // skip loop node itself variable: item, index
|
||||||
@ -87,6 +86,7 @@ const useSingleRunFormParams = ({
|
|||||||
}))
|
}))
|
||||||
return {
|
return {
|
||||||
usedOutVars: res,
|
usedOutVars: res,
|
||||||
|
allVarObject,
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
@ -211,6 +211,7 @@ const useSingleRunFormParams = ({
|
|||||||
return {
|
return {
|
||||||
forms,
|
forms,
|
||||||
nodeInfo,
|
nodeInfo,
|
||||||
|
allVarObject,
|
||||||
getDependentVars,
|
getDependentVars,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,3 +315,5 @@ export const ENABLE_WEBSITE_FIRECRAWL = process.env.NEXT_PUBLIC_ENABLE_WEBSITE_F
|
|||||||
export const ENABLE_WEBSITE_WATERCRAWL = process.env.NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL !== undefined
|
export const ENABLE_WEBSITE_WATERCRAWL = process.env.NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL !== undefined
|
||||||
? process.env.NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL === 'true'
|
? process.env.NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL === 'true'
|
||||||
: globalThis.document?.body?.getAttribute('data-public-enable-website-watercrawl') === 'true' || true
|
: globalThis.document?.body?.getAttribute('data-public-enable-website-watercrawl') === 'true' || true
|
||||||
|
|
||||||
|
export const VALUE_SELECTOR_DELIMITER = '@@@@@'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user