Fix instruct system sequence missing + {{original}}

This commit is contained in:
Cohee 2023-08-23 18:04:22 +03:00
parent fad6c164cb
commit 2c2a68ef76
2 changed files with 16 additions and 0 deletions

View File

@ -165,6 +165,7 @@ import {
formatInstructModeExamples,
getInstructStoppingSequences,
autoSelectInstructPreset,
formatInstructModeSystemPrompt,
} from "./scripts/instruct-mode.js";
import { applyLocale } from "./scripts/i18n.js";
import { getTokenCount, getTokenizerModel, saveTokenCache } from "./scripts/tokenizers.js";
@ -2360,6 +2361,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
if (isInstruct) {
systemPrompt = power_user.prefer_character_prompt && systemPrompt ? systemPrompt : baseChatReplace(power_user.instruct.system_prompt, name1, name2);
systemPrompt = formatInstructModeSystemPrompt(substituteParams(systemPrompt, name1, name2, power_user.instruct.system_prompt));
}
// Parse example messages

View File

@ -189,6 +189,20 @@ export function formatInstructModeChat(name, mes, isUser, isNarrator, forceAvata
return text;
}
/**
* Formats instruct mode system prompt.
* @param {string} systemPrompt System prompt string.
* @returns {string} Formatted instruct mode system prompt.
*/
export function formatInstructModeSystemPrompt(systemPrompt){
if (power_user.instruct.system_sequence) {
const separator = power_user.instruct.wrap ? '\n' : '';
return power_user.instruct.system_sequence + separator + systemPrompt;
}
return systemPrompt;
}
/**
* Formats example messages according to instruct mode settings.
* @param {string} mesExamples Example messages string.