From ecfe8a722fae02e5a1c5809de1e7061a98f2f2fb Mon Sep 17 00:00:00 2001 From: kingbri Date: Mon, 21 Aug 2023 16:52:58 -0400 Subject: [PATCH] Generate: Fix prompt bias addition If the bias is empty, don't add it. Signed-off-by: kingbri --- public/script.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/public/script.js b/public/script.js index 80429d4b5..a0d37f792 100644 --- a/public/script.js +++ b/public/script.js @@ -2922,13 +2922,15 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, // Add prompt bias after everything else // Always run with continue if (!isInstruct && !isImpersonate && (tokens_already_generated === 0 || isContinue)) { - const trimmedBias = promptBias.trimStart(); - finalMesSend[finalMesSend.length - 1] += + if (promptBias.trim().length !== 0) { + finalMesSend[finalMesSend.length - 1] += /\s/.test(finalMesSend[finalMesSend.length - 1].slice(-1)) - ? trimmedBias - : ` ${trimmedBias}`; + ? promptBias.trimStart() + : ` ${promptBias.trimStart()}`; + } } + // Prune from prompt cache if it exists if (generatedPromtCache.length !== 0) { generatedPromtCache = cleanupPromptCache(generatedPromtCache);