Added /continue "await" arg
| @@ -329,6 +329,16 @@ export function initDefaultSlashCommands() { | |||
| 329 | name: 'continue', | 329 | name: 'continue', |
| 330 | callback: continueChatCallback, | 330 | callback: continueChatCallback, |
| 331 | aliases: ['cont'], | 331 | aliases: ['cont'], |
| 332 | namedArgumentList: [ | ||
| 333 | new SlashCommandNamedArgument( | ||
| 334 | 'await', | ||
| 335 | 'Whether to await for the continued generation before continuing', | ||
| 336 | [ARGUMENT_TYPE.BOOLEAN], | ||
| 337 | false, | ||
| 338 | false, | ||
| 339 | 'false', | ||
| 340 | ), | ||
| 341 | ], | ||
| 332 | unnamedArgumentList: [ | 342 | unnamedArgumentList: [ |
| 333 | new SlashCommandArgument( | 343 | new SlashCommandArgument( |
| 334 | 'prompt', [ARGUMENT_TYPE.STRING], false, | 344 | 'prompt', [ARGUMENT_TYPE.STRING], false, |
| @@ -339,6 +349,9 @@ export function initDefaultSlashCommands() { | |||
| 339 | Continues the last message in the chat, with an optional additional prompt. | 349 | Continues the last message in the chat, with an optional additional prompt. |
| 340 | </div> | 350 | </div> |
| 341 | <div> | 351 | <div> |
| 352 | If <code>await=true</code> named argument is passed, the command will await for the continued generation before continuing. | ||
| 353 | </div> | ||
| 354 | <div> | ||
| 342 | <strong>Example:</strong> | 355 | <strong>Example:</strong> |
| 343 | <ul> | 356 | <ul> |
| 344 | <li> | 357 | <li> |
| @@ -2623,7 +2636,10 @@ async function openChat(id) { | |||
| 2623 | await reloadCurrentChat(); | 2636 | await reloadCurrentChat(); |
| 2624 | } | 2637 | } |
| 2625 | 2638 | ||
| 2626 | function continueChatCallback(_, prompt) { | 2639 | async function continueChatCallback(args, prompt) { |
| 2640 | const shouldAwait = isTrueBoolean(args?.await); | ||
| 2641 | |||
| 2642 | const outerPromise = new Promise((resolve) => { | ||
| 2627 | setTimeout(async () => { | 2643 | setTimeout(async () => { |
| 2628 | try { | 2644 | try { |
| 2629 | await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100); | 2645 | await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100); |
| @@ -2634,8 +2650,17 @@ function continueChatCallback(_, prompt) { | |||
| 2634 | 2650 | ||
| 2635 | // Prevent infinite recursion | 2651 | // Prevent infinite recursion |
| 2636 | $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true })); | 2652 | $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true })); |
| 2637 | $('#option_continue').trigger('click', { fromSlashCommand: true, additionalPrompt: prompt }); | 2653 | |
| 2654 | const options = prompt?.trim() ? { quiet_prompt: prompt.trim(), quietToLoud: true } : {}; | ||
| 2655 | await Generate('continue', options); | ||
| 2656 | |||
| 2657 | resolve(); | ||
| 2638 | }, 1); | 2658 | }, 1); |
| 2659 | }); | ||
| 2660 | |||
| 2661 | if (shouldAwait) { | ||
| 2662 | await outerPromise; | ||
| 2663 | } | ||
| 2639 | 2664 | ||
| 2640 | return ''; | 2665 | return ''; |
| 2641 | } | 2666 | } |