Fix oobabooga streaming multigen

This commit is contained in:
SillyLossy
2023-04-12 20:11:37 +03:00
parent 886d1f26a1
commit caff1a62c4

View File

@ -1169,6 +1169,7 @@ class StreamingProcessor {
showSwipeButtons(); showSwipeButtons();
setGenerationProgress(0); setGenerationProgress(0);
$('.mes_edit:last').show(); $('.mes_edit:last').show();
generatedPromtCache = '';
} }
onErrorStreaming() { onErrorStreaming() {
@ -1189,6 +1190,7 @@ class StreamingProcessor {
constructor(type, force_name2) { constructor(type, force_name2) {
this.result = ""; this.result = "";
this.prefix = "";
this.messageId = -1; this.messageId = -1;
this.type = type; this.type = type;
this.force_name2 = force_name2; this.force_name2 = force_name2;
@ -1202,6 +1204,11 @@ class StreamingProcessor {
this.messageId = this.onStartStreaming('...'); this.messageId = this.onStartStreaming('...');
} }
// for multigen
if (this.result.length) {
this.prefix = this.result;
}
for await (const text of this.generator()) { for await (const text of this.generator()) {
if (this.isStopped) { if (this.isStopped) {
this.onStopStreaming(); this.onStopStreaming();
@ -1209,8 +1216,8 @@ class StreamingProcessor {
} }
try { try {
this.result = text; this.result = this.prefix + text;
this.onProgressStreaming(this.messageId, text); this.onProgressStreaming(this.messageId, this.result);
} }
catch (err) { catch (err) {
console.error(err); console.error(err);
@ -1221,7 +1228,6 @@ class StreamingProcessor {
} }
this.isFinished = true; this.isFinished = true;
this.onFinishStreaming(this.messageId, this.result);
return this.result; return this.result;
} }
} }
@ -1873,6 +1879,7 @@ async function Generate(type, automatic_trigger, force_name2) {
let getMessage = await streamingProcessor.generate(); let getMessage = await streamingProcessor.generate();
if (isMultigenEnabled()) { if (isMultigenEnabled()) {
tokens_already_generated += this_amount_gen; // add new gen amt to any prev gen counter..
message_already_generated += getMessage; message_already_generated += getMessage;
promptBias = ''; promptBias = '';
if (!streamingProcessor.isStopped && shouldContinueMultigen(getMessage)) { if (!streamingProcessor.isStopped && shouldContinueMultigen(getMessage)) {
@ -1883,6 +1890,7 @@ async function Generate(type, automatic_trigger, force_name2) {
} }
} }
streamingProcessor.onFinishStreaming(streamingProcessor.messageId, getMessage);
streamingProcessor = null; streamingProcessor = null;
} }