DRY
| @@ -570,12 +570,8 @@ function selectMatchingContextTemplate(name) { | |||
| 570 | * @returns {import('./macros.js').Macro[]} Macro objects. | 570 | * @returns {import('./macros.js').Macro[]} Macro objects. |
| 571 | */ | 571 | */ |
| 572 | export function getInstructMacros(env) { | 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 | const instructMacros = { | 573 | const instructMacros = { |
| 574 | // Instruct template macros | ||
| 579 | 'instructSystemPromptPrefix': power_user.instruct.system_sequence_prefix, | 575 | 'instructSystemPromptPrefix': power_user.instruct.system_sequence_prefix, |
| 580 | 'instructSystemPromptSuffix': power_user.instruct.system_sequence_suffix, | 576 | 'instructSystemPromptSuffix': power_user.instruct.system_sequence_suffix, |
| 581 | 'instructInput|instructUserPrefix': power_user.instruct.input_sequence, | 577 | 'instructInput|instructUserPrefix': power_user.instruct.input_sequence, |
| @@ -591,6 +587,12 @@ export function getInstructMacros(env) { | |||
| 591 | 'instructSystemInstructionPrefix': power_user.instruct.last_system_sequence, | 587 | 'instructSystemInstructionPrefix': power_user.instruct.last_system_sequence, |
| 592 | 'instructFirstInput|instructFirstUserPrefix': power_user.instruct.first_input_sequence || power_user.instruct.input_sequence, | 588 | 'instructFirstInput|instructFirstUserPrefix': power_user.instruct.first_input_sequence || power_user.instruct.input_sequence, |
| 593 | 'instructLastInput|instructLastUserPrefix': power_user.instruct.last_input_sequence || power_user.instruct.input_sequence, | 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 | const macros = []; | 598 | const macros = []; |
| @@ -601,15 +603,6 @@ export function getInstructMacros(env) { | |||
| 601 | macros.push({ regex, replace }); | 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 | return macros; | 606 | return macros; |
| 614 | } | 607 | } |
| 615 | 608 | ||