mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
Bugfix/AgentflowV2 State (#4512)
* add persistence state, http node variables, custom function flow state * update marketplace templates
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"data": {
|
||||
"id": "startAgentflow_0",
|
||||
"label": "Start",
|
||||
"version": 1,
|
||||
"version": 1.1,
|
||||
"name": "startAgentflow",
|
||||
"type": "Start",
|
||||
"color": "#7EE787",
|
||||
@@ -157,6 +157,15 @@
|
||||
],
|
||||
"id": "startAgentflow_0-input-startState-array",
|
||||
"display": true
|
||||
},
|
||||
{
|
||||
"label": "Persist State",
|
||||
"name": "startPersistState",
|
||||
"type": "boolean",
|
||||
"description": "Persist the state in the same session",
|
||||
"optional": true,
|
||||
"id": "startAgentflow_0-input-startPersistState-boolean",
|
||||
"display": true
|
||||
}
|
||||
],
|
||||
"inputAnchors": [],
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"data": {
|
||||
"id": "startAgentflow_0",
|
||||
"label": "Start",
|
||||
"version": 1,
|
||||
"version": 1.1,
|
||||
"name": "startAgentflow",
|
||||
"type": "Start",
|
||||
"color": "#7EE787",
|
||||
@@ -157,6 +157,15 @@
|
||||
],
|
||||
"id": "startAgentflow_0-input-startState-array",
|
||||
"display": true
|
||||
},
|
||||
{
|
||||
"label": "Persist State",
|
||||
"name": "startPersistState",
|
||||
"type": "boolean",
|
||||
"description": "Persist the state in the same session",
|
||||
"optional": true,
|
||||
"id": "startAgentflow_0-input-startPersistState-boolean",
|
||||
"display": true
|
||||
}
|
||||
],
|
||||
"inputAnchors": [],
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"data": {
|
||||
"id": "startAgentflow_0",
|
||||
"label": "Start",
|
||||
"version": 1,
|
||||
"version": 1.1,
|
||||
"name": "startAgentflow",
|
||||
"type": "Start",
|
||||
"color": "#7EE787",
|
||||
@@ -160,6 +160,15 @@
|
||||
],
|
||||
"id": "startAgentflow_0-input-startState-array",
|
||||
"display": true
|
||||
},
|
||||
{
|
||||
"label": "Persist State",
|
||||
"name": "startPersistState",
|
||||
"type": "boolean",
|
||||
"description": "Persist the state in the same session",
|
||||
"optional": true,
|
||||
"id": "startAgentflow_0-input-startPersistState-boolean",
|
||||
"display": true
|
||||
}
|
||||
],
|
||||
"inputAnchors": [],
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"data": {
|
||||
"id": "startAgentflow_0",
|
||||
"label": "Start",
|
||||
"version": 1,
|
||||
"version": 1.1,
|
||||
"name": "startAgentflow",
|
||||
"type": "Start",
|
||||
"color": "#7EE787",
|
||||
@@ -157,6 +157,15 @@
|
||||
],
|
||||
"id": "startAgentflow_0-input-startState-array",
|
||||
"display": true
|
||||
},
|
||||
{
|
||||
"label": "Persist State",
|
||||
"name": "startPersistState",
|
||||
"type": "boolean",
|
||||
"description": "Persist the state in the same session",
|
||||
"optional": true,
|
||||
"id": "startAgentflow_0-input-startPersistState-boolean",
|
||||
"display": true
|
||||
}
|
||||
],
|
||||
"inputAnchors": [],
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"data": {
|
||||
"id": "startAgentflow_0",
|
||||
"label": "Start",
|
||||
"version": 1,
|
||||
"version": 1.1,
|
||||
"name": "startAgentflow",
|
||||
"type": "Start",
|
||||
"color": "#7EE787",
|
||||
@@ -157,6 +157,15 @@
|
||||
],
|
||||
"id": "startAgentflow_0-input-startState-array",
|
||||
"display": true
|
||||
},
|
||||
{
|
||||
"label": "Persist State",
|
||||
"name": "startPersistState",
|
||||
"type": "boolean",
|
||||
"description": "Persist the state in the same session",
|
||||
"optional": true,
|
||||
"id": "startAgentflow_0-input-startPersistState-boolean",
|
||||
"display": true
|
||||
}
|
||||
],
|
||||
"inputAnchors": [],
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"data": {
|
||||
"id": "startAgentflow_0",
|
||||
"label": "Start",
|
||||
"version": 1,
|
||||
"version": 1.1,
|
||||
"name": "startAgentflow",
|
||||
"type": "Start",
|
||||
"color": "#7EE787",
|
||||
@@ -157,6 +157,15 @@
|
||||
],
|
||||
"id": "startAgentflow_0-input-startState-array",
|
||||
"display": true
|
||||
},
|
||||
{
|
||||
"label": "Persist State",
|
||||
"name": "startPersistState",
|
||||
"type": "boolean",
|
||||
"description": "Persist the state in the same session",
|
||||
"optional": true,
|
||||
"id": "startAgentflow_0-input-startPersistState-boolean",
|
||||
"display": true
|
||||
}
|
||||
],
|
||||
"inputAnchors": [],
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"data": {
|
||||
"id": "startAgentflow_0",
|
||||
"label": "Start",
|
||||
"version": 1,
|
||||
"version": 1.1,
|
||||
"name": "startAgentflow",
|
||||
"type": "Start",
|
||||
"color": "#7EE787",
|
||||
@@ -157,6 +157,15 @@
|
||||
],
|
||||
"id": "startAgentflow_0-input-startState-array",
|
||||
"display": true
|
||||
},
|
||||
{
|
||||
"label": "Persist State",
|
||||
"name": "startPersistState",
|
||||
"type": "boolean",
|
||||
"description": "Persist the state in the same session",
|
||||
"optional": true,
|
||||
"id": "startAgentflow_0-input-startPersistState-boolean",
|
||||
"display": true
|
||||
}
|
||||
],
|
||||
"inputAnchors": [],
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"data": {
|
||||
"id": "startAgentflow_0",
|
||||
"label": "Start",
|
||||
"version": 1,
|
||||
"version": 1.1,
|
||||
"name": "startAgentflow",
|
||||
"type": "Start",
|
||||
"color": "#7EE787",
|
||||
@@ -157,6 +157,15 @@
|
||||
],
|
||||
"id": "startAgentflow_0-input-startState-array",
|
||||
"display": true
|
||||
},
|
||||
{
|
||||
"label": "Persist State",
|
||||
"name": "startPersistState",
|
||||
"type": "boolean",
|
||||
"description": "Persist the state in the same session",
|
||||
"optional": true,
|
||||
"id": "startAgentflow_0-input-startPersistState-boolean",
|
||||
"display": true
|
||||
}
|
||||
],
|
||||
"inputAnchors": [],
|
||||
|
||||
@@ -1324,6 +1324,24 @@ export const executeAgentFlow = async ({
|
||||
}
|
||||
}
|
||||
|
||||
// If the state is persistent, get the state from the previous execution
|
||||
const startPersistState = nodes.find((node) => node.data.name === 'startAgentflow')?.data.inputs?.startPersistState
|
||||
if (startPersistState === true && previousExecution) {
|
||||
const previousExecutionData = (JSON.parse(previousExecution.executionData) as IAgentflowExecutedData[]) ?? []
|
||||
|
||||
let previousState = {}
|
||||
if (Array.isArray(previousExecutionData) && previousExecutionData.length) {
|
||||
for (const execData of previousExecutionData.reverse()) {
|
||||
if (execData.data.state) {
|
||||
previousState = execData.data.state
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
agentflowRuntime.state = previousState
|
||||
}
|
||||
|
||||
// If the start input type is form input, get the form values from the previous execution (form values are persisted in the same session)
|
||||
if (startInputType === 'formInput' && previousExecution) {
|
||||
const previousExecutionData = (JSON.parse(previousExecution.executionData) as IAgentflowExecutedData[]) ?? []
|
||||
|
||||
Reference in New Issue
Block a user