diff --git a/packages/web/components/common/Textarea/JsonEditor/index.tsx b/packages/web/components/common/Textarea/JsonEditor/index.tsx index e958ef3ae..da26e20ad 100644 --- a/packages/web/components/common/Textarea/JsonEditor/index.tsx +++ b/packages/web/components/common/Textarea/JsonEditor/index.tsx @@ -178,12 +178,11 @@ const JSONEditor = ({ return ''; } - try { + if (typeof value === 'object') { return JSON.stringify(value, null, 2); - } catch (error) { - console.error('JSON stringify error:', error); - return String(value) || ''; } + + return String(value); }, [value]); const onBlur = useCallback(() => { diff --git a/projects/app/src/web/core/chat/context/chatItemContext.tsx b/projects/app/src/web/core/chat/context/chatItemContext.tsx index 001157cfb..47cceb306 100644 --- a/projects/app/src/web/core/chat/context/chatItemContext.tsx +++ b/projects/app/src/web/core/chat/context/chatItemContext.tsx @@ -140,20 +140,15 @@ const ChatItemContextProvider = ({ (props?: { variables?: Record; variableList?: VariableItemType[] }) => { const { variables, variableList = [] } = props || {}; - let newVariableValue: Record = {}; if (variables) { variableList.forEach((item) => { - newVariableValue[item.key] = variables[item.key]; + variablesForm.setValue(`variables.${item.key}`, variables[item.key]); }); } else { variableList.forEach((item) => { - newVariableValue[item.key] = item.defaultValue; + variablesForm.setValue(`variables.${item.key}`, item.defaultValue); }); } - - Object.entries(newVariableValue).forEach(([key, value]) => { - variablesForm.setValue(`variables.${key}`, value); - }); }, [variablesForm] );