From bc1a7ab56736d1dc6b54fc02d1f27c4157e82fe1 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 9 Jun 2024 17:38:08 -0700 Subject: [PATCH] fix: playground --- .../components/workspace/Playground.svelte | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/lib/components/workspace/Playground.svelte b/src/lib/components/workspace/Playground.svelte index b7453e3f3..e99014cab 100644 --- a/src/lib/components/workspace/Playground.svelte +++ b/src/lib/components/workspace/Playground.svelte @@ -80,8 +80,6 @@ if (stopResponseFlag) { controller.abort('User: Stop Response'); } - - currentRequestId = null; break; } @@ -97,11 +95,7 @@ let data = JSON.parse(line.replace(/^data: /, '')); console.log(data); - if ('request_id' in data) { - currentRequestId = data.request_id; - } else { - text += data.choices[0].delta.content ?? ''; - } + text += data.choices[0].delta.content ?? ''; } } } @@ -178,21 +172,17 @@ let data = JSON.parse(line.replace(/^data: /, '')); console.log(data); - if ('request_id' in data) { - currentRequestId = data.request_id; + if (responseMessage.content == '' && data.choices[0].delta.content == '\n') { + continue; } else { - if (responseMessage.content == '' && data.choices[0].delta.content == '\n') { - continue; - } else { - textareaElement.style.height = textareaElement.scrollHeight + 'px'; + textareaElement.style.height = textareaElement.scrollHeight + 'px'; - responseMessage.content += data.choices[0].delta.content ?? ''; - messages = messages; + responseMessage.content += data.choices[0].delta.content ?? ''; + messages = messages; - textareaElement.style.height = textareaElement.scrollHeight + 'px'; + textareaElement.style.height = textareaElement.scrollHeight + 'px'; - await tick(); - } + await tick(); } } }