Fix instruct macros not using a proper enabled field

8c3ac0ac5a48c28e32014745218462ea06795a03

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

1 files changed, +101 -24Ignore whitespace
public/scripts/instruct-mode.js+101 -24
@@ -570,36 +570,113 @@ function selectMatchingContextTemplate(name) {
570570 * @returns {import('./macros.js').Macro[]} Macro objects.
571571 */
572572export function getInstructMacros(env) {
573- const instructMacros = {
573+ /** @type {{ key: string,value: string, enabled: boolean }[]} */
574+ const instructMacros = [
574575 // Instruct template macros
575- 'instructSystemPromptPrefix': power_user.instruct.system_sequence_prefix,
576+ {
576- 'instructSystemPromptSuffix': power_user.instruct.system_sequence_suffix,
577+ key: 'instructSystemPromptPrefix',
577578 'instructInput|instructUserPrefix' value: power_user.instruct.input_sequencesystem_sequence_prefix,
578579 'instructUserSuffix' enabled: power_user.instruct.input_suffixenabled,
579- 'instructOutput|instructAssistantPrefix': power_user.instruct.output_sequence,
580+ },
580- 'instructSeparator|instructAssistantSuffix': power_user.instruct.output_suffix,
581+ {
581- 'instructSystemPrefix': power_user.instruct.system_sequence,
582+ key: 'instructSystemPromptSuffix',
582583 'instructSystemSuffix' value: power_user.instruct.system_suffixsystem_sequence_suffix,
583- 'instructFirstOutput|instructFirstAssistantPrefix': power_user.instruct.first_output_sequence || power_user.instruct.output_sequence,
584+ enabled: power_user.instruct.enabled,
584- 'instructLastOutput|instructLastAssistantPrefix': power_user.instruct.last_output_sequence || power_user.instruct.output_sequence,
585+ },
585- 'instructStop': power_user.instruct.stop_sequence,
586+ {
586- 'instructUserFiller': power_user.instruct.user_alignment_message,
587+ key: 'instructInput|instructUserPrefix',
587588 'instructSystemInstructionPrefix' value: power_user.instruct.last_system_sequenceinput_sequence,
588- 'instructFirstInput|instructFirstUserPrefix': power_user.instruct.first_input_sequence || power_user.instruct.input_sequence,
589+ enabled: power_user.instruct.enabled,
589- 'instructLastInput|instructLastUserPrefix': power_user.instruct.last_input_sequence || power_user.instruct.input_sequence,
590+ },
591+ {
592+ key: 'instructUserSuffix',
593+ value: power_user.instruct.input_suffix,
594+ enabled: power_user.instruct.enabled,
595+ },
596+ {
597+ key: 'instructOutput|instructAssistantPrefix',
598+ value: power_user.instruct.output_sequence,
599+ enabled: power_user.instruct.enabled,
600+ },
601+ {
602+ key: 'instructSeparator|instructAssistantSuffix',
603+ value: power_user.instruct.output_suffix,
604+ enabled: power_user.instruct.enabled,
605+ },
606+ {
607+ key: 'instructSystemPrefix',
608+ value: power_user.instruct.system_sequence,
609+ enabled: power_user.instruct.enabled,
610+ },
611+ {
612+ key: 'instructSystemSuffix',
613+ value: power_user.instruct.system_suffix,
614+ enabled: power_user.instruct.enabled,
615+ },
616+ {
617+ key: 'instructFirstOutput|instructFirstAssistantPrefix',
618+ value: power_user.instruct.first_output_sequence || power_user.instruct.output_sequence,
619+ enabled: power_user.instruct.enabled,
620+ },
621+ {
622+ key: 'instructLastOutput|instructLastAssistantPrefix',
623+ value: power_user.instruct.last_output_sequence || power_user.instruct.output_sequence,
624+ enabled: power_user.instruct.enabled,
625+ },
626+ {
627+ key: 'instructStop',
628+ value: power_user.instruct.stop_sequence,
629+ enabled: power_user.instruct.enabled,
630+ },
631+ {
632+ key: 'instructUserFiller',
633+ value: power_user.instruct.user_alignment_message,
634+ enabled: power_user.instruct.enabled,
635+ },
636+ {
637+ key: 'instructSystemInstructionPrefix',
638+ value: power_user.instruct.last_system_sequence,
639+ enabled: power_user.instruct.enabled,
640+ },
641+ {
642+ key: 'instructFirstInput|instructFirstUserPrefix',
643+ value: power_user.instruct.first_input_sequence || power_user.instruct.input_sequence,
644+ enabled: power_user.instruct.enabled,
645+ },
646+ {
647+ key: 'instructLastInput|instructLastUserPrefix',
648+ value: power_user.instruct.last_input_sequence || power_user.instruct.input_sequence,
649+ enabled: power_user.instruct.enabled,
650+ },
590651 // System prompt macros
591- 'systemPrompt': (power_user.prefer_character_prompt && env.charPrompt ? env.charPrompt : power_user.sysprompt.content),
652+ {
592- 'defaultSystemPrompt|instructSystem|instructSystemPrompt': power_user.sysprompt.content,
653+ key: 'systemPrompt',
654+ value: power_user.prefer_character_prompt && env.charPrompt ? env.charPrompt : power_user.sysprompt.content,
655+ enabled: power_user.sysprompt.enabled,
656+ },
657+ {
658+ key: 'defaultSystemPrompt|instructSystem|instructSystemPrompt',
659+ value: power_user.sysprompt.content,
660+ enabled: power_user.sysprompt.enabled,
661+ },
593662 // Context template macros
594- 'chatSeparator': power_user.context.example_separator,
663+ {
595- 'chatStart': power_user.context.chat_start,
664+ key: 'chatSeparator',
596- };
665+ value: power_user.context.example_separator,
666+ enabled: true,
667+ },
668+ {
669+ key: 'chatStart',
670+ value: power_user.context.chat_start,
671+ enabled: true,
672+ },
673+ ];
597674
598675 const macros = [];
599676
600677 for (const [placeholder{ key, value], enabled } of Object.entries(instructMacros)) {
601678 const regex = new RegExp(`{{(${placeholderkey})}}`, 'gi');
602679 const replace = () => power_user.instruct.enabled ? value : '';
603680 macros.push({ regex, replace });
604681 }
605682