Selaa lähdekoodia

Merge pull request #4329 from cheahjs/fix/missing-openai-usage-info

fix: missing openai usage information
Timothy Jaeryang Baek 9 kuukautta sitten
vanhempi
commit
a75a9c953a
1 muutettua tiedostoa jossa 1 lisäystä ja 6 poistoa
  1. 1 6
      src/lib/components/chat/Chat.svelte

+ 1 - 6
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, {