mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 09:01:06 +03:00
Merge pull request #1025 from FlowiseAI/bugfix/BufferMemory-ChatHistory
Bugfix/Redis Backed Memory fix
This commit is contained in:
@@ -95,9 +95,13 @@ class ConversationalAgent_Agents implements INode {
|
|||||||
const callbacks = await additionalCallbacks(nodeData, options)
|
const callbacks = await additionalCallbacks(nodeData, options)
|
||||||
|
|
||||||
if (options && options.chatHistory) {
|
if (options && options.chatHistory) {
|
||||||
|
const chatHistoryClassName = memory.chatHistory.constructor.name
|
||||||
|
// Only replace when its In-Memory
|
||||||
|
if (chatHistoryClassName && chatHistoryClassName === 'ChatMessageHistory') {
|
||||||
memory.chatHistory = mapChatHistory(options)
|
memory.chatHistory = mapChatHistory(options)
|
||||||
executor.memory = memory
|
executor.memory = memory
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const result = await executor.call({ input }, [...callbacks])
|
const result = await executor.call({ input }, [...callbacks])
|
||||||
return result?.output
|
return result?.output
|
||||||
|
|||||||
+4
@@ -82,8 +82,12 @@ class ConversationalRetrievalAgent_Agents implements INode {
|
|||||||
if (executor.memory) {
|
if (executor.memory) {
|
||||||
;(executor.memory as any).memoryKey = 'chat_history'
|
;(executor.memory as any).memoryKey = 'chat_history'
|
||||||
;(executor.memory as any).outputKey = 'output'
|
;(executor.memory as any).outputKey = 'output'
|
||||||
|
const chatHistoryClassName = (executor.memory as any).chatHistory.constructor.name
|
||||||
|
// Only replace when its In-Memory
|
||||||
|
if (chatHistoryClassName && chatHistoryClassName === 'ChatMessageHistory') {
|
||||||
;(executor.memory as any).chatHistory = mapChatHistory(options)
|
;(executor.memory as any).chatHistory = mapChatHistory(options)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
||||||
const callbacks = await additionalCallbacks(nodeData, options)
|
const callbacks = await additionalCallbacks(nodeData, options)
|
||||||
|
|||||||
@@ -81,9 +81,13 @@ class OpenAIFunctionAgent_Agents implements INode {
|
|||||||
const memory = nodeData.inputs?.memory as BaseChatMemory
|
const memory = nodeData.inputs?.memory as BaseChatMemory
|
||||||
|
|
||||||
if (options && options.chatHistory) {
|
if (options && options.chatHistory) {
|
||||||
|
const chatHistoryClassName = memory.chatHistory.constructor.name
|
||||||
|
// Only replace when its In-Memory
|
||||||
|
if (chatHistoryClassName && chatHistoryClassName === 'ChatMessageHistory') {
|
||||||
memory.chatHistory = mapChatHistory(options)
|
memory.chatHistory = mapChatHistory(options)
|
||||||
executor.memory = memory
|
executor.memory = memory
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
||||||
const callbacks = await additionalCallbacks(nodeData, options)
|
const callbacks = await additionalCallbacks(nodeData, options)
|
||||||
|
|||||||
@@ -106,9 +106,13 @@ class ConversationChain_Chains implements INode {
|
|||||||
const memory = nodeData.inputs?.memory as BufferMemory
|
const memory = nodeData.inputs?.memory as BufferMemory
|
||||||
|
|
||||||
if (options && options.chatHistory) {
|
if (options && options.chatHistory) {
|
||||||
|
const chatHistoryClassName = memory.chatHistory.constructor.name
|
||||||
|
// Only replace when its In-Memory
|
||||||
|
if (chatHistoryClassName && chatHistoryClassName === 'ChatMessageHistory') {
|
||||||
memory.chatHistory = mapChatHistory(options)
|
memory.chatHistory = mapChatHistory(options)
|
||||||
chain.memory = memory
|
chain.memory = memory
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
||||||
const callbacks = await additionalCallbacks(nodeData, options)
|
const callbacks = await additionalCallbacks(nodeData, options)
|
||||||
|
|||||||
+4
@@ -179,8 +179,12 @@ class ConversationalRetrievalQAChain_Chains implements INode {
|
|||||||
const obj = { question: input }
|
const obj = { question: input }
|
||||||
|
|
||||||
if (options && options.chatHistory && chain.memory) {
|
if (options && options.chatHistory && chain.memory) {
|
||||||
|
const chatHistoryClassName = (chain.memory as any).chatHistory.constructor.name
|
||||||
|
// Only replace when its In-Memory
|
||||||
|
if (chatHistoryClassName && chatHistoryClassName === 'ChatMessageHistory') {
|
||||||
;(chain.memory as any).chatHistory = mapChatHistory(options)
|
;(chain.memory as any).chatHistory = mapChatHistory(options)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
||||||
const callbacks = await additionalCallbacks(nodeData, options)
|
const callbacks = await additionalCallbacks(nodeData, options)
|
||||||
|
|||||||
Reference in New Issue
Block a user