diff --git a/public/index.html b/public/index.html index 67a8b14b5..8b59a2fcf 100644 --- a/public/index.html +++ b/public/index.html @@ -818,6 +818,10 @@
select
+ +
Example dialogues stay in context

Anchors Order

Helps to increase the length of messages 0) { if (is_pygmalion) { value = value.replace(/{{user}}:/gi, "You:"); @@ -963,7 +964,11 @@ function baseChatReplaceAndSplit(value, name1, name2) { value = value.replace(/{{user}}/gi, name1); value = value.replace(/{{char}}/gi, name2); value = value.replace(//gi, name1); - value = value.replace(//gi, name2);; + value = value.replace(//gi, name2); + + if (collapse_newlines) { + value = collapseNewlines(value); + } } return value; } @@ -1078,10 +1083,10 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length let chatString = ''; let arrMes = []; let mesSend = []; - let charDescription = baseChatReplaceAndSplit($.trim(characters[this_chid].description), name1, name2); - let charPersonality = baseChatReplaceAndSplit($.trim(characters[this_chid].personality), name1, name2); - let Scenario = baseChatReplaceAndSplit($.trim(characters[this_chid].scenario), name1, name2); - let mesExamples = baseChatReplaceAndSplit($.trim(characters[this_chid].mes_example), name1, name2); + let charDescription = baseChatReplace($.trim(characters[this_chid].description), name1, name2); + let charPersonality = baseChatReplace($.trim(characters[this_chid].personality), name1, name2); + let Scenario = baseChatReplace($.trim(characters[this_chid].scenario), name1, name2); + let mesExamples = baseChatReplace($.trim(characters[this_chid].mes_example), name1, name2); if (!mesExamples.startsWith('')) { mesExamples = '\n' + mesExamples.trim(); @@ -1114,6 +1119,15 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length storyString += '\n' + appendToStoryString(charPersonality, ''); } } + + if (pin_examples){ + for (let example of mesExamplesArray) { + if(!is_pygmalion) { + example = example.replace(//i, 'This is how '+name2+' should talk');//An example of how '+name2+' responds + } + storyString += example; + } + } ////////////////////////////////// var count_exm_add = 0; @@ -1199,18 +1213,20 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length count_exm_add = 0; if (i === chat.length - 1) { - let mesExmString = ''; - for (let iii = mesExamplesArray.length - 1; iii >= 0; iii--) { - mesExmString += mesExamplesArray[iii]; - const prompt = worldInfoString + storyString + mesExmString + chatString + anchorTop + anchorBottom + charPersonality + promptBias + extension_prompt; - if (encode(JSON.stringify(prompt)).length + 120 < this_max_context) { - if (!is_pygmalion) { - mesExamplesArray[iii] = mesExamplesArray[iii].replace(//i, `This is how ${name2} should talk`); + if (!pin_examples) { + let mesExmString = ''; + for (let iii = mesExamplesArray.length - 1; iii >= 0; iii--) { + mesExmString += mesExamplesArray[iii]; + const prompt = worldInfoString + storyString + mesExmString + chatString + anchorTop + anchorBottom + charPersonality + promptBias + extension_prompt; + if (encode(JSON.stringify(prompt)).length + 120 < this_max_context) { + if (!is_pygmalion) { + mesExamplesArray[iii] = mesExamplesArray[iii].replace(//i, `This is how ${name2} should talk`); + } + count_exm_add++; + await delay(1); + } else { + break; } - count_exm_add++; - await delay(1); - } else { - break; } } if (!is_pygmalion && Scenario && Scenario.length > 0) { @@ -1338,9 +1354,6 @@ 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... diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 60f461745..1728d6001 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -2,14 +2,17 @@ export { collapseNewlines, collapse_newlines, force_pygmalion_formatting, + pin_examples, }; let collapse_newlines = false; let force_pygmalion_formatting = false; +let pin_examples = false; const storage_keys = { collapse_newlines: "TavernAI_collapse_newlines", force_pygmalion_formatting: "TavernAI_force_pygmalion_formatting", + pin_examples: "TavernAI_pin_examples", }; function collapseNewlines(x) { @@ -19,9 +22,11 @@ function collapseNewlines(x) { function loadPowerUserSettings() { collapse_newlines = localStorage.getItem(storage_keys.collapse_newlines) == "true"; force_pygmalion_formatting = localStorage.getItem(storage_keys.force_pygmalion_formatting) == "true"; + pin_examples = localStorage.getItem(storage_keys.pin_examples) == "true"; $("#force-pygmalion-formatting-checkbox").prop("checked", force_pygmalion_formatting); $("#collapse-newlines-checkbox").prop("checked", collapse_newlines); + $("#pin-examples-checkbox").prop("checked", pin_examples); } $(document).ready(() => { @@ -37,4 +42,9 @@ $(document).ready(() => { force_pygmalion_formatting = !!$("#force-pygmalion-formatting-checkbox").prop("checked"); localStorage.setItem(storage_keys.force_pygmalion_formatting, force_pygmalion_formatting); }); + + $("#pin-examples-checkbox").change(function () { + pin_examples = !!$("#pin-examples-checkbox").prop("checked"); + localStorage.setItem(storage_keys.force_pygmalion_formatting, pin_examples); + }); }); \ No newline at end of file diff --git a/public/style.css b/public/style.css index deadb6daa..069520cd1 100644 --- a/public/style.css +++ b/public/style.css @@ -1912,7 +1912,8 @@ input[type="range"] { } #anchor_checkbox label, -#power-user-option-checkboxes label { +#power-user-option-checkboxes label, +.checkbox_label { display: flex; flex-direction: row; column-gap: 10px;