diff --git a/public/script.js b/public/script.js index 2e27f1be2..8d4867799 100644 --- a/public/script.js +++ b/public/script.js @@ -34,6 +34,7 @@ import { import { force_pygmalion_formatting, collapse_newlines, + collapseNewlines, } from "./scripts/power-user.js"; import { debounce, delay } from "./scripts/utils.js"; @@ -1336,6 +1337,10 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length } finalPromt = worldInfoBefore + storyString + worldInfoAfter + extension_prompt + mesExmString + mesSendString + generatedPromtCache + promptBias; finalPromt = finalPromt.replace(/\r/gm, ''); + + if (collapse_newlines) { + finalPromt = collapseNewlines(finalPromt); + } //console.log('final prompt decided'); //if we aren't using the kobold GUI settings... @@ -1493,7 +1498,7 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length } if (collapse_newlines) { - getMessage = getMessage.replaceAll(/\n+/g, "\n"); + getMessage = collapseNewlines(getMessage); } //Pygmalion run again // to make it continue generating so long as it's under max_amount and hasn't signaled diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 3b40ab778..60f461745 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -1,4 +1,5 @@ export { + collapseNewlines, collapse_newlines, force_pygmalion_formatting, }; @@ -11,6 +12,10 @@ const storage_keys = { force_pygmalion_formatting: "TavernAI_force_pygmalion_formatting", }; +function collapseNewlines(x) { + return x.replaceAll(/\n+/g, "\n"); +} + function loadPowerUserSettings() { collapse_newlines = localStorage.getItem(storage_keys.collapse_newlines) == "true"; force_pygmalion_formatting = localStorage.getItem(storage_keys.force_pygmalion_formatting) == "true"; diff --git a/public/style.css b/public/style.css index 99de526c6..b3d7e3098 100644 --- a/public/style.css +++ b/public/style.css @@ -88,6 +88,10 @@ body { text-align: right; } +.mes_text br { + content: ' '; +} + .mes_bias { display: block; font-size: 0.9rem;