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

9714374749b0bf1193f10af1b83695ab38147b7c

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

Signed
1 files changed, +5 -5Showing whitespace changes
public/script.js+5 -5
@@ -4140,7 +4140,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
4140 const isInstruct = power_user.instruct.enabled && main_api !== 'openai';4140 const isInstruct = power_user.instruct.enabled && main_api !== 'openai';
4141 const isImpersonate = type == 'impersonate';4141 const isImpersonate = type == 'impersonate';
41424142
4143 if (!(dryRun || type == 'regenerate' || type == 'swipe' || type == 'quiet')) {4143 if (!(dryRun || depth || type == 'regenerate' || type == 'swipe' || type == 'quiet')) {
4144 const interruptedByCommand = await processCommands(String($('#send_textarea').val()));4144 const interruptedByCommand = await processCommands(String($('#send_textarea').val()));
41454145
4146 if (interruptedByCommand) {4146 if (interruptedByCommand) {
@@ -4229,7 +4229,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
4229 const lastMessage = chat[chat.length - 1];4229 const lastMessage = chat[chat.length - 1];
42304230
4231 let textareaText;4231 let textareaText;
4232 if (type !== 'regenerate' && type !== 'swipe' && type !== 'quiet' && !isImpersonate && !dryRun) {4232 if (type !== 'regenerate' && type !== 'swipe' && type !== 'quiet' && !isImpersonate && !dryRun && !depth) {
4233 is_send_press = true;4233 is_send_press = true;
4234 textareaText = String($('#send_textarea').val());4234 textareaText = String($('#send_textarea').val());
4235 $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));4235 $('#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
4238 if (chat.length && lastMessage.is_user) {4238 if (chat.length && lastMessage.is_user) {
4239 //do nothing? why does this check exist?4239 //do nothing? why does this check exist?
4240 }4240 }
4241 else if (type !== 'quiet' && type !== 'swipe' && !isImpersonate && !dryRun && chat.length) {4241 else if (type !== 'quiet' && type !== 'swipe' && !isImpersonate && !dryRun && !depth && chat.length) {
4242 deleteItemizedPromptForMessage(chat.length - 1);4242 deleteItemizedPromptForMessage(chat.length - 1);
4243 chat.length = chat.length - 1;4243 chat.length = chat.length - 1;
4244 await removeLastMessage();4244 await removeLastMessage();
@@ -4279,7 +4279,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
4279 'continue',4279 'continue',
4280 ];4280 ];
4281 //for normal messages sent from user..4281 //for normal messages sent from user..
4282 if ((textareaText != '' || (hasPendingFileAttachment() && !noAttachTypes.includes(type))) && !automatic_trigger && type !== 'quiet' && !dryRun) {4282 if ((textareaText != '' || (hasPendingFileAttachment() && !noAttachTypes.includes(type))) && !automatic_trigger && type !== 'quiet' && !dryRun && !depth) {
4283 // If user message contains no text other than bias - send as a system message4283 // If user message contains no text other than bias - send as a system message
4284 if (messageBias && !removeMacros(textareaText)) {4284 if (messageBias && !removeMacros(textareaText)) {
4285 sendSystemMessage(system_message_types.GENERIC, ' ', { bias: messageBias });4285 sendSystemMessage(system_message_types.GENERIC, ' ', { bias: messageBias });
@@ -4288,7 +4288,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
4288 await sendMessageAsUser(textareaText, messageBias);4288 await sendMessageAsUser(textareaText, messageBias);
4289 }4289 }
4290 }4290 }
4291 else if (textareaText == '' && !automatic_trigger && !dryRun && [undefined, 'normal'].includes(type) && main_api == 'openai' && oai_settings.send_if_empty.trim().length > 0) {4291 else if (textareaText == '' && !automatic_trigger && !dryRun && [undefined, 'normal'].includes(type) && main_api == 'openai' && oai_settings.send_if_empty.trim().length > 0 && !depth) {
4292 // Use send_if_empty if set and the user message is empty. Only when sending messages normally4292 // Use send_if_empty if set and the user message is empty. Only when sending messages normally
4293 await sendMessageAsUser(oai_settings.send_if_empty.trim(), messageBias);4293 await sendMessageAsUser(oai_settings.send_if_empty.trim(), messageBias);
4294 }4294 }