mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-02 19:07:40 +01:00
Wait for generation unlock before running continue or trigger
This commit is contained in:
parent
a06f1e8ad6
commit
a28c23d295
@ -4335,6 +4335,10 @@ function extractMessageFromData(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanUpMessage(getMessage, isImpersonate, isContinue, displayIncompleteSentences = false) {
|
function cleanUpMessage(getMessage, isImpersonate, isContinue, displayIncompleteSentences = false) {
|
||||||
|
if (!getMessage) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
// Add the prompt bias before anything else
|
// Add the prompt bias before anything else
|
||||||
if (
|
if (
|
||||||
power_user.user_prompt_bias &&
|
power_user.user_prompt_bias &&
|
||||||
|
@ -40,7 +40,7 @@ import { addEphemeralStoppingString, chat_styles, flushEphemeralStoppingStrings,
|
|||||||
import { autoSelectPersona } from "./personas.js";
|
import { autoSelectPersona } from "./personas.js";
|
||||||
import { getContext, saveMetadataDebounced } from "./extensions.js";
|
import { getContext, saveMetadataDebounced } from "./extensions.js";
|
||||||
import { hideChatMessage, unhideChatMessage } from "./chats.js";
|
import { hideChatMessage, unhideChatMessage } from "./chats.js";
|
||||||
import { delay, isFalseBoolean, isTrueBoolean, stringToRange, trimToEndSentence, trimToStartSentence } from "./utils.js";
|
import { delay, isFalseBoolean, isTrueBoolean, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from "./utils.js";
|
||||||
import { registerVariableCommands, resolveVariable } from "./variables.js";
|
import { registerVariableCommands, resolveVariable } from "./variables.js";
|
||||||
import { decodeTextTokens, getFriendlyTokenizerName, getTextTokens, getTokenCount } from "./tokenizers.js";
|
import { decodeTextTokens, getFriendlyTokenizerName, getTextTokens, getTokenCount } from "./tokenizers.js";
|
||||||
export {
|
export {
|
||||||
@ -971,8 +971,11 @@ async function addGroupMemberCallback(_, arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function triggerGenerationCallback(_, arg) {
|
async function triggerGenerationCallback(_, arg) {
|
||||||
if (is_send_press || is_group_generating) {
|
try {
|
||||||
toastr.warning("Cannot run trigger command while the reply is being generated.");
|
await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100);
|
||||||
|
} catch {
|
||||||
|
console.warn('Timeout waiting for generation unlock');
|
||||||
|
toastr.warning("Cannot run /trigger command while the reply is being generated.");
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1083,10 +1086,19 @@ async function openChat(id) {
|
|||||||
await reloadCurrentChat();
|
await reloadCurrentChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
function continueChatCallback() {
|
async function continueChatCallback() {
|
||||||
|
try {
|
||||||
|
await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100);
|
||||||
|
} catch {
|
||||||
|
console.warn('Timeout waiting for generation unlock');
|
||||||
|
toastr.warning("Cannot run /continue command while the reply is being generated.");
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent infinite recursion
|
// Prevent infinite recursion
|
||||||
$('#send_textarea').val('').trigger('input');
|
$('#send_textarea').val('').trigger('input');
|
||||||
$('#option_continue').trigger('click', { fromSlashCommand: true });
|
$('#option_continue').trigger('click', { fromSlashCommand: true });
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function generateSystemMessage(_, prompt) {
|
export async function generateSystemMessage(_, prompt) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user