From 2c2a68ef76f6c11b33d4a6247b24cb0698083bf5 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 23 Aug 2023 18:04:22 +0300 Subject: [PATCH] Fix instruct system sequence missing + {{original}} --- public/script.js | 2 ++ public/scripts/instruct-mode.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/public/script.js b/public/script.js index add7da3d5..27ce9a3ba 100644 --- a/public/script.js +++ b/public/script.js @@ -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 diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js index bc75e266d..d15274d2f 100644 --- a/public/scripts/instruct-mode.js +++ b/public/scripts/instruct-mode.js @@ -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.