From 56a6398189059761f8f7e76257d7d053eabb87b2 Mon Sep 17 00:00:00 2001 From: Stefan Daniel Schwarz Date: Thu, 24 Aug 2023 19:33:04 +0200 Subject: [PATCH] system prompt in system sequence --- public/instruct/Llama 2 Chat.json | 4 ++-- public/scripts/instruct-mode.js | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/public/instruct/Llama 2 Chat.json b/public/instruct/Llama 2 Chat.json index 98cc04c4d..f7d035277 100644 --- a/public/instruct/Llama 2 Chat.json +++ b/public/instruct/Llama 2 Chat.json @@ -1,10 +1,10 @@ { "name": "Llama 2 Chat", - "system_prompt": "[INST] <>\nWrite {{char}}'s next reply in this fictional roleplay with {{user}}.\n<>\n", + "system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.", "input_sequence": "[INST] ", "output_sequence": " [/INST] ", "last_output_sequence": "", - "system_sequence": "[INST] <>\n", + "system_sequence": "[INST] <>\n{{sys}}\n<>\n", "stop_sequence": "", "separator_sequence": "\n", "wrap": false, diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js index 85b66ca48..86bcbac8a 100644 --- a/public/scripts/instruct-mode.js +++ b/public/scripts/instruct-mode.js @@ -256,7 +256,12 @@ export function formatInstructModeChat(name, mes, isUser, isNarrator, forceAvata 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; + + if (power_user.instruct.system_sequence.includes("{{sys}}")) { + return power_user.instruct.system_sequence.replace(/{{sys}}/gi, systemPrompt) + separator; + } else { + return power_user.instruct.system_sequence + separator + systemPrompt; + } } return systemPrompt;