From dedb96ec8d6f99c1ff8742ca4ae039e43b913926 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:05:15 +0000 Subject: [PATCH] Don't trim on whitespace user prefix sequence --- public/script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index 2e8b8d736..cda7adea3 100644 --- a/public/script.js +++ b/public/script.js @@ -5427,6 +5427,7 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc getMessage = getMessage.substring(0, getMessage.indexOf('<|endoftext|>')); } const isInstruct = power_user.instruct.enabled && main_api !== 'openai'; + const isNotEmpty = (str) => str && str.trim() !== ''; if (isInstruct && power_user.instruct.stop_sequence) { if (getMessage.indexOf(power_user.instruct.stop_sequence) != -1) { getMessage = getMessage.substring(0, getMessage.indexOf(power_user.instruct.stop_sequence)); @@ -5434,7 +5435,7 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc } // Hana: Only use the first sequence (should be <|model|>) // of the prompt before <|user|> (as KoboldAI Lite does it). - if (isInstruct && power_user.instruct.input_sequence) { + if (isInstruct && isNotEmpty(power_user.instruct.input_sequence)) { if (getMessage.indexOf(power_user.instruct.input_sequence) != -1) { getMessage = getMessage.substring(0, getMessage.indexOf(power_user.instruct.input_sequence)); }