Skip to content

Commit 416e573

Browse files
add history chat timestamp in mongodb (#4296)
1 parent 54d1b5e commit 416e573

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/components/nodes/memory/MongoDBMemory/MongoDBMemory.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
155155

156156
if (input) {
157157
const newInputMessage = new HumanMessage(input.text)
158-
const messageToAdd = [newInputMessage].map((msg) => msg.toDict())
158+
const messageToAdd = [newInputMessage].map((msg) => ({
159+
...msg.toDict(),
160+
timestamp: new Date() // Add timestamp to the message
161+
}))
159162
await collection.updateOne(
160163
{ sessionId: id },
161164
{
@@ -167,7 +170,10 @@ class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
167170

168171
if (output) {
169172
const newOutputMessage = new AIMessage(output.text)
170-
const messageToAdd = [newOutputMessage].map((msg) => msg.toDict())
173+
const messageToAdd = [newOutputMessage].map((msg) => ({
174+
...msg.toDict(),
175+
timestamp: new Date() // Add timestamp to the message
176+
}))
171177
await collection.updateOne(
172178
{ sessionId: id },
173179
{

0 commit comments

Comments
 (0)