Collapse newlines in prompt

This commit is contained in:
SillyLossy
2023-03-18 22:42:41 +02:00
parent bf5b2a5c40
commit 92d4a7f19e
3 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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";

View File

@ -88,6 +88,10 @@ body {
text-align: right;
}
.mes_text br {
content: ' ';
}
.mes_bias {
display: block;
font-size: 0.9rem;