From bcc2bab623496f03468fb2d9ce41fb0b0870363e Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 19 May 2024 13:15:41 -0700 Subject: [PATCH] refac --- src/routes/(app)/+page.svelte | 6 ++---- src/routes/(app)/c/[id]/+page.svelte | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index d5642c926..6b929795f 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -255,8 +255,6 @@ const sendPrompt = async (prompt, parentId, modelId = null) => { const _chatId = JSON.parse(JSON.stringify($chatId)); - let userContext = null; - await Promise.all( (modelId ? [modelId] : atSelectedModel !== '' ? [atSelectedModel.id] : selectedModels).map( async (modelId) => { @@ -273,7 +271,7 @@ role: 'assistant', content: '', model: model.id, - userContext: userContext, + userContext: null, timestamp: Math.floor(Date.now() / 1000) // Unix epoch }; @@ -291,6 +289,7 @@ await tick(); + let userContext = null; if ($settings?.memory ?? false) { if (userContext === null) { const res = await queryMemory(localStorage.token, prompt).catch((error) => { @@ -314,7 +313,6 @@ } } } - responseMessage.userContext = userContext; if (model?.external) { diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 8088a4bb0..8bf3b6d54 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -261,8 +261,6 @@ const sendPrompt = async (prompt, parentId, modelId = null) => { const _chatId = JSON.parse(JSON.stringify($chatId)); - let userContext = null; - await Promise.all( (modelId ? [modelId] : atSelectedModel !== '' ? [atSelectedModel.id] : selectedModels).map( async (modelId) => { @@ -279,7 +277,7 @@ role: 'assistant', content: '', model: model.id, - userContext: userContext, + userContext: null, timestamp: Math.floor(Date.now() / 1000) // Unix epoch }; @@ -297,6 +295,7 @@ await tick(); + let userContext = null; if ($settings?.memory ?? false) { if (userContext === null) { const res = await queryMemory(localStorage.token, prompt).catch((error) => { @@ -320,7 +319,6 @@ } } } - responseMessage.userContext = userContext; if (model?.external) {