mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
Feature/agentflow v2 (#4298)
* agent flow v2 * chat message background * conditon agent flow * add sticky note * update human input dynamic prompt * add HTTP node * add default tool icon * fix export duplicate agentflow v2 * add agentflow v2 marketplaces * refractor memoization, add iteration nodes * add agentflow v2 templates * add agentflow generator * add migration scripts for mysql, mariadb, posrgres and fix date filters for executions * update agentflow chat history config * fix get all flows error after deletion and rename * add previous nodes from parent node * update generator prompt * update run time state when using iteration nodes * prevent looping connection, prevent duplication of start node, add executeflow node, add nodes agentflow, chat history variable * update embed * convert form input to string * bump openai version * add react rewards * add prompt generator to prediction queue * add array schema to overrideconfig * UI touchup * update embedded chat version * fix node info dialog * update start node and loop default iteration * update UI fixes for agentflow v2 * fix async drop down * add export import to agentflowsv2, executions, fix UI bugs * add default empty object to flowlisttable * add ability to share trace link publicly, allow MCP tool use for Agent and Assistant * add runtime message length to variable, display conditions on UI * fix array validation * add ability to add knowledge from vector store and embeddings for agent * add agent tool require human input * add ephemeral memory to start node * update agent flow node to show vs and embeddings icons * feat: add import chat data functionality for AgentFlowV2 * feat: set chatMessage.executionId to null if not found in import JSON file or database * fix: MariaDB execution migration script to utf8mb4_unicode_520_ci --------- Co-authored-by: Ong Chung Yau <33013947+chungyau97@users.noreply.github.com> Co-authored-by: chungyau97 <chungyau97@gmail.com>
This commit is contained in:
@@ -63,6 +63,7 @@ import { buildAgentGraph } from './buildAgentGraph'
|
||||
import { getErrorMessage } from '../errors/utils'
|
||||
import { FLOWISE_METRIC_COUNTERS, FLOWISE_COUNTER_STATUS, IMetricsProvider } from '../Interface.Metrics'
|
||||
import { OMIT_QUEUE_JOB_DATA } from './constants'
|
||||
import { executeAgentFlow } from './buildAgentflow'
|
||||
|
||||
/*
|
||||
* Initialize the ending node to be executed
|
||||
@@ -236,7 +237,8 @@ export const executeFlow = async ({
|
||||
baseURL,
|
||||
isInternal,
|
||||
files,
|
||||
signal
|
||||
signal,
|
||||
isTool
|
||||
}: IExecuteFlowParams) => {
|
||||
// Ensure incomingInput has all required properties with default values
|
||||
incomingInput = {
|
||||
@@ -260,8 +262,8 @@ export const executeFlow = async ({
|
||||
*/
|
||||
let fileUploads: IFileUpload[] = []
|
||||
let uploadedFilesContent = ''
|
||||
if (incomingInput.uploads) {
|
||||
fileUploads = incomingInput.uploads
|
||||
if (uploads) {
|
||||
fileUploads = uploads
|
||||
for (let i = 0; i < fileUploads.length; i += 1) {
|
||||
const upload = fileUploads[i]
|
||||
|
||||
@@ -373,6 +375,26 @@ export const executeFlow = async ({
|
||||
}
|
||||
}
|
||||
|
||||
const isAgentFlowV2 = chatflow.type === 'AGENTFLOW'
|
||||
if (isAgentFlowV2) {
|
||||
return executeAgentFlow({
|
||||
componentNodes,
|
||||
incomingInput,
|
||||
chatflow,
|
||||
chatId,
|
||||
appDataSource,
|
||||
telemetry,
|
||||
cachePool,
|
||||
sseStreamer,
|
||||
baseURL,
|
||||
isInternal,
|
||||
uploadedFilesContent,
|
||||
fileUploads,
|
||||
signal,
|
||||
isTool
|
||||
})
|
||||
}
|
||||
|
||||
/*** Get chatflows and prepare data ***/
|
||||
const flowData = chatflow.flowData
|
||||
const parsedFlowData: IReactFlowObject = JSON.parse(flowData)
|
||||
@@ -498,7 +520,7 @@ export const executeFlow = async ({
|
||||
memoryType,
|
||||
sessionId,
|
||||
createdDate: userMessageDateTime,
|
||||
fileUploads: incomingInput.uploads ? JSON.stringify(fileUploads) : undefined,
|
||||
fileUploads: uploads ? JSON.stringify(fileUploads) : undefined,
|
||||
leadEmail: incomingInput.leadEmail
|
||||
}
|
||||
await utilAddChatMessage(userMessage, appDataSource)
|
||||
@@ -819,12 +841,14 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
|
||||
}
|
||||
|
||||
const isAgentFlow = chatflow.type === 'MULTIAGENT'
|
||||
|
||||
const httpProtocol = req.get('x-forwarded-proto') || req.protocol
|
||||
const baseURL = `${httpProtocol}://${req.get('host')}`
|
||||
const incomingInput: IncomingInput = req.body || {} // Ensure incomingInput is never undefined
|
||||
const chatId = incomingInput.chatId ?? incomingInput.overrideConfig?.sessionId ?? uuidv4()
|
||||
const files = (req.files as Express.Multer.File[]) || []
|
||||
const abortControllerId = `${chatflow.id}_${chatId}`
|
||||
const isTool = req.get('flowise-tool') === 'true'
|
||||
|
||||
try {
|
||||
// Validate API Key if its external API request
|
||||
@@ -846,7 +870,8 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
|
||||
sseStreamer: appServer.sseStreamer,
|
||||
telemetry: appServer.telemetry,
|
||||
cachePool: appServer.cachePool,
|
||||
componentNodes: appServer.nodesPool.componentNodes
|
||||
componentNodes: appServer.nodesPool.componentNodes,
|
||||
isTool // used to disable streaming if incoming request its from ChatflowTool
|
||||
}
|
||||
|
||||
if (process.env.MODE === MODE.QUEUE) {
|
||||
@@ -868,7 +893,6 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
|
||||
const signal = new AbortController()
|
||||
appServer.abortControllerPool.add(abortControllerId, signal)
|
||||
executeData.signal = signal
|
||||
|
||||
const result = await executeFlow(executeData)
|
||||
|
||||
appServer.abortControllerPool.remove(abortControllerId)
|
||||
|
||||
Reference in New Issue
Block a user