Bugfix/pass execute custom function to worker (#4432)

pass execute custom function to worker
This commit is contained in:
Henry Heng
2025-05-16 01:13:25 +08:00
committed by GitHub
parent a6e64230b4
commit 0a4570ecda
3 changed files with 95 additions and 43 deletions
+11 -1
View File
@@ -10,6 +10,7 @@ import { RedisOptions } from 'bullmq'
import logger from '../utils/logger'
import { generateAgentflowv2 as generateAgentflowv2_json } from 'flowise-components'
import { databaseEntities } from '../utils'
import { executeCustomNodeFunction } from '../utils/executeCustomNodeFunction'
interface PredictionQueueOptions {
appDataSource: DataSource
@@ -65,7 +66,7 @@ export class PredictionQueue extends BaseQueue {
if (this.redisPublisher) data.sseStreamer = this.redisPublisher
if (Object.prototype.hasOwnProperty.call(data, 'isAgentFlowGenerator')) {
logger.info('Generating Agentflow...')
logger.info(`Generating Agentflow...`)
const { prompt, componentNodes, toolNodes, selectedChatModel, question } = data as IGenerateAgentflowv2Params
const options: Record<string, any> = {
appDataSource: this.appDataSource,
@@ -75,6 +76,15 @@ export class PredictionQueue extends BaseQueue {
return await generateAgentflowv2_json({ prompt, componentNodes, toolNodes, selectedChatModel }, question, options)
}
if (Object.prototype.hasOwnProperty.call(data, 'isExecuteCustomFunction')) {
logger.info(`Executing Custom Function...`)
return await executeCustomNodeFunction({
appDataSource: this.appDataSource,
componentNodes: this.componentNodes,
data
})
}
if (this.abortControllerPool) {
const abortControllerId = `${data.chatflow.id}_${data.chatId}`
const signal = new AbortController()