From 3892f0c82aad0d6587842253114fc9572a94de88 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Thu, 10 Oct 2024 02:59:18 -0700 Subject: [PATCH] Aix: rationalize non_abortable --- src/modules/aix/client/aix.client.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/aix/client/aix.client.ts b/src/modules/aix/client/aix.client.ts index 8c1beb0b7..c570b1ef6 100644 --- a/src/modules/aix/client/aix.client.ts +++ b/src/modules/aix/client/aix.client.ts @@ -71,7 +71,7 @@ type StreamMessageStatus = { interface AixClientOptions { - abortSignal: AbortSignal, + abortSignal: AbortSignal | 'NON_ABORTABLE'; // 'NON_ABORTABLE' is a special case for non-abortable operations throttleParallelThreads?: number; // 0: disable, 1: default throttle (12Hz), 2+ reduce frequency with the square root llmOptionsOverride?: Partial<{ llmTemperature: number, @@ -172,12 +172,12 @@ export async function aixChatGenerateTextNS_Simple( aixChatGenerate, aixContext, false, - { abortSignal: abortSignal }, + { abortSignal: abortSignal || 'NON_ABORTABLE' }, undefined, // no streaming ); // re-throw the user-initiated abort, as the former function catches it - if (abortSignal.aborted) + if (abortSignal?.aborted) throw new DOMException('Stopped.', 'AbortError'); const textContentFragments = (fragments || []).filter(f => isTextPart(f.part)); @@ -275,6 +275,13 @@ export async function aixChatGenerateContent_DMessage {