Strip whitespace

This commit is contained in:
Niek van der Maas 2023-03-08 13:59:20 +01:00
parent 77344ef691
commit bab6028893
1 changed files with 2 additions and 0 deletions

View File

@ -189,6 +189,8 @@
} else { } else {
response.choices.map((choice) => { response.choices.map((choice) => {
choice.message.usage = response.usage; 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); addMessage(chatId, choice.message);
// Use TTS to read the response, if query was recorded // Use TTS to read the response, if query was recorded
if (recorded && "SpeechSynthesisUtterance" in window) { if (recorded && "SpeechSynthesisUtterance" in window) {