add history chat timestamp in mongodb (#4296)

This commit is contained in:
Arif Romadhan 2025-04-15 01:39:37 +07:00 committed by GitHub
parent 54d1b5e3bb
commit 416e57380e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 2 deletions

View File

@ -155,7 +155,10 @@ class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
if (input) {
const newInputMessage = new HumanMessage(input.text)
const messageToAdd = [newInputMessage].map((msg) => msg.toDict())
const messageToAdd = [newInputMessage].map((msg) => ({
...msg.toDict(),
timestamp: new Date() // Add timestamp to the message
}))
await collection.updateOne(
{ sessionId: id },
{
@ -167,7 +170,10 @@ class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
if (output) {
const newOutputMessage = new AIMessage(output.text)
const messageToAdd = [newOutputMessage].map((msg) => msg.toDict())
const messageToAdd = [newOutputMessage].map((msg) => ({
...msg.toDict(),
timestamp: new Date() // Add timestamp to the message
}))
await collection.updateOne(
{ sessionId: id },
{