slightly change stream "abort" flow so token probabilities get successfully updated

This commit is contained in:
50h100a 2024-10-19 00:31:12 -04:00
parent 1ac6780e9c
commit 9f97a144e8
1 changed files with 9 additions and 5 deletions

View File

@ -3194,7 +3194,8 @@ class StreamingProcessor {
} }
onStopStreaming() { onStopStreaming() {
this.onErrorStreaming(); this.abortController.abort();
this.isFinished = true;
} }
/** /**
@ -3239,9 +3240,13 @@ class StreamingProcessor {
console.warn(`Stream stats: ${timestamps.length} tokens, ${seconds.toFixed(2)} seconds, rate: ${Number(timestamps.length / seconds).toFixed(2)} TPS`); console.warn(`Stream stats: ${timestamps.length} tokens, ${seconds.toFixed(2)} seconds, rate: ${Number(timestamps.length / seconds).toFixed(2)} TPS`);
} }
catch (err) { catch (err) {
console.error(err); // in the case of a self-inflicted abort, we have already cleaned up
this.onErrorStreaming(); if (!this.isFinished)
return; {
console.error(err);
this.onErrorStreaming();
}
return this.result;
} }
this.isFinished = true; this.isFinished = true;
@ -4641,7 +4646,6 @@ export function stopGeneration() {
let stopped = false; let stopped = false;
if (streamingProcessor) { if (streamingProcessor) {
streamingProcessor.onStopStreaming(); streamingProcessor.onStopStreaming();
streamingProcessor = null;
stopped = true; stopped = true;
} }
if (abortController) { if (abortController) {