Skip to content

Commit

Permalink
Merge pull request #1483 from FlowiseAI/bugfix/Pass-JSON-Variable-Value
Browse files Browse the repository at this point in the history
Bugfix/Pass Json Variable Value
  • Loading branch information
HenryHengZJ authored Jan 8, 2024
2 parents d5b8db5 + 8cb9393 commit 33c7426
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CustomFunction_Utilities implements INode {
inputVars =
typeof functionInputVariablesRaw === 'object' ? functionInputVariablesRaw : JSON.parse(functionInputVariablesRaw)
} catch (exception) {
throw new Error("Invalid JSON in the PromptTemplate's promptValues: " + exception)
throw new Error('Invalid JSON in the Custom Function Input Variables: ' + exception)
}
}

Expand Down
6 changes: 5 additions & 1 deletion packages/server/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,11 @@ export const getVariableValue = (
variablePaths.forEach((path) => {
const variableValue = variableDict[path]
// Replace all occurrence
returnVal = returnVal.split(path).join(variableValue)
if (typeof variableValue === 'object') {
returnVal = returnVal.split(path).join(JSON.stringify(variableValue).replace(/"/g, '\\"'))
} else {
returnVal = returnVal.split(path).join(variableValue)
}
})
return returnVal
}
Expand Down
6 changes: 5 additions & 1 deletion packages/ui/src/ui-component/dialog/ExpandTextDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ const ExpandTextDialog = ({ show, dialogProps, onCancel, onConfirm }) => {

useEffect(() => {
if (executeCustomFunctionNodeApi.data) {
setCodeExecutedResult(executeCustomFunctionNodeApi.data)
if (typeof executeCustomFunctionNodeApi.data === 'object') {
setCodeExecutedResult(JSON.stringify(executeCustomFunctionNodeApi.data, null, 2))
} else {
setCodeExecutedResult(executeCustomFunctionNodeApi.data)
}
}
}, [executeCustomFunctionNodeApi.data])

Expand Down

0 comments on commit 33c7426

Please sign in to comment.