Wrap widget value in API format workflow (#2989)

This commit is contained in:
Chenlei Hu
2025-03-12 10:00:05 -04:00
committed by GitHub
parent d76391b682
commit 313f32b094

View File

@@ -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
}
}