From eda157e303067ebce6cf18aaeaf48d97a1566837 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 31 Mar 2024 21:02:29 -0700 Subject: [PATCH] fix: openai issue --- src/routes/(app)/+page.svelte | 10 +++++----- src/routes/(app)/c/[id]/+page.svelte | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index b2d2cbd4d..1580e365e 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -520,11 +520,6 @@ const sendPromptOpenAI = async (model, userPrompt, responseMessageId, _chatId) => { const responseMessage = history.messages[responseMessageId]; - // Wait until history/message have been updated - await tick(); - - scrollToBottom(); - const docs = messages .filter((message) => message?.files ?? null) .map((message) => @@ -593,6 +588,11 @@ : `${OPENAI_API_BASE_URL}` ); + // Wait until history/message have been updated + await tick(); + + scrollToBottom(); + if (res && res.ok) { const reader = res.body .pipeThrough(new TextDecoderStream()) diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 1a304f6d2..139fcd401 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -536,11 +536,6 @@ const sendPromptOpenAI = async (model, userPrompt, responseMessageId, _chatId) => { const responseMessage = history.messages[responseMessageId]; - // Wait until history/message have been updated - await tick(); - - scrollToBottom(); - const docs = messages .filter((message) => message?.files ?? null) .map((message) => @@ -607,6 +602,11 @@ : `${OPENAI_API_BASE_URL}` ); + // Wait until history/message have been updated + await tick(); + + scrollToBottom(); + if (res && res.ok) { const reader = res.body .pipeThrough(new TextDecoderStream())