mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 08:26:27 +08:00
fix: single run bool type
This commit is contained in:
parent
75d4e519fc
commit
37de3b1b68
@ -94,6 +94,8 @@ const varTypeToInputVarType = (type: VarType, {
|
|||||||
return InputVarType.paragraph
|
return InputVarType.paragraph
|
||||||
if (type === VarType.number)
|
if (type === VarType.number)
|
||||||
return InputVarType.number
|
return InputVarType.number
|
||||||
|
if (type === VarType.boolean)
|
||||||
|
return InputVarType.boolean
|
||||||
if ([VarType.object, VarType.array, VarType.arrayNumber, VarType.arrayString, VarType.arrayObject].includes(type))
|
if ([VarType.object, VarType.array, VarType.arrayNumber, VarType.arrayString, VarType.arrayObject].includes(type))
|
||||||
return InputVarType.json
|
return InputVarType.json
|
||||||
if (type === VarType.file)
|
if (type === VarType.file)
|
||||||
@ -185,11 +187,11 @@ const useOneStepRun = <T>({
|
|||||||
const isPaused = isPausedRef.current
|
const isPaused = isPausedRef.current
|
||||||
|
|
||||||
// The backend don't support pause the single run, so the frontend handle the pause state.
|
// The backend don't support pause the single run, so the frontend handle the pause state.
|
||||||
if(isPaused)
|
if (isPaused)
|
||||||
return
|
return
|
||||||
|
|
||||||
const canRunLastRun = !isRunAfterSingleRun || runningStatus === NodeRunningStatus.Succeeded
|
const canRunLastRun = !isRunAfterSingleRun || runningStatus === NodeRunningStatus.Succeeded
|
||||||
if(!canRunLastRun) {
|
if (!canRunLastRun) {
|
||||||
doSetRunResult(data)
|
doSetRunResult(data)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -199,9 +201,9 @@ const useOneStepRun = <T>({
|
|||||||
const { getNodes } = store.getState()
|
const { getNodes } = store.getState()
|
||||||
const nodes = getNodes()
|
const nodes = getNodes()
|
||||||
appendNodeInspectVars(id, vars, nodes)
|
appendNodeInspectVars(id, vars, nodes)
|
||||||
if(data?.status === NodeRunningStatus.Succeeded) {
|
if (data?.status === NodeRunningStatus.Succeeded) {
|
||||||
invalidLastRun()
|
invalidLastRun()
|
||||||
if(isStartNode)
|
if (isStartNode)
|
||||||
invalidateSysVarValues()
|
invalidateSysVarValues()
|
||||||
invalidateConversationVarValues() // loop, iteration, variable assigner node can update the conversation variables, but to simple the logic(some nodes may also can update in the future), all nodes refresh.
|
invalidateConversationVarValues() // loop, iteration, variable assigner node can update the conversation variables, but to simple the logic(some nodes may also can update in the future), all nodes refresh.
|
||||||
}
|
}
|
||||||
@ -218,21 +220,21 @@ const useOneStepRun = <T>({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
const checkValidWrap = () => {
|
const checkValidWrap = () => {
|
||||||
if(!checkValid)
|
if (!checkValid)
|
||||||
return { isValid: true, errorMessage: '' }
|
return { isValid: true, errorMessage: '' }
|
||||||
const res = checkValid(data, t, moreDataForCheckValid)
|
const res = checkValid(data, t, moreDataForCheckValid)
|
||||||
if(!res.isValid) {
|
if (!res.isValid) {
|
||||||
handleNodeDataUpdate({
|
handleNodeDataUpdate({
|
||||||
id,
|
id,
|
||||||
data: {
|
data: {
|
||||||
...data,
|
...data,
|
||||||
_isSingleRun: false,
|
_isSingleRun: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Toast.notify({
|
Toast.notify({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: res.errorMessage,
|
message: res.errorMessage,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
@ -251,7 +253,6 @@ const useOneStepRun = <T>({
|
|||||||
const { isValid } = checkValidWrap()
|
const { isValid } = checkValidWrap()
|
||||||
setCanShowSingleRun(isValid)
|
setCanShowSingleRun(isValid)
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [data._isSingleRun])
|
}, [data._isSingleRun])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -293,9 +294,9 @@ const useOneStepRun = <T>({
|
|||||||
if (!isIteration && !isLoop) {
|
if (!isIteration && !isLoop) {
|
||||||
const isStartNode = data.type === BlockEnum.Start
|
const isStartNode = data.type === BlockEnum.Start
|
||||||
const postData: Record<string, any> = {}
|
const postData: Record<string, any> = {}
|
||||||
if(isStartNode) {
|
if (isStartNode) {
|
||||||
const { '#sys.query#': query, '#sys.files#': files, ...inputs } = submitData
|
const { '#sys.query#': query, '#sys.files#': files, ...inputs } = submitData
|
||||||
if(isChatMode)
|
if (isChatMode)
|
||||||
postData.conversation_id = ''
|
postData.conversation_id = ''
|
||||||
|
|
||||||
postData.inputs = inputs
|
postData.inputs = inputs
|
||||||
@ -317,7 +318,7 @@ const useOneStepRun = <T>({
|
|||||||
{
|
{
|
||||||
onWorkflowStarted: noop,
|
onWorkflowStarted: noop,
|
||||||
onWorkflowFinished: (params) => {
|
onWorkflowFinished: (params) => {
|
||||||
if(isPausedRef.current)
|
if (isPausedRef.current)
|
||||||
return
|
return
|
||||||
handleNodeDataUpdate({
|
handleNodeDataUpdate({
|
||||||
id,
|
id,
|
||||||
@ -396,7 +397,7 @@ const useOneStepRun = <T>({
|
|||||||
setIterationRunResult(newIterationRunResult)
|
setIterationRunResult(newIterationRunResult)
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
if(isPausedRef.current)
|
if (isPausedRef.current)
|
||||||
return
|
return
|
||||||
handleNodeDataUpdate({
|
handleNodeDataUpdate({
|
||||||
id,
|
id,
|
||||||
@ -420,7 +421,7 @@ const useOneStepRun = <T>({
|
|||||||
{
|
{
|
||||||
onWorkflowStarted: noop,
|
onWorkflowStarted: noop,
|
||||||
onWorkflowFinished: (params) => {
|
onWorkflowFinished: (params) => {
|
||||||
if(isPausedRef.current)
|
if (isPausedRef.current)
|
||||||
return
|
return
|
||||||
handleNodeDataUpdate({
|
handleNodeDataUpdate({
|
||||||
id,
|
id,
|
||||||
@ -500,7 +501,7 @@ const useOneStepRun = <T>({
|
|||||||
setLoopRunResult(newLoopRunResult)
|
setLoopRunResult(newLoopRunResult)
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
if(isPausedRef.current)
|
if (isPausedRef.current)
|
||||||
return
|
return
|
||||||
handleNodeDataUpdate({
|
handleNodeDataUpdate({
|
||||||
id,
|
id,
|
||||||
@ -522,7 +523,7 @@ const useOneStepRun = <T>({
|
|||||||
hasError = true
|
hasError = true
|
||||||
invalidLastRun()
|
invalidLastRun()
|
||||||
if (!isIteration && !isLoop) {
|
if (!isIteration && !isLoop) {
|
||||||
if(isPausedRef.current)
|
if (isPausedRef.current)
|
||||||
return
|
return
|
||||||
handleNodeDataUpdate({
|
handleNodeDataUpdate({
|
||||||
id,
|
id,
|
||||||
@ -544,11 +545,11 @@ const useOneStepRun = <T>({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isPausedRef.current)
|
if (isPausedRef.current)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (!isIteration && !isLoop && !hasError) {
|
if (!isIteration && !isLoop && !hasError) {
|
||||||
if(isPausedRef.current)
|
if (isPausedRef.current)
|
||||||
return
|
return
|
||||||
handleNodeDataUpdate({
|
handleNodeDataUpdate({
|
||||||
id,
|
id,
|
||||||
@ -587,7 +588,7 @@ const useOneStepRun = <T>({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
label: item.label || item.variable,
|
label: (typeof item.label === 'object' ? item.label.variable : item.label) || item.variable,
|
||||||
variable: item.variable,
|
variable: item.variable,
|
||||||
type: varTypeToInputVarType(originalVar.type, {
|
type: varTypeToInputVarType(originalVar.type, {
|
||||||
isSelect: !!originalVar.isSelect,
|
isSelect: !!originalVar.isSelect,
|
||||||
|
|||||||
@ -107,7 +107,7 @@ const useSingleRunFormParams = ({
|
|||||||
}, [runResult, loopRunResult, t])
|
}, [runResult, loopRunResult, t])
|
||||||
|
|
||||||
const setInputVarValues = useCallback((newPayload: Record<string, any>) => {
|
const setInputVarValues = useCallback((newPayload: Record<string, any>) => {
|
||||||
setRunInputData(newPayload)
|
setRunInputData(newPayload)
|
||||||
}, [setRunInputData])
|
}, [setRunInputData])
|
||||||
|
|
||||||
const inputVarValues = (() => {
|
const inputVarValues = (() => {
|
||||||
@ -149,16 +149,15 @@ const useSingleRunFormParams = ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
payload.loop_variables?.forEach((loopVariable) => {
|
payload.loop_variables?.forEach((loopVariable) => {
|
||||||
if(loopVariable.value_type === ValueType.variable)
|
if (loopVariable.value_type === ValueType.variable)
|
||||||
allInputs.push(loopVariable.value)
|
allInputs.push(loopVariable.value)
|
||||||
})
|
})
|
||||||
const inputVarsFromValue: InputVar[] = []
|
const inputVarsFromValue: InputVar[] = []
|
||||||
const varInputs = [...varSelectorsToVarInputs(allInputs), ...inputVarsFromValue]
|
const varInputs = [...varSelectorsToVarInputs(allInputs), ...inputVarsFromValue]
|
||||||
|
|
||||||
const existVarsKey: Record<string, boolean> = {}
|
const existVarsKey: Record<string, boolean> = {}
|
||||||
const uniqueVarInputs: InputVar[] = []
|
const uniqueVarInputs: InputVar[] = []
|
||||||
varInputs.forEach((input) => {
|
varInputs.forEach((input) => {
|
||||||
if(!input)
|
if (!input)
|
||||||
return
|
return
|
||||||
if (!existVarsKey[input.variable]) {
|
if (!existVarsKey[input.variable]) {
|
||||||
existVarsKey[input.variable] = true
|
existVarsKey[input.variable] = true
|
||||||
@ -191,7 +190,7 @@ const useSingleRunFormParams = ({
|
|||||||
if (condition.variable_selector)
|
if (condition.variable_selector)
|
||||||
vars.push(condition.variable_selector)
|
vars.push(condition.variable_selector)
|
||||||
|
|
||||||
if(condition.sub_variable_condition && condition.sub_variable_condition.conditions?.length)
|
if (condition.sub_variable_condition && condition.sub_variable_condition.conditions?.length)
|
||||||
vars.push(...getVarFromCaseItem(condition.sub_variable_condition))
|
vars.push(...getVarFromCaseItem(condition.sub_variable_condition))
|
||||||
return vars
|
return vars
|
||||||
}
|
}
|
||||||
@ -203,7 +202,7 @@ const useSingleRunFormParams = ({
|
|||||||
vars.push(...conditionVars)
|
vars.push(...conditionVars)
|
||||||
})
|
})
|
||||||
payload.loop_variables?.forEach((loopVariable) => {
|
payload.loop_variables?.forEach((loopVariable) => {
|
||||||
if(loopVariable.value_type === ValueType.variable)
|
if (loopVariable.value_type === ValueType.variable)
|
||||||
vars.push(loopVariable.value)
|
vars.push(loopVariable.value)
|
||||||
})
|
})
|
||||||
const hasFilterLoopVars = vars.filter(item => item[0] !== id)
|
const hasFilterLoopVars = vars.filter(item => item[0] !== id)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user