mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix instruct macros not using a proper enabled field
This commit is contained in:
@@ -570,36 +570,113 @@ function selectMatchingContextTemplate(name) {
|
|||||||
* @returns {import('./macros.js').Macro[]} Macro objects.
|
* @returns {import('./macros.js').Macro[]} Macro objects.
|
||||||
*/
|
*/
|
||||||
export function getInstructMacros(env) {
|
export function getInstructMacros(env) {
|
||||||
const instructMacros = {
|
/** @type {{ key: string,value: string, enabled: boolean }[]} */
|
||||||
|
const instructMacros = [
|
||||||
// Instruct template macros
|
// Instruct template macros
|
||||||
'instructSystemPromptPrefix': power_user.instruct.system_sequence_prefix,
|
{
|
||||||
'instructSystemPromptSuffix': power_user.instruct.system_sequence_suffix,
|
key: 'instructSystemPromptPrefix',
|
||||||
'instructInput|instructUserPrefix': power_user.instruct.input_sequence,
|
value: power_user.instruct.system_sequence_prefix,
|
||||||
'instructUserSuffix': power_user.instruct.input_suffix,
|
enabled: power_user.instruct.enabled,
|
||||||
'instructOutput|instructAssistantPrefix': power_user.instruct.output_sequence,
|
},
|
||||||
'instructSeparator|instructAssistantSuffix': power_user.instruct.output_suffix,
|
{
|
||||||
'instructSystemPrefix': power_user.instruct.system_sequence,
|
key: 'instructSystemPromptSuffix',
|
||||||
'instructSystemSuffix': power_user.instruct.system_suffix,
|
value: power_user.instruct.system_sequence_suffix,
|
||||||
'instructFirstOutput|instructFirstAssistantPrefix': power_user.instruct.first_output_sequence || power_user.instruct.output_sequence,
|
enabled: power_user.instruct.enabled,
|
||||||
'instructLastOutput|instructLastAssistantPrefix': power_user.instruct.last_output_sequence || power_user.instruct.output_sequence,
|
},
|
||||||
'instructStop': power_user.instruct.stop_sequence,
|
{
|
||||||
'instructUserFiller': power_user.instruct.user_alignment_message,
|
key: 'instructInput|instructUserPrefix',
|
||||||
'instructSystemInstructionPrefix': power_user.instruct.last_system_sequence,
|
value: power_user.instruct.input_sequence,
|
||||||
'instructFirstInput|instructFirstUserPrefix': power_user.instruct.first_input_sequence || power_user.instruct.input_sequence,
|
enabled: power_user.instruct.enabled,
|
||||||
'instructLastInput|instructLastUserPrefix': power_user.instruct.last_input_sequence || power_user.instruct.input_sequence,
|
},
|
||||||
|
{
|
||||||
|
key: 'instructUserSuffix',
|
||||||
|
value: power_user.instruct.input_suffix,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instructOutput|instructAssistantPrefix',
|
||||||
|
value: power_user.instruct.output_sequence,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instructSeparator|instructAssistantSuffix',
|
||||||
|
value: power_user.instruct.output_suffix,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instructSystemPrefix',
|
||||||
|
value: power_user.instruct.system_sequence,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instructSystemSuffix',
|
||||||
|
value: power_user.instruct.system_suffix,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instructFirstOutput|instructFirstAssistantPrefix',
|
||||||
|
value: power_user.instruct.first_output_sequence || power_user.instruct.output_sequence,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instructLastOutput|instructLastAssistantPrefix',
|
||||||
|
value: power_user.instruct.last_output_sequence || power_user.instruct.output_sequence,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instructStop',
|
||||||
|
value: power_user.instruct.stop_sequence,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instructUserFiller',
|
||||||
|
value: power_user.instruct.user_alignment_message,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instructSystemInstructionPrefix',
|
||||||
|
value: power_user.instruct.last_system_sequence,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instructFirstInput|instructFirstUserPrefix',
|
||||||
|
value: power_user.instruct.first_input_sequence || power_user.instruct.input_sequence,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'instructLastInput|instructLastUserPrefix',
|
||||||
|
value: power_user.instruct.last_input_sequence || power_user.instruct.input_sequence,
|
||||||
|
enabled: power_user.instruct.enabled,
|
||||||
|
},
|
||||||
// System prompt macros
|
// System prompt macros
|
||||||
'systemPrompt': (power_user.prefer_character_prompt && env.charPrompt ? env.charPrompt : power_user.sysprompt.content),
|
{
|
||||||
'defaultSystemPrompt|instructSystem|instructSystemPrompt': power_user.sysprompt.content,
|
key: 'systemPrompt',
|
||||||
|
value: power_user.prefer_character_prompt && env.charPrompt ? env.charPrompt : power_user.sysprompt.content,
|
||||||
|
enabled: power_user.sysprompt.enabled,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'defaultSystemPrompt|instructSystem|instructSystemPrompt',
|
||||||
|
value: power_user.sysprompt.content,
|
||||||
|
enabled: power_user.sysprompt.enabled,
|
||||||
|
},
|
||||||
// Context template macros
|
// Context template macros
|
||||||
'chatSeparator': power_user.context.example_separator,
|
{
|
||||||
'chatStart': power_user.context.chat_start,
|
key: 'chatSeparator',
|
||||||
};
|
value: power_user.context.example_separator,
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'chatStart',
|
||||||
|
value: power_user.context.chat_start,
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const macros = [];
|
const macros = [];
|
||||||
|
|
||||||
for (const [placeholder, value] of Object.entries(instructMacros)) {
|
for (const { key, value, enabled } of instructMacros) {
|
||||||
const regex = new RegExp(`{{(${placeholder})}}`, 'gi');
|
const regex = new RegExp(`{{(${key})}}`, 'gi');
|
||||||
const replace = () => power_user.instruct.enabled ? value : '';
|
const replace = () => enabled ? value : '';
|
||||||
macros.push({ regex, replace });
|
macros.push({ regex, replace });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user