Preserve user input on tool call recursion (#5134) Supersedes #5129

9714374749b0bf1193f10af1b83695ab38147b7c

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
1 files changed, +5 -5Ignore whitespace
public/script.js+5 -5
@@ -4140,7 +4140,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
41404140 const isInstruct = power_user.instruct.enabled && main_api !== 'openai';
41414141 const isImpersonate = type == 'impersonate';
41424142
41434143 if (!(dryRun || depth || type == 'regenerate' || type == 'swipe' || type == 'quiet')) {
41444144 const interruptedByCommand = await processCommands(String($('#send_textarea').val()));
41454145
41464146 if (interruptedByCommand) {
@@ -4229,7 +4229,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
42294229 const lastMessage = chat[chat.length - 1];
42304230
42314231 let textareaText;
42324232 if (type !== 'regenerate' && type !== 'swipe' && type !== 'quiet' && !isImpersonate && !dryRun && !depth) {
42334233 is_send_press = true;
42344234 textareaText = String($('#send_textarea').val());
42354235 $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
@@ -4238,7 +4238,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
42384238 if (chat.length && lastMessage.is_user) {
42394239 //do nothing? why does this check exist?
42404240 }
42414241 else if (type !== 'quiet' && type !== 'swipe' && !isImpersonate && !dryRun && !depth && chat.length) {
42424242 deleteItemizedPromptForMessage(chat.length - 1);
42434243 chat.length = chat.length - 1;
42444244 await removeLastMessage();
@@ -4279,7 +4279,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
42794279 'continue',
42804280 ];
42814281 //for normal messages sent from user..
42824282 if ((textareaText != '' || (hasPendingFileAttachment() && !noAttachTypes.includes(type))) && !automatic_trigger && type !== 'quiet' && !dryRun && !depth) {
42834283 // If user message contains no text other than bias - send as a system message
42844284 if (messageBias && !removeMacros(textareaText)) {
42854285 sendSystemMessage(system_message_types.GENERIC, ' ', { bias: messageBias });
@@ -4288,7 +4288,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
42884288 await sendMessageAsUser(textareaText, messageBias);
42894289 }
42904290 }
42914291 else if (textareaText == '' && !automatic_trigger && !dryRun && [undefined, 'normal'].includes(type) && main_api == 'openai' && oai_settings.send_if_empty.trim().length > 0 && !depth) {
42924292 // Use send_if_empty if set and the user message is empty. Only when sending messages normally
42934293 await sendMessageAsUser(oai_settings.send_if_empty.trim(), messageBias);
42944294 }