mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Pin message examples option
This commit is contained in:
@ -818,6 +818,10 @@
|
|||||||
<h5 id="max_context_counter">select</h5>
|
<h5 id="max_context_counter">select</h5>
|
||||||
<input type="range" id="max_context" name="volume" min="512" max="2048" step="1">
|
<input type="range" id="max_context" name="volume" min="512" max="2048" step="1">
|
||||||
</div>
|
</div>
|
||||||
|
<label class="checkbox_label" for="pin-examples-checkbox"><input id="pin-examples-checkbox" type="checkbox" />
|
||||||
|
<h4>Pin message examples</h4>
|
||||||
|
</label>
|
||||||
|
<h5>Example dialogues stay in context</h5>
|
||||||
<div id="anchors-block">
|
<div id="anchors-block">
|
||||||
<h4>Anchors Order</h4>
|
<h4>Anchors Order</h4>
|
||||||
<h5>Helps to increase the length of messages <a href="/notes/9" class="notes-link"
|
<h5>Helps to increase the length of messages <a href="/notes/9" class="notes-link"
|
||||||
|
@ -34,6 +34,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
force_pygmalion_formatting,
|
force_pygmalion_formatting,
|
||||||
collapse_newlines,
|
collapse_newlines,
|
||||||
|
pin_examples,
|
||||||
collapseNewlines,
|
collapseNewlines,
|
||||||
} from "./scripts/power-user.js";
|
} from "./scripts/power-user.js";
|
||||||
|
|
||||||
@ -954,7 +955,7 @@ function getWorldInfoPrompt(chat2) {
|
|||||||
return { worldInfoString, worldInfoBefore, worldInfoAfter };
|
return { worldInfoString, worldInfoBefore, worldInfoAfter };
|
||||||
}
|
}
|
||||||
|
|
||||||
function baseChatReplaceAndSplit(value, name1, name2) {
|
function baseChatReplace(value, name1, name2) {
|
||||||
if (value !== undefined && value.length > 0) {
|
if (value !== undefined && value.length > 0) {
|
||||||
if (is_pygmalion) {
|
if (is_pygmalion) {
|
||||||
value = value.replace(/{{user}}:/gi, "You:");
|
value = value.replace(/{{user}}:/gi, "You:");
|
||||||
@ -963,7 +964,11 @@ function baseChatReplaceAndSplit(value, name1, name2) {
|
|||||||
value = value.replace(/{{user}}/gi, name1);
|
value = value.replace(/{{user}}/gi, name1);
|
||||||
value = value.replace(/{{char}}/gi, name2);
|
value = value.replace(/{{char}}/gi, name2);
|
||||||
value = value.replace(/<USER>/gi, name1);
|
value = value.replace(/<USER>/gi, name1);
|
||||||
value = value.replace(/<BOT>/gi, name2);;
|
value = value.replace(/<BOT>/gi, name2);
|
||||||
|
|
||||||
|
if (collapse_newlines) {
|
||||||
|
value = collapseNewlines(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -1078,10 +1083,10 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
let chatString = '';
|
let chatString = '';
|
||||||
let arrMes = [];
|
let arrMes = [];
|
||||||
let mesSend = [];
|
let mesSend = [];
|
||||||
let charDescription = baseChatReplaceAndSplit($.trim(characters[this_chid].description), name1, name2);
|
let charDescription = baseChatReplace($.trim(characters[this_chid].description), name1, name2);
|
||||||
let charPersonality = baseChatReplaceAndSplit($.trim(characters[this_chid].personality), name1, name2);
|
let charPersonality = baseChatReplace($.trim(characters[this_chid].personality), name1, name2);
|
||||||
let Scenario = baseChatReplaceAndSplit($.trim(characters[this_chid].scenario), name1, name2);
|
let Scenario = baseChatReplace($.trim(characters[this_chid].scenario), name1, name2);
|
||||||
let mesExamples = baseChatReplaceAndSplit($.trim(characters[this_chid].mes_example), name1, name2);
|
let mesExamples = baseChatReplace($.trim(characters[this_chid].mes_example), name1, name2);
|
||||||
|
|
||||||
if (!mesExamples.startsWith('<START>')) {
|
if (!mesExamples.startsWith('<START>')) {
|
||||||
mesExamples = '<START>\n' + mesExamples.trim();
|
mesExamples = '<START>\n' + mesExamples.trim();
|
||||||
@ -1114,6 +1119,15 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
storyString += '\n' + appendToStoryString(charPersonality, '');
|
storyString += '\n' + appendToStoryString(charPersonality, '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pin_examples){
|
||||||
|
for (let example of mesExamplesArray) {
|
||||||
|
if(!is_pygmalion) {
|
||||||
|
example = example.replace(/<START>/i, 'This is how '+name2+' should talk');//An example of how '+name2+' responds
|
||||||
|
}
|
||||||
|
storyString += example;
|
||||||
|
}
|
||||||
|
}
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
|
||||||
var count_exm_add = 0;
|
var count_exm_add = 0;
|
||||||
@ -1199,6 +1213,7 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
count_exm_add = 0;
|
count_exm_add = 0;
|
||||||
|
|
||||||
if (i === chat.length - 1) {
|
if (i === chat.length - 1) {
|
||||||
|
if (!pin_examples) {
|
||||||
let mesExmString = '';
|
let mesExmString = '';
|
||||||
for (let iii = mesExamplesArray.length - 1; iii >= 0; iii--) {
|
for (let iii = mesExamplesArray.length - 1; iii >= 0; iii--) {
|
||||||
mesExmString += mesExamplesArray[iii];
|
mesExmString += mesExamplesArray[iii];
|
||||||
@ -1213,6 +1228,7 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!is_pygmalion && Scenario && Scenario.length > 0) {
|
if (!is_pygmalion && Scenario && Scenario.length > 0) {
|
||||||
storyString += `Circumstances and context of the dialogue: ${Scenario}\n`;
|
storyString += `Circumstances and context of the dialogue: ${Scenario}\n`;
|
||||||
}
|
}
|
||||||
@ -1338,9 +1354,6 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
finalPromt = worldInfoBefore + storyString + worldInfoAfter + extension_prompt + mesExmString + mesSendString + generatedPromtCache + promptBias;
|
finalPromt = worldInfoBefore + storyString + worldInfoAfter + extension_prompt + mesExmString + mesSendString + generatedPromtCache + promptBias;
|
||||||
finalPromt = finalPromt.replace(/\r/gm, '');
|
finalPromt = finalPromt.replace(/\r/gm, '');
|
||||||
|
|
||||||
if (collapse_newlines) {
|
|
||||||
finalPromt = collapseNewlines(finalPromt);
|
|
||||||
}
|
|
||||||
//console.log('final prompt decided');
|
//console.log('final prompt decided');
|
||||||
|
|
||||||
//if we aren't using the kobold GUI settings...
|
//if we aren't using the kobold GUI settings...
|
||||||
|
@ -2,14 +2,17 @@ export {
|
|||||||
collapseNewlines,
|
collapseNewlines,
|
||||||
collapse_newlines,
|
collapse_newlines,
|
||||||
force_pygmalion_formatting,
|
force_pygmalion_formatting,
|
||||||
|
pin_examples,
|
||||||
};
|
};
|
||||||
|
|
||||||
let collapse_newlines = false;
|
let collapse_newlines = false;
|
||||||
let force_pygmalion_formatting = false;
|
let force_pygmalion_formatting = false;
|
||||||
|
let pin_examples = false;
|
||||||
|
|
||||||
const storage_keys = {
|
const storage_keys = {
|
||||||
collapse_newlines: "TavernAI_collapse_newlines",
|
collapse_newlines: "TavernAI_collapse_newlines",
|
||||||
force_pygmalion_formatting: "TavernAI_force_pygmalion_formatting",
|
force_pygmalion_formatting: "TavernAI_force_pygmalion_formatting",
|
||||||
|
pin_examples: "TavernAI_pin_examples",
|
||||||
};
|
};
|
||||||
|
|
||||||
function collapseNewlines(x) {
|
function collapseNewlines(x) {
|
||||||
@ -19,9 +22,11 @@ function collapseNewlines(x) {
|
|||||||
function loadPowerUserSettings() {
|
function loadPowerUserSettings() {
|
||||||
collapse_newlines = localStorage.getItem(storage_keys.collapse_newlines) == "true";
|
collapse_newlines = localStorage.getItem(storage_keys.collapse_newlines) == "true";
|
||||||
force_pygmalion_formatting = localStorage.getItem(storage_keys.force_pygmalion_formatting) == "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);
|
$("#force-pygmalion-formatting-checkbox").prop("checked", force_pygmalion_formatting);
|
||||||
$("#collapse-newlines-checkbox").prop("checked", collapse_newlines);
|
$("#collapse-newlines-checkbox").prop("checked", collapse_newlines);
|
||||||
|
$("#pin-examples-checkbox").prop("checked", pin_examples);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
@ -37,4 +42,9 @@ $(document).ready(() => {
|
|||||||
force_pygmalion_formatting = !!$("#force-pygmalion-formatting-checkbox").prop("checked");
|
force_pygmalion_formatting = !!$("#force-pygmalion-formatting-checkbox").prop("checked");
|
||||||
localStorage.setItem(storage_keys.force_pygmalion_formatting, force_pygmalion_formatting);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
@ -1912,7 +1912,8 @@ input[type="range"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#anchor_checkbox label,
|
#anchor_checkbox label,
|
||||||
#power-user-option-checkboxes label {
|
#power-user-option-checkboxes label,
|
||||||
|
.checkbox_label {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
column-gap: 10px;
|
column-gap: 10px;
|
||||||
|
Reference in New Issue
Block a user