Bugfix/Buffer Memory for Anthropic (#3242)

fix buffer memory
This commit is contained in:
Henry Heng
2024-09-24 15:19:08 +01:00
committed by GitHub
parent 7d88183eca
commit a6a0398074
3 changed files with 22 additions and 8 deletions
@@ -118,14 +118,16 @@ class BufferWindowMemoryExtended extends FlowiseWindowMemory implements MemoryMe
sessionId: id,
chatflowid: this.chatflowid
},
take: this.k + 1,
order: {
createdDate: 'DESC' // we get the latest top K
createdDate: 'ASC'
}
})
// reverse the order of human and ai messages
if (chatMessage.length) chatMessage.reverse()
if (this.k <= 0) {
chatMessage = []
} else {
chatMessage = chatMessage.slice(-this.k * 2)
}
if (prependMessages?.length) {
chatMessage.unshift(...prependMessages)