mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 18:25:55 +08:00
fix: tool constant params change cause page crashed (#11682)
This commit is contained in:
parent
4b402c4041
commit
607a22ad12
@ -61,20 +61,12 @@ const InputVarList: FC<Props> = ({
|
|||||||
const newValue = produce(value, (draft: ToolVarInputs) => {
|
const newValue = produce(value, (draft: ToolVarInputs) => {
|
||||||
const target = draft[variable]
|
const target = draft[variable]
|
||||||
if (target) {
|
if (target) {
|
||||||
if (!isSupportConstantValue || varKindType === VarKindType.variable) {
|
target.type = varKindType
|
||||||
if (isSupportConstantValue)
|
target.value = varValue
|
||||||
target.type = VarKindType.variable
|
|
||||||
|
|
||||||
target.value = varValue as ValueSelector
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
target.type = VarKindType.constant
|
|
||||||
target.value = varValue as string
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
draft[variable] = {
|
draft[variable] = {
|
||||||
type: VarKindType.variable,
|
type: varKindType,
|
||||||
value: varValue,
|
value: varValue,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,7 +165,7 @@ const InputVarList: FC<Props> = ({
|
|||||||
value={varInput?.type === VarKindType.constant ? (varInput?.value || '') : (varInput?.value || [])}
|
value={varInput?.type === VarKindType.constant ? (varInput?.value || '') : (varInput?.value || [])}
|
||||||
onChange={handleNotMixedTypeChange(variable)}
|
onChange={handleNotMixedTypeChange(variable)}
|
||||||
onOpen={handleOpen(index)}
|
onOpen={handleOpen(index)}
|
||||||
defaultVarKindType={isNumber ? VarKindType.constant : VarKindType.variable}
|
defaultVarKindType={varInput?.type || (isNumber ? VarKindType.constant : VarKindType.variable)}
|
||||||
isSupportConstantValue={isSupportConstantValue}
|
isSupportConstantValue={isSupportConstantValue}
|
||||||
filterVar={isNumber ? filterVar : undefined}
|
filterVar={isNumber ? filterVar : undefined}
|
||||||
availableVars={isSelect ? availableVars : undefined}
|
availableVars={isSelect ? availableVars : undefined}
|
||||||
|
@ -214,8 +214,13 @@ const useConfig = (id: string, payload: ToolNodeType) => {
|
|||||||
.map(k => inputs.tool_parameters[k])
|
.map(k => inputs.tool_parameters[k])
|
||||||
|
|
||||||
const varInputs = getInputVars(hadVarParams.map((p) => {
|
const varInputs = getInputVars(hadVarParams.map((p) => {
|
||||||
if (p.type === VarType.variable)
|
if (p.type === VarType.variable) {
|
||||||
|
// handle the old wrong value not crash the page
|
||||||
|
if (!(p.value as any).join)
|
||||||
|
return `{{#${p.value}#}}`
|
||||||
|
|
||||||
return `{{#${(p.value as ValueSelector).join('.')}#}}`
|
return `{{#${(p.value as ValueSelector).join('.')}#}}`
|
||||||
|
}
|
||||||
|
|
||||||
return p.value as string
|
return p.value as string
|
||||||
}))
|
}))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user