Generate: Fix prompt bias addition

If the bias is empty, don't add it.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2023-08-21 16:52:58 -04:00
parent 60faaf1831
commit ecfe8a722f

View File

@ -2922,13 +2922,15 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
// Add prompt bias after everything else // Add prompt bias after everything else
// Always run with continue // Always run with continue
if (!isInstruct && !isImpersonate && (tokens_already_generated === 0 || isContinue)) { if (!isInstruct && !isImpersonate && (tokens_already_generated === 0 || isContinue)) {
const trimmedBias = promptBias.trimStart(); if (promptBias.trim().length !== 0) {
finalMesSend[finalMesSend.length - 1] += finalMesSend[finalMesSend.length - 1] +=
/\s/.test(finalMesSend[finalMesSend.length - 1].slice(-1)) /\s/.test(finalMesSend[finalMesSend.length - 1].slice(-1))
? trimmedBias ? promptBias.trimStart()
: ` ${trimmedBias}`; : ` ${promptBias.trimStart()}`;
}
} }
// Prune from prompt cache if it exists // Prune from prompt cache if it exists
if (generatedPromtCache.length !== 0) { if (generatedPromtCache.length !== 0) {
generatedPromtCache = cleanupPromptCache(generatedPromtCache); generatedPromtCache = cleanupPromptCache(generatedPromtCache);