diff --git a/packages/gpt.gblib/services/ChatServices.ts b/packages/gpt.gblib/services/ChatServices.ts index d7a46627..954b2edf 100644 --- a/packages/gpt.gblib/services/ChatServices.ts +++ b/packages/gpt.gblib/services/ChatServices.ts @@ -264,15 +264,18 @@ export class ChatServices { const docsContext = min['vectorStore']; - const memory = new BufferWindowMemory({ - returnMessages: true, - memoryKey: 'chat_history', - inputKey: 'input', - k: 2 - }); - + let memory; if (user && !this.memoryMap[user.userSystemId]) { - this.memoryMap[user.userSystemId] = memory; + this.memoryMap[user.userSystemId] = new BufferWindowMemory({ + returnMessages: true, + memoryKey: 'chat_history', + inputKey: 'input', + k: 2 + }); + } + else + { + memory = this.memoryMap[user.userSystemId] } const systemPrompt = user ? this.userSystemPrompt[user.userSystemId] : '';