From 57175b422969e878d378c7c40dd7bf49b6340c37 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 6 Jul 2024 17:39:50 +0300 Subject: [PATCH] Don't send streaming request if generation was aborted before the streaming processor creation --- public/script.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/script.js b/public/script.js index be58c5922..cf6b4ebd9 100644 --- a/public/script.js +++ b/public/script.js @@ -5020,6 +5020,10 @@ async function sendGenerationRequest(type, data) { * @returns {Promise} Streaming generator */ async function sendStreamingRequest(type, data) { + if (abortController?.signal?.aborted) { + throw new Error('Generation was aborted.'); + } + switch (main_api) { case 'openai': return await sendOpenAIRequest(type, data.prompt, streamingProcessor.abortController.signal);