From bab6028893a8412d5a9577c6350d7f83b7481ae7 Mon Sep 17 00:00:00 2001 From: Niek van der Maas Date: Wed, 8 Mar 2023 13:59:20 +0100 Subject: [PATCH] Strip whitespace --- src/lib/Chat.svelte | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/Chat.svelte b/src/lib/Chat.svelte index 9b7a275..9883c0c 100644 --- a/src/lib/Chat.svelte +++ b/src/lib/Chat.svelte @@ -189,6 +189,8 @@ } else { response.choices.map((choice) => { choice.message.usage = response.usage; + // Remove whitespace around the message that the OpenAI API sometimes returns + choice.message.content = choice.message.content.trim(); addMessage(chatId, choice.message); // Use TTS to read the response, if query was recorded if (recorded && "SpeechSynthesisUtterance" in window) {