From 283234d51da8729274017442584d1c7800076c8f Mon Sep 17 00:00:00 2001 From: Jun Siang Cheah Date: Sat, 3 Aug 2024 19:06:19 +0100 Subject: [PATCH] fix: missing openai usage information --- src/lib/components/chat/Chat.svelte | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 78a22010e..a8e42279a 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -1128,7 +1128,6 @@ if (res && res.ok && res.body) { const textStream = await createOpenAITextStream(res.body, $settings.splitLargeChunks); - let lastUsage = null; for await (const update of textStream) { const { value, done, citations, error, usage } = update; @@ -1154,7 +1153,7 @@ } if (usage) { - lastUsage = usage; + responseMessage.info = { ...usage, openai: true }; } if (citations) { @@ -1208,10 +1207,6 @@ document.getElementById(`speak-button-${responseMessage.id}`)?.click(); } - if (lastUsage) { - responseMessage.info = { ...lastUsage, openai: true }; - } - if ($chatId == _chatId) { if ($settings.saveChatHistory ?? true) { chat = await updateChatById(localStorage.token, _chatId, {