mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Added /continue "await" arg
This commit is contained in:
@ -329,6 +329,16 @@ export function initDefaultSlashCommands() {
|
|||||||
name: 'continue',
|
name: 'continue',
|
||||||
callback: continueChatCallback,
|
callback: continueChatCallback,
|
||||||
aliases: ['cont'],
|
aliases: ['cont'],
|
||||||
|
namedArgumentList: [
|
||||||
|
new SlashCommandNamedArgument(
|
||||||
|
'await',
|
||||||
|
'Whether to await for the continued generation before continuing',
|
||||||
|
[ARGUMENT_TYPE.BOOLEAN],
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
'false',
|
||||||
|
),
|
||||||
|
],
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
'prompt', [ARGUMENT_TYPE.STRING], false,
|
'prompt', [ARGUMENT_TYPE.STRING], false,
|
||||||
@ -338,6 +348,9 @@ export function initDefaultSlashCommands() {
|
|||||||
<div>
|
<div>
|
||||||
Continues the last message in the chat, with an optional additional prompt.
|
Continues the last message in the chat, with an optional additional prompt.
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
If <code>await=true</code> named argument is passed, the command will await for the continued generation before continuing.
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong>Example:</strong>
|
<strong>Example:</strong>
|
||||||
<ul>
|
<ul>
|
||||||
@ -2623,7 +2636,10 @@ async function openChat(id) {
|
|||||||
await reloadCurrentChat();
|
await reloadCurrentChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
function continueChatCallback(_, prompt) {
|
async function continueChatCallback(args, prompt) {
|
||||||
|
const shouldAwait = isTrueBoolean(args?.await);
|
||||||
|
|
||||||
|
const outerPromise = new Promise((resolve) => {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100);
|
await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100);
|
||||||
@ -2634,8 +2650,17 @@ function continueChatCallback(_, prompt) {
|
|||||||
|
|
||||||
// Prevent infinite recursion
|
// Prevent infinite recursion
|
||||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
|
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
$('#option_continue').trigger('click', { fromSlashCommand: true, additionalPrompt: prompt });
|
|
||||||
|
const options = prompt?.trim() ? { quiet_prompt: prompt.trim(), quietToLoud: true } : {};
|
||||||
|
await Generate('continue', options);
|
||||||
|
|
||||||
|
resolve();
|
||||||
}, 1);
|
}, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (shouldAwait) {
|
||||||
|
await outerPromise;
|
||||||
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user