Added /continue "await" arg
This commit is contained in:
parent
79069b49b8
commit
aad65c9273
|
@ -329,6 +329,16 @@ export function initDefaultSlashCommands() {
|
|||
name: 'continue',
|
||||
callback: continueChatCallback,
|
||||
aliases: ['cont'],
|
||||
namedArgumentList: [
|
||||
new SlashCommandNamedArgument(
|
||||
'await',
|
||||
'Whether to await for the continued generation before continuing',
|
||||
[ARGUMENT_TYPE.BOOLEAN],
|
||||
false,
|
||||
false,
|
||||
'false',
|
||||
),
|
||||
],
|
||||
unnamedArgumentList: [
|
||||
new SlashCommandArgument(
|
||||
'prompt', [ARGUMENT_TYPE.STRING], false,
|
||||
|
@ -338,6 +348,9 @@ export function initDefaultSlashCommands() {
|
|||
<div>
|
||||
Continues the last message in the chat, with an optional additional prompt.
|
||||
</div>
|
||||
<div>
|
||||
If <code>await=true</code> named argument is passed, the command will await for the continued generation before continuing.
|
||||
</div>
|
||||
<div>
|
||||
<strong>Example:</strong>
|
||||
<ul>
|
||||
|
@ -2623,7 +2636,10 @@ async function openChat(id) {
|
|||
await reloadCurrentChat();
|
||||
}
|
||||
|
||||
function continueChatCallback(_, prompt) {
|
||||
async function continueChatCallback(args, prompt) {
|
||||
const shouldAwait = isTrueBoolean(args?.await);
|
||||
|
||||
const outerPromise = new Promise((resolve) => {
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100);
|
||||
|
@ -2634,8 +2650,17 @@ function continueChatCallback(_, prompt) {
|
|||
|
||||
// Prevent infinite recursion
|
||||
$('#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);
|
||||
});
|
||||
|
||||
if (shouldAwait) {
|
||||
await outerPromise;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue