@@ -249,6 +249,8 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
249
249
// Get prepend messages
250
250
const prependMessages = incomingInput . history
251
251
252
+ const flowVariables = { } as Record < string , unknown >
253
+
252
254
/* Reuse the flow without having to rebuild (to avoid duplicated upsert, recomputation, reinitialization of memory) when all these conditions met:
253
255
* - Reuse of flows is not disabled
254
256
* - Node Data already exists in pool
@@ -378,6 +380,18 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
378
380
baseURL
379
381
} )
380
382
383
+ // Show output of setVariable nodes in the response
384
+ for ( const node of reactFlowNodes ) {
385
+ if (
386
+ node . data . name === 'setVariable' &&
387
+ ( node . data . inputs ?. showOutput === true || node . data . inputs ?. showOutput === 'true' )
388
+ ) {
389
+ const outputResult = node . data . instance
390
+ const variableKey = node . data . inputs ?. variableName
391
+ flowVariables [ variableKey ] = outputResult
392
+ }
393
+ }
394
+
381
395
const nodeToExecute =
382
396
endingNodeIds . length === 1
383
397
? reactFlowNodes . find ( ( node : IReactFlowNode ) => endingNodeIds [ 0 ] === node . id )
@@ -525,6 +539,7 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
525
539
526
540
if ( sessionId ) result . sessionId = sessionId
527
541
if ( memoryType ) result . memoryType = memoryType
542
+ if ( Object . keys ( flowVariables ) . length ) result . flowVariables = flowVariables
528
543
529
544
return result
530
545
} catch ( e ) {
0 commit comments