#2267 Fix multiswipe mutating the array returning by the streaming provider

This commit is contained in:
Cohee
2024-05-19 16:38:18 +03:00
parent e9c5618b10
commit dd06fddd17

View File

@ -2889,6 +2889,9 @@ class StreamingProcessor {
this.onErrorStreaming(); this.onErrorStreaming();
} }
/**
* @returns {Generator<{ text: string, swipes: string[], logprobs: import('./scripts/logprobs.js').TokenLogprobs }, void, void>}
*/
*nullStreamingGeneration() { *nullStreamingGeneration() {
throw new Error('Generation function for streaming is not hooked up'); throw new Error('Generation function for streaming is not hooked up');
} }
@ -2916,7 +2919,7 @@ class StreamingProcessor {
} }
this.result = text; this.result = text;
this.swipes = swipes; this.swipes = Array.from(swipes ?? []);
if (logprobs) { if (logprobs) {
this.messageLogprobs.push(...(Array.isArray(logprobs) ? logprobs : [logprobs])); this.messageLogprobs.push(...(Array.isArray(logprobs) ? logprobs : [logprobs]));
} }