Lift precondition check out of processCommands

Instead of passing type and dryRun into processCommands, do the check in
Generate, the only function that calls it. This makes the logic clearer.
This commit is contained in:
valadaptive
2023-12-23 05:24:31 -05:00
parent 47cb017a45
commit f53e051cbf

View File

@ -2354,11 +2354,7 @@ export async function generateQuietPrompt(quiet_prompt, quietToLoud, skipWIAN, q
return generateFinished; return generateFinished;
} }
async function processCommands(message, type, dryRun) { async function processCommands(message) {
if (dryRun || type == 'regenerate' || type == 'swipe' || type == 'quiet') {
return null;
}
const previousText = String($('#send_textarea').val()); const previousText = String($('#send_textarea').val());
const result = await executeSlashCommands(message); const result = await executeSlashCommands(message);
@ -2946,13 +2942,15 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
let message_already_generated = isImpersonate ? `${name1}: ` : `${name2}: `; let message_already_generated = isImpersonate ? `${name1}: ` : `${name2}: `;
const interruptedByCommand = await processCommands($('#send_textarea').val(), type, dryRun); if (!(dryRun || type == 'regenerate' || type == 'swipe' || type == 'quiet')) {
const interruptedByCommand = await processCommands($('#send_textarea').val());
if (interruptedByCommand) { if (interruptedByCommand) {
//$("#send_textarea").val('').trigger('input'); //$("#send_textarea").val('').trigger('input');
unblockGeneration(); unblockGeneration();
return Promise.resolve(); return Promise.resolve();
} }
}
if (main_api == 'kobold' && kai_settings.streaming_kobold && !kai_flags.can_use_streaming) { if (main_api == 'kobold' && kai_settings.streaming_kobold && !kai_flags.can_use_streaming) {
toastr.error('Streaming is enabled, but the version of Kobold used does not support token streaming.', undefined, { timeOut: 10000, preventDuplicates: true }); toastr.error('Streaming is enabled, but the version of Kobold used does not support token streaming.', undefined, { timeOut: 10000, preventDuplicates: true });