mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
Feature/add ability to show variable output (#3580)
add ability to show variable output
This commit is contained in:
@@ -16,7 +16,7 @@ class SetVariable_Utilities implements INode {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'Set Variable'
|
this.label = 'Set Variable'
|
||||||
this.name = 'setVariable'
|
this.name = 'setVariable'
|
||||||
this.version = 2.0
|
this.version = 2.1
|
||||||
this.type = 'SetVariable'
|
this.type = 'SetVariable'
|
||||||
this.icon = 'setvar.svg'
|
this.icon = 'setvar.svg'
|
||||||
this.category = 'Utilities'
|
this.category = 'Utilities'
|
||||||
@@ -36,6 +36,14 @@ class SetVariable_Utilities implements INode {
|
|||||||
name: 'variableName',
|
name: 'variableName',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
placeholder: 'var1'
|
placeholder: 'var1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Show Output',
|
||||||
|
name: 'showOutput',
|
||||||
|
description: 'Show the output result in the Prediction API response',
|
||||||
|
type: 'boolean',
|
||||||
|
optional: true,
|
||||||
|
additionalParams: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
this.outputs = [
|
this.outputs = [
|
||||||
|
|||||||
@@ -249,6 +249,8 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
|
|||||||
// Get prepend messages
|
// Get prepend messages
|
||||||
const prependMessages = incomingInput.history
|
const prependMessages = incomingInput.history
|
||||||
|
|
||||||
|
const flowVariables = {} as Record<string, unknown>
|
||||||
|
|
||||||
/* Reuse the flow without having to rebuild (to avoid duplicated upsert, recomputation, reinitialization of memory) when all these conditions met:
|
/* Reuse the flow without having to rebuild (to avoid duplicated upsert, recomputation, reinitialization of memory) when all these conditions met:
|
||||||
* - Reuse of flows is not disabled
|
* - Reuse of flows is not disabled
|
||||||
* - Node Data already exists in pool
|
* - Node Data already exists in pool
|
||||||
@@ -378,6 +380,18 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
|
|||||||
baseURL
|
baseURL
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Show output of setVariable nodes in the response
|
||||||
|
for (const node of reactFlowNodes) {
|
||||||
|
if (
|
||||||
|
node.data.name === 'setVariable' &&
|
||||||
|
(node.data.inputs?.showOutput === true || node.data.inputs?.showOutput === 'true')
|
||||||
|
) {
|
||||||
|
const outputResult = node.data.instance
|
||||||
|
const variableKey = node.data.inputs?.variableName
|
||||||
|
flowVariables[variableKey] = outputResult
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const nodeToExecute =
|
const nodeToExecute =
|
||||||
endingNodeIds.length === 1
|
endingNodeIds.length === 1
|
||||||
? reactFlowNodes.find((node: IReactFlowNode) => endingNodeIds[0] === node.id)
|
? reactFlowNodes.find((node: IReactFlowNode) => endingNodeIds[0] === node.id)
|
||||||
@@ -525,6 +539,7 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
|
|||||||
|
|
||||||
if (sessionId) result.sessionId = sessionId
|
if (sessionId) result.sessionId = sessionId
|
||||||
if (memoryType) result.memoryType = memoryType
|
if (memoryType) result.memoryType = memoryType
|
||||||
|
if (Object.keys(flowVariables).length) result.flowVariables = flowVariables
|
||||||
|
|
||||||
return result
|
return result
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user