From 313f32b094451f5c4648388494a263a83b8d1187 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Wed, 12 Mar 2025 10:00:05 -0400 Subject: [PATCH] Wrap widget value in API format workflow (#2989) --- src/utils/executionUtil.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/utils/executionUtil.ts b/src/utils/executionUtil.ts index c8eaa3631d..976894a768 100644 --- a/src/utils/executionUtil.ts +++ b/src/utils/executionUtil.ts @@ -66,9 +66,19 @@ export const graphToPrompt = async ( for (const [i, widget] of widgets.entries()) { if (!widget.name || widget.options?.serialize === false) continue - inputs[widget.name] = widget.serializeValue + const widgetValue = widget.serializeValue ? await widget.serializeValue(node, i) : widget.value + // By default, Array values are reserved to represent node connections. + // We need to wrap the array as an object to avoid the misinterpretation + // of the array as a node connection. + // The backend automatically unwraps the object to an array during + // execution. + inputs[widget.name] = Array.isArray(widgetValue) + ? { + __value__: widgetValue + } + : widgetValue } }