DRY
| @@ -570,12 +570,8 @@ function selectMatchingContextTemplate(name) { | ||
| 570 | 570 | * @returns {import('./macros.js').Macro[]} Macro objects. |
| 571 | 571 | */ |
| 572 | 572 | export function getInstructMacros(env) { |
| 573 | - const syspromptMacros = { | |
| 574 | - 'systemPrompt': (power_user.prefer_character_prompt && env.charPrompt ? env.charPrompt : power_user.sysprompt.content), | |
| 575 | - 'defaultSystemPrompt|instructSystem|instructSystemPrompt': power_user.sysprompt.content, | |
| 576 | - }; | |
| 577 | - | |
| 578 | 573 | const instructMacros = { |
| 574 | + // Instruct template macros | |
| 579 | 575 | 'instructSystemPromptPrefix': power_user.instruct.system_sequence_prefix, |
| 580 | 576 | 'instructSystemPromptSuffix': power_user.instruct.system_sequence_suffix, |
| 581 | 577 | 'instructInput|instructUserPrefix': power_user.instruct.input_sequence, |
| @@ -591,6 +587,12 @@ export function getInstructMacros(env) { | ||
| 591 | 587 | 'instructSystemInstructionPrefix': power_user.instruct.last_system_sequence, |
| 592 | 588 | 'instructFirstInput|instructFirstUserPrefix': power_user.instruct.first_input_sequence || power_user.instruct.input_sequence, |
| 593 | 589 | 'instructLastInput|instructLastUserPrefix': power_user.instruct.last_input_sequence || power_user.instruct.input_sequence, |
| 590 | + // System prompt macros | |
| 591 | + 'systemPrompt': (power_user.prefer_character_prompt && env.charPrompt ? env.charPrompt : power_user.sysprompt.content), | |
| 592 | + 'defaultSystemPrompt|instructSystem|instructSystemPrompt': power_user.sysprompt.content, | |
| 593 | + // Context template macros | |
| 594 | + 'chatSeparator': power_user.context.example_separator, | |
| 595 | + 'chatStart': power_user.context.chat_start, | |
| 594 | 596 | }; |
| 595 | 597 | |
| 596 | 598 | const macros = []; |
| @@ -601,15 +603,6 @@ export function getInstructMacros(env) { | ||
| 601 | 603 | macros.push({ regex, replace }); |
| 602 | 604 | } |
| 603 | 605 | |
| 604 | - for (const [placeholder, value] of Object.entries(syspromptMacros)) { | |
| 605 | - const regex = new RegExp(`{{(${placeholder})}}`, 'gi'); | |
| 606 | - const replace = () => power_user.sysprompt.enabled ? value : ''; | |
| 607 | - macros.push({ regex, replace }); | |
| 608 | - } | |
| 609 | - | |
| 610 | - macros.push({ regex: /{{exampleSeparator}}/gi, replace: () => power_user.context.example_separator }); | |
| 611 | - macros.push({ regex: /{{chatStart}}/gi, replace: () => power_user.context.chat_start }); | |
| 612 | - | |
| 613 | 606 | return macros; |
| 614 | 607 | } |
| 615 | 608 | |