From d54fe31d55a6b6e2a0e3a55d8737b34cb3db5df0 Mon Sep 17 00:00:00 2001 From: Glauber Brack Date: Wed, 4 Dec 2024 22:23:49 -0300 Subject: [PATCH] feat(redis): dont add chat messages --- .../RedisBackedChatMemory.ts | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/components/nodes/memory/RedisBackedChatMemory/RedisBackedChatMemory.ts b/packages/components/nodes/memory/RedisBackedChatMemory/RedisBackedChatMemory.ts index c60b9431fb2..82d80bb3591 100644 --- a/packages/components/nodes/memory/RedisBackedChatMemory/RedisBackedChatMemory.ts +++ b/packages/components/nodes/memory/RedisBackedChatMemory/RedisBackedChatMemory.ts @@ -158,25 +158,25 @@ class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods { } async addChatMessages(msgArray: { text: string; type: MessageType }[], overrideSessionId = ''): Promise { - await this.withRedisClient(async (client) => { - const id = overrideSessionId ? overrideSessionId : this.sessionId - const input = msgArray.find((msg) => msg.type === 'userMessage') - const output = msgArray.find((msg) => msg.type === 'apiMessage') - - if (input) { - const newInputMessage = new HumanMessage(input.text) - const messageToAdd = [newInputMessage].map((msg) => msg.toDict()) - await client.lpush(id, JSON.stringify(messageToAdd[0])) - if (this.sessionTTL) await client.expire(id, this.sessionTTL) - } - - if (output) { - const newOutputMessage = new AIMessage(output.text) - const messageToAdd = [newOutputMessage].map((msg) => msg.toDict()) - await client.lpush(id, JSON.stringify(messageToAdd[0])) - if (this.sessionTTL) await client.expire(id, this.sessionTTL) - } - }) + // await this.withRedisClient(async (client) => { + // const id = overrideSessionId ? overrideSessionId : this.sessionId + // const input = msgArray.find((msg) => msg.type === 'userMessage') + // const output = msgArray.find((msg) => msg.type === 'apiMessage') + + // if (input) { + // const newInputMessage = new HumanMessage(input.text) + // const messageToAdd = [newInputMessage].map((msg) => msg.toDict()) + // await client.lpush(id, JSON.stringify(messageToAdd[0])) + // if (this.sessionTTL) await client.expire(id, this.sessionTTL) + // } + + // if (output) { + // const newOutputMessage = new AIMessage(output.text) + // const messageToAdd = [newOutputMessage].map((msg) => msg.toDict()) + // await client.lpush(id, JSON.stringify(messageToAdd[0])) + // if (this.sessionTTL) await client.expire(id, this.sessionTTL) + // } + // }) } async clearChatMessages(overrideSessionId = ''): Promise {