Feature - Env variable to disable ChatFlow reuse (#2559)

This commit is contained in:
Daniel D'Abate
2024-06-04 11:11:57 +02:00
committed by GitHub
parent bdbb6f850a
commit 5ba9493b30
6 changed files with 10 additions and 0 deletions
@@ -187,6 +187,7 @@ export const utilBuildChatflow = async (req: Request, socketIO?: Server, isInter
const prependMessages = incomingInput.history
/* 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
* - Node Data already exists in pool
* - Still in sync (i.e the flow has not been modified since)
* - Existing overrideConfig and new overrideConfig are the same
@@ -194,6 +195,7 @@ export const utilBuildChatflow = async (req: Request, socketIO?: Server, isInter
***/
const isFlowReusable = () => {
return (
process.env.DISABLE_CHATFLOW_REUSE !== 'true' &&
Object.prototype.hasOwnProperty.call(appServer.chatflowPool.activeChatflows, chatflowid) &&
appServer.chatflowPool.activeChatflows[chatflowid].inSync &&
appServer.chatflowPool.activeChatflows[chatflowid].endingNodeData &&