Don't send streaming request if generation was aborted before the streaming processor creation

57175b422969e878d378c7c40dd7bf49b6340c37

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +4 -0Ignore whitespace
public/script.js+4 -0
@@ -5020,6 +5020,10 @@ async function sendGenerationRequest(type, data) {
5020 * @returns {Promise<any>} Streaming generator5020 * @returns {Promise<any>} Streaming generator
5021 */5021 */
5022async function sendStreamingRequest(type, data) {5022async function sendStreamingRequest(type, data) {
5023 if (abortController?.signal?.aborted) {
5024 throw new Error('Generation was aborted.');
5025 }
5026
5023 switch (main_api) {5027 switch (main_api) {
5024 case 'openai':5028 case 'openai':
5025 return await sendOpenAIRequest(type, data.prompt, streamingProcessor.abortController.signal);5029 return await sendOpenAIRequest(type, data.prompt, streamingProcessor.abortController.signal);