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