mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Try to minimize side effects of generate dry running
This commit is contained in:
@ -2348,7 +2348,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hide swipes on either multigen or real streaming
|
// Hide swipes on either multigen or real streaming
|
||||||
if (isStreamingEnabled() || isMultigenEnabled()) {
|
if ((isStreamingEnabled() || isMultigenEnabled()) && !dryRun) {
|
||||||
hideSwipeButtons();
|
hideSwipeButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2411,7 +2411,10 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isContinue = type == 'continue';
|
const isContinue = type == 'continue';
|
||||||
|
|
||||||
|
if (!dryRun) {
|
||||||
deactivateSendButtons();
|
deactivateSendButtons();
|
||||||
|
}
|
||||||
|
|
||||||
let { messageBias, promptBias, isUserPromptBias } = getBiasStrings(textareaText, type);
|
let { messageBias, promptBias, isUserPromptBias } = getBiasStrings(textareaText, type);
|
||||||
|
|
||||||
@ -2637,7 +2640,10 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
|
|
||||||
let mesSend = [];
|
let mesSend = [];
|
||||||
console.debug('calling runGenerate');
|
console.debug('calling runGenerate');
|
||||||
|
|
||||||
|
if (!dryRun) {
|
||||||
streamingProcessor = isStreamingEnabled() ? new StreamingProcessor(type, force_name2) : false;
|
streamingProcessor = isStreamingEnabled() ? new StreamingProcessor(type, force_name2) : false;
|
||||||
|
}
|
||||||
|
|
||||||
if (isContinue) {
|
if (isContinue) {
|
||||||
// Coping mechanism for OAI spacing
|
// Coping mechanism for OAI spacing
|
||||||
@ -2657,7 +2663,9 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
runGenerate(cyclePrompt);
|
runGenerate(cyclePrompt);
|
||||||
|
|
||||||
async function runGenerate(cycleGenerationPromt = '') {
|
async function runGenerate(cycleGenerationPromt = '') {
|
||||||
|
if (!dryRun) {
|
||||||
is_send_press = true;
|
is_send_press = true;
|
||||||
|
}
|
||||||
|
|
||||||
generatedPromtCache += cycleGenerationPromt;
|
generatedPromtCache += cycleGenerationPromt;
|
||||||
if (generatedPromtCache.length == 0 || type === 'continue') {
|
if (generatedPromtCache.length == 0 || type === 'continue') {
|
||||||
@ -3010,6 +3018,12 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onSuccess(data) {
|
async function onSuccess(data) {
|
||||||
|
if (data.error == 'dryRun') {
|
||||||
|
generatedPromtCache = '';
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
hideStopButton();
|
hideStopButton();
|
||||||
is_send_press = false;
|
is_send_press = false;
|
||||||
if (!data.error) {
|
if (!data.error) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {callPopup, event_types, eventSource, main_api, saveSettingsDebounced, substituteParams} from "../script.js";
|
import {callPopup, event_types, eventSource, is_send_press, main_api, saveSettingsDebounced, substituteParams} from "../script.js";
|
||||||
import {TokenHandler} from "./openai.js";
|
import {TokenHandler} from "./openai.js";
|
||||||
import {power_user} from "./power-user.js";
|
import {power_user} from "./power-user.js";
|
||||||
import { debounce } from "./utils.js";
|
import { debounce, waitUntilCondition } from "./utils.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register migrations for the prompt manager when settings are loaded or an Open AI preset is loaded.
|
* Register migrations for the prompt manager when settings are loaded or an Open AI preset is loaded.
|
||||||
@ -596,6 +596,7 @@ PromptManagerModule.prototype.render = function (afterTryGenerate = true) {
|
|||||||
if (null === this.activeCharacter) return;
|
if (null === this.activeCharacter) return;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
|
|
||||||
|
waitUntilCondition(() => is_send_press == false, 1024 * 1024, 100).then(() => {
|
||||||
if (true === afterTryGenerate) {
|
if (true === afterTryGenerate) {
|
||||||
// Executed during dry-run for determining context composition
|
// Executed during dry-run for determining context composition
|
||||||
this.profileStart('filling context');
|
this.profileStart('filling context');
|
||||||
@ -615,6 +616,9 @@ PromptManagerModule.prototype.render = function (afterTryGenerate = true) {
|
|||||||
this.makeDraggable();
|
this.makeDraggable();
|
||||||
this.profileEnd('render');
|
this.profileEnd('render');
|
||||||
}
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
console.log('Timeout while waiting for send press to be false');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user