Impersonate with `last_input_sequence` (#5456)
Signed| @@ -4387,7 +4387,7 @@ | |||
| 4387 | <small data-i18n="First User Prefix">First User Prefix</small> | 4387 | <small data-i18n="First User Prefix">First User Prefix</small> |
| 4388 | <textarea id="instruct_first_input_sequence" data-macros class="text_pole textarea_compact autoSetHeight"></textarea> | 4388 | <textarea id="instruct_first_input_sequence" data-macros class="text_pole textarea_compact autoSetHeight"></textarea> |
| 4389 | </div> | 4389 | </div> |
| 4390 | <div class="flexAuto" title="Inserted before the last User's message." data-i18n="[title]instruct_last_input_sequence"> | 4390 | <div class="flexAuto" title="Inserted before the last User's message or as a last prompt line when generating an impersonation." data-i18n="[title]instruct_last_input_sequence"> |
| 4391 | <small data-i18n="Last User Prefix">Last User Prefix</small> | 4391 | <small data-i18n="Last User Prefix">Last User Prefix</small> |
| 4392 | <textarea id="instruct_last_input_sequence" data-macros class="text_pole wide100p textarea_compact autoSetHeight"></textarea> | 4392 | <textarea id="instruct_last_input_sequence" data-macros class="text_pole wide100p textarea_compact autoSetHeight"></textarea> |
| 4393 | </div> | 4393 | </div> |
| @@ -4718,7 +4718,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | |||
| 4718 | chat2[i] = formatMessageHistoryItem(coreChat[j], isInstruct, force_output_sequence.FIRST); | 4718 | chat2[i] = formatMessageHistoryItem(coreChat[j], isInstruct, force_output_sequence.FIRST); |
| 4719 | } | 4719 | } |
| 4720 | 4720 | ||
| 4721 | if (lastUserMessageIndex >= 0 && j === lastUserMessageIndex && isInstruct) { | 4721 | if (lastUserMessageIndex >= 0 && j === lastUserMessageIndex && isInstruct && !isImpersonate) { |
| 4722 | // Reformat with the last input sequence (if any) | 4722 | // Reformat with the last input sequence (if any) |
| 4723 | chat2[i] = formatMessageHistoryItem(coreChat[j], isInstruct, force_output_sequence.LAST); | 4723 | chat2[i] = formatMessageHistoryItem(coreChat[j], isInstruct, force_output_sequence.LAST); |
| 4724 | } | 4724 | } |
| @@ -597,7 +597,7 @@ export function formatInstructModePrompt(name, isImpersonate, promptBias, name1, | |||
| 597 | function getSequence() { | 597 | function getSequence() { |
| 598 | // User impersonation prompt | 598 | // User impersonation prompt |
| 599 | if (isImpersonate) { | 599 | if (isImpersonate) { |
| 600 | return instruct.input_sequence; | 600 | return instruct.last_input_sequence || instruct.input_sequence; |
| 601 | } | 601 | } |
| 602 | 602 | ||
| 603 | // Neutral / system / quiet prompt | 603 | // Neutral / system / quiet prompt |