diff --git a/index.html b/index.html
index 60e795f..6df4e62 100644
--- a/index.html
+++ b/index.html
@@ -2334,6 +2334,9 @@
const instructstartplaceholder = "\n{{[INPUT]}}\n";
const instructendplaceholder = "\n{{[OUTPUT]}}\n";
const instructsysplaceholder = "\n{{[SYSTEM]}}\n";
+ const instructstartplaceholder_end = "\n{{[INPUT_END]}}\n";
+ const instructendplaceholder_end = "\n{{[OUTPUT_END]}}\n";
+ const instructsysplaceholder_end = "\n{{[SYSTEM_END]}}\n";
// list of all preinstalled quick start scenarios
const scenario_db = [
@@ -3067,6 +3070,9 @@
instruct_starttag: "\\n### Instruction:\\n",
instruct_endtag: "\\n### Response:\\n",
instruct_systag: "",
+ instruct_starttag_end: "",
+ instruct_endtag_end: "",
+ instruct_systag_end: "",
instruct_sysprompt: "",
instruct_has_markdown: true,
placeholder_tags: true,
@@ -3114,6 +3120,7 @@
inject_timestamps: false,
inject_chatnames_instruct: false,
inject_jailbreak_instruct: false,
+ separate_end_tags: false,
idle_responses: 0,
idle_duration: 60,
export_settings: true, //affects if settings are included with the story and sharelinks
@@ -3765,158 +3772,158 @@
console.log("Load autosaves started");
-let loadok = false;
-
-//load all autosave data from indexeddb
-Promise.all([
- indexeddb_load("settings",""),
- indexeddb_load("story",""),
- indexeddb_load("bgimg",""),
- indexeddb_load("savedcustomcss",""),
-]).then(([loadedsettingsjson, loadedstorycompressed, loadedbackgroundimg, currcss]) => {
-try
-{
- if (loadedsettingsjson != null && loadedsettingsjson != "" && loadedstorycompressed != null && loadedstorycompressed != "") {
- let loadedsettings = JSON.parse(loadedsettingsjson);
- //see if persist is enabled
- if (loadedsettings && loadedsettings.persist_session) {
- import_compressed_story(loadedstorycompressed,true); //use the same compressed format as shared stories and import it
- import_props_into_object(localsettings,loadedsettings);
- console.log("Loaded local settings and story");
-
- //offer to reconnect
- let pending_eptype = localsettings.prev_custom_endpoint_type;
- if(!localflag && pending_eptype>0)
- {
- msgboxYesNo("Reconnect to previous custom endpoint?","Custom Endpoint Reconnect",()=>{
- document.getElementById("customapidropdown").value = (pending_eptype).toString();
- display_endpoint_container();
- },null);
+ let loadok = false;
+
+ //load all autosave data from indexeddb
+ Promise.all([
+ indexeddb_load("settings",""),
+ indexeddb_load("story",""),
+ indexeddb_load("bgimg",""),
+ indexeddb_load("savedcustomcss",""),
+ ]).then(([loadedsettingsjson, loadedstorycompressed, loadedbackgroundimg, currcss]) => {
+ try
+ {
+ if (loadedsettingsjson != null && loadedsettingsjson != "" && loadedstorycompressed != null && loadedstorycompressed != "") {
+ let loadedsettings = JSON.parse(loadedsettingsjson);
+ //see if persist is enabled
+ if (loadedsettings && loadedsettings.persist_session) {
+ import_compressed_story(loadedstorycompressed,true); //use the same compressed format as shared stories and import it
+ import_props_into_object(localsettings,loadedsettings);
+ console.log("Loaded local settings and story");
+
+ //offer to reconnect
+ let pending_eptype = localsettings.prev_custom_endpoint_type;
+ if(!localflag && pending_eptype>0)
+ {
+ msgboxYesNo("Reconnect to previous custom endpoint?","Custom Endpoint Reconnect",()=>{
+ document.getElementById("customapidropdown").value = (pending_eptype).toString();
+ display_endpoint_container();
+ },null);
+ }
}
+ if(loadedsettings && !loadedsettings.persist_session)
+ {
+ //toggle persistence off to prevent it from turning on again
+ localsettings.persist_session = false;
+ }
+ if(loadedbackgroundimg && loadedbackgroundimg!="")
+ {
+ let selectedImg = `url('${loadedbackgroundimg}')`;
+ document.body.style.backgroundImage = selectedImg;
+ document.getElementById("gamescreen").classList.add("translucentbg");
+ document.getElementById("enhancedchatinterface").classList.add("transparentbg");
+ document.getElementById("enhancedchatinterface_inner").classList.add("transparentbg");
+ }
+ loadok = true;
+ } else {
+ console.log("Skipped missing local save");
+ loadok = false;
+ //show welcome
+ show_welcome_panel();
}
- if(loadedsettings && !loadedsettings.persist_session)
+ populate_corpo_leftpanel();
+ update_toggle_lightmode(false); //load theme but dont save or toggle it
+
+ //load custom css
+ let resetcss = urlParams.get('resetcss');
+ if(currcss && currcss!="" && !resetcss)
{
- //toggle persistence off to prevent it from turning on again
- localsettings.persist_session = false;
+ currcss = sanitize_css(currcss);
+ console.log("Custom CSS applied.");
+ let styleElement = document.getElementById('custom_css');
+ styleElement.innerHTML = currcss;
}
- if(loadedbackgroundimg && loadedbackgroundimg!="")
+ else if(resetcss)
{
- let selectedImg = `url('${loadedbackgroundimg}')`;
- document.body.style.backgroundImage = selectedImg;
- document.getElementById("gamescreen").classList.add("translucentbg");
- document.getElementById("enhancedchatinterface").classList.add("transparentbg");
- document.getElementById("enhancedchatinterface_inner").classList.add("transparentbg");
+ console.log("Custom CSS reset.")
+ indexeddb_save("savedcustomcss", "");
+ window.history.replaceState(null, null, window.location.pathname);
}
- loadok = true;
- } else {
- console.log("Skipped missing local save");
+
+ } catch (e) {
+ console.log("Discarded invalid local save: " + e);
loadok = false;
- //show welcome
- show_welcome_panel();
}
- populate_corpo_leftpanel();
- update_toggle_lightmode(false); //load theme but dont save or toggle it
- //load custom css
- let resetcss = urlParams.get('resetcss');
- if(currcss && currcss!="" && !resetcss)
- {
- currcss = sanitize_css(currcss);
- console.log("Custom CSS applied.");
- let styleElement = document.getElementById('custom_css');
- styleElement.innerHTML = currcss;
- }
- else if(resetcss)
+ if(!loadok && !localflag && selected_models.length==0 && !is_using_custom_ep()) //nothing was loaded. this is a brand new state, in web lite
{
- console.log("Custom CSS reset.")
- indexeddb_save("savedcustomcss", "");
- window.history.replaceState(null, null, window.location.pathname);
- }
-
-} catch (e) {
- console.log("Discarded invalid local save: " + e);
- loadok = false;
-}
-
-if(!loadok && !localflag && selected_models.length==0 && !is_using_custom_ep()) //nothing was loaded. this is a brand new state, in web lite
-{
- console.log("Autopick some good default models...");
- //attempt to autopick some good default models
- fetch_models((mdls) => {
- //can we find the model that's used? if yes load it, otherwise load the first one
- if (mdls.length > 0)
- {
- selected_models = []; //force clear is needed, as it can get overwritten
- for (var i = 0; i < mdls.length; ++i) {
- let skipignored = false;
- for(let k=0;k {
+ //can we find the model that's used? if yes load it, otherwise load the first one
+ if (mdls.length > 0)
+ {
+ selected_models = []; //force clear is needed, as it can get overwritten
+ for (var i = 0; i < mdls.length; ++i) {
+ let skipignored = false;
+ for(let k=0;k x.json())
- .then(data => {
- if(data && data!="" && data.newstitle && data.newstext && data.newstitle!="" && data.newstext!="")
- {
- msgbox(data.newstext,data.newstitle,true,data.nobtns);
- }
- }).catch((error) => {
- console.log("Error: " + error);
- });
-}
+ //fetch for news updates, for local mode, we don't fetch any news info. They can find updates themselves.
+ if(!localflag)
+ {
+ fetch(horde_news_endpoint)
+ .then(x => x.json())
+ .then(data => {
+ if(data && data!="" && data.newstitle && data.newstext && data.newstitle!="" && data.newstext!="")
+ {
+ msgbox(data.newstext,data.newstitle,true,data.nobtns);
+ }
+ }).catch((error) => {
+ console.log("Error: " + error);
+ });
+ }
-//setup customization aesthetic UI functionality
-initializeInstructUIFunctionality();
+ //setup customization aesthetic UI functionality
+ initializeInstructUIFunctionality();
-});
+ });
-}
+ } //end init
// Helper functions for prompt formatting
function get_my_multiplayer_chatname()
@@ -3951,6 +3958,64 @@
return replaceAll(localsettings.instruct_systag, "\\n", "\n");
}
}
+ function get_instruct_starttag_end(doTrim=true)
+ {
+ if(doTrim){
+ return replaceAll(localsettings.instruct_starttag_end, "\\n", "\n").trim();
+ } else {
+ return replaceAll(localsettings.instruct_starttag_end, "\\n", "\n");
+ }
+ }
+ function get_instruct_endtag_end(doTrim=true)
+ {
+ if(doTrim){
+ return replaceAll(localsettings.instruct_endtag_end, "\\n", "\n").trim();
+ } else {
+ return replaceAll(localsettings.instruct_endtag_end, "\\n", "\n");
+ }
+ }
+ function get_instruct_systag_end(doTrim=true)
+ {
+ if(doTrim){
+ return replaceAll(localsettings.instruct_systag_end, "\\n", "\n").trim();
+ } else {
+ return replaceAll(localsettings.instruct_systag_end, "\\n", "\n");
+ }
+ }
+ function get_instruct_latest_end(doTrim=true)
+ {
+ //scan history for the newest end tag. if none, return empty
+ let truncated_context = concat_gametext(true, "");
+ let strA = instructstartplaceholder;
+ let strB = instructendplaceholder;
+ let strC = instructsysplaceholder;
+ if(!localsettings.placeholder_tags)
+ {
+ strA = get_instruct_starttag(true);
+ strB = get_instruct_endtag(true);
+ strC = get_instruct_systag(true);
+ }
+ let lastA = strA?truncated_context.lastIndexOf(strA):-1;
+ let lastB = strB?truncated_context.lastIndexOf(strB):-1;
+ let lastC = strC?truncated_context.lastIndexOf(strC):-1;
+
+ const maxIndex = Math.max(lastA, lastB, lastC);
+ if(localsettings.placeholder_tags)
+ {
+ if (maxIndex === -1) return "";
+ if (maxIndex === lastA) return instructstartplaceholder_end;
+ if (maxIndex === lastB) return instructendplaceholder_end;
+ return instructsysplaceholder_end;
+ }
+ else
+ {
+ if (maxIndex === -1) return "";
+ if (maxIndex === lastA) return get_instruct_starttag_end(doTrim);
+ if (maxIndex === lastB) return get_instruct_endtag_end(doTrim);
+ return get_instruct_systag_end(doTrim);
+ }
+ }
+
function replace_search_placeholders(text) {
// Remove any instruct tags as needed to ensure a more accurate search
@@ -3961,6 +4026,8 @@
text = replaceAll(text, get_instruct_endtag(false).trim(), "");
text = replaceAll(text, get_instruct_systag(false).trim(), "");
text = text.replace(/\{\{\[INPUT\]\}\}/g, "").replace(/\{\{\[OUTPUT\]\}\}/g, "");
+ text = text.replace(/\{\{\[INPUT_END\]\}\}/g, "").replace(/\{\{\[OUTPUT_END\]\}\}/g, "");
+ text = text.replace(/\{\{\[SYSTEM\]\}\}/g, "").replace(/\{\{\[SYSTEM_END\]\}\}/g, "");
// Replace {{user}} and other placeholders
text = replace_placeholders(text);
@@ -3973,10 +4040,16 @@
inputtxt = replaceAll(inputtxt,instructstartplaceholder,get_instruct_starttag(false));
inputtxt = replaceAll(inputtxt,instructendplaceholder,get_instruct_endtag(false));
inputtxt = replaceAll(inputtxt,instructsysplaceholder,get_instruct_systag(false));
+ inputtxt = replaceAll(inputtxt,instructstartplaceholder_end,get_instruct_starttag_end(false));
+ inputtxt = replaceAll(inputtxt,instructendplaceholder_end,get_instruct_endtag_end(false));
+ inputtxt = replaceAll(inputtxt,instructsysplaceholder_end,get_instruct_systag_end(false));
//failsafe to handle removing newline tags
inputtxt = replaceAll(inputtxt,instructstartplaceholder.trim(),get_instruct_starttag(false));
inputtxt = replaceAll(inputtxt,instructendplaceholder.trim(),get_instruct_endtag(false));
inputtxt = replaceAll(inputtxt,instructsysplaceholder.trim(),get_instruct_systag(false));
+ inputtxt = replaceAll(inputtxt,instructstartplaceholder_end.trim(),get_instruct_starttag_end(false));
+ inputtxt = replaceAll(inputtxt,instructendplaceholder_end.trim(),get_instruct_endtag_end(false));
+ inputtxt = replaceAll(inputtxt,instructsysplaceholder_end.trim(),get_instruct_systag_end(false));
return inputtxt;
}
function replace_noninstruct_placeholders(inputtxt,escape=false)
@@ -10314,6 +10387,9 @@
let sp = replaceAll(localsettings.instruct_sysprompt, "\n", "\\n");
document.getElementById("instruct_sysprompt").value = sp;
document.getElementById("instruct_endtag").value = localsettings.instruct_endtag;
+ document.getElementById("instruct_starttag_end").value = localsettings.instruct_starttag_end;
+ document.getElementById("instruct_systag_end").value = localsettings.instruct_systag_end;
+ document.getElementById("instruct_endtag_end").value = localsettings.instruct_endtag_end;
document.getElementById("min_p").value = localsettings.min_p;
document.getElementById("dynatemp_range").value = localsettings.dynatemp_range;
document.getElementById("dynatemp_exponent").value = localsettings.dynatemp_exponent;
@@ -10392,6 +10468,7 @@
document.getElementById("inject_timestamps").checked = localsettings.inject_timestamps;
document.getElementById("inject_chatnames_instruct").checked = localsettings.inject_chatnames_instruct;
document.getElementById("inject_jailbreak_instruct").checked = localsettings.inject_jailbreak_instruct;
+ document.getElementById("separate_end_tags").checked = localsettings.separate_end_tags;
document.getElementById("idle_responses").value = localsettings.idle_responses;
document.getElementById("idle_duration").value = localsettings.idle_duration;
document.getElementById("fix_alpaca_leak").checked = localsettings.fix_alpaca_leak;
@@ -10685,6 +10762,9 @@
if (localsettings.instruct_endtag == null || localsettings.instruct_endtag == "") {
localsettings.instruct_endtag = "\\n### Response:\\n";
}
+ localsettings.instruct_starttag_end = document.getElementById("instruct_starttag_end").value;
+ localsettings.instruct_endtag_end = document.getElementById("instruct_endtag_end").value;
+ localsettings.instruct_systag_end = document.getElementById("instruct_systag_end").value;
}
function confirm_settings() {
@@ -10732,6 +10812,7 @@
localsettings.inject_timestamps = (document.getElementById("inject_timestamps").checked ? true : false);
localsettings.inject_chatnames_instruct = (document.getElementById("inject_chatnames_instruct").checked ? true : false);
localsettings.inject_jailbreak_instruct = (document.getElementById("inject_jailbreak_instruct").checked ? true : false);
+ localsettings.separate_end_tags = (document.getElementById("separate_end_tags").checked ? true : false);
localsettings.idle_responses = document.getElementById("idle_responses").value;
localsettings.idle_duration = document.getElementById("idle_duration").value;
localsettings.fix_alpaca_leak = (document.getElementById("fix_alpaca_leak").checked ? true : false);
@@ -10919,10 +11000,26 @@
document.getElementById('instruct_starttag').value = itags.start;
document.getElementById('instruct_endtag').value = itags.end;
document.getElementById('instruct_systag').value = itags.system;
+ document.getElementById('instruct_starttag_end').value = "";
+ document.getElementById('instruct_endtag_end').value = "";
+ document.getElementById('instruct_systag_end').value = "";
}
}
function edit_instruct_tag_format()
{
+ let use_et = document.getElementById('separate_end_tags').checked;
+ if(use_et)
+ {
+ document.getElementById('instruct_starttag_end').classList.remove("hidden");
+ document.getElementById('instruct_endtag_end').classList.remove("hidden");
+ document.getElementById('instruct_systag_end').classList.remove("hidden");
+ }
+ else
+ {
+ document.getElementById('instruct_starttag_end').classList.add("hidden");
+ document.getElementById('instruct_endtag_end').classList.add("hidden");
+ document.getElementById('instruct_systag_end').classList.add("hidden");
+ }
let dropdown = document.getElementById('instruct_tag_format');
let options = dropdown.options;
let found = false;
@@ -10932,7 +11029,10 @@
let st = document.getElementById('instruct_starttag').value;
let et = document.getElementById('instruct_endtag').value;
let systag = document.getElementById('instruct_systag').value;
- if(itags.start!="" && itags.end!="" && itags.start==st && itags.end==et && itags.system==systag)
+ let st_end = document.getElementById('instruct_starttag_end').value;
+ let et_end = document.getElementById('instruct_endtag_end').value;
+ let sys_end = document.getElementById('instruct_systag_end').value;
+ if(itags.start!="" && itags.end!="" && itags.start==st && itags.end==et && itags.system==systag && (st_end=="" && et_end=="" && sys_end==""))
{
document.getElementById('instruct_tag_format').value = option.value;
found = true;
@@ -12744,10 +12844,13 @@
{
let ist = instructstartplaceholder;
let iet = instructendplaceholder;
+ let iste = instructstartplaceholder_end;
if (!localsettings.placeholder_tags) {
ist = get_instruct_starttag(false);
iet = get_instruct_endtag(false);
+ iste = get_instruct_starttag_end(false);
}
+ let prev_et = get_instruct_latest_end(false);
if(newgen != "")
{
@@ -12761,8 +12864,14 @@
}
//append instruction for instruct mode
-
- newgen = ist + newgen + iet;
+ if(localsettings.separate_end_tags)
+ {
+ newgen = prev_et + ist + newgen + iste + iet;
+ }
+ else
+ {
+ newgen = ist + newgen + iet;
+ }
if(localsettings.inject_jailbreak_instruct)
{
@@ -12773,9 +12882,13 @@
{
if (is_impersonate_user) {
is_impersonate_user = false;
- pending_context_preinjection = ist; //bot response as first msg
- pending_context_postinjection = iet;
-
+ if (localsettings.separate_end_tags) {
+ pending_context_preinjection = prev_et + ist; //bot response as first msg
+ pending_context_postinjection = iste + iet;
+ } else {
+ pending_context_preinjection = ist; //bot response as first msg
+ pending_context_postinjection = iet;
+ }
} else {
if (gametext_arr.length == 0) {
newgen = iet;
@@ -13057,7 +13170,12 @@
if(localsettings.opmode==4 && localsettings.instruct_sysprompt!="")
{
max_mem_len = Math.floor(max_allowed_characters*0.7);
- appendedsysprompt = get_instruct_systag(false) + localsettings.instruct_sysprompt + "\n";
+ appendedsysprompt = get_instruct_systag(false) + localsettings.instruct_sysprompt;
+ if(localsettings.separate_end_tags && get_instruct_systag_end(true))
+ {
+ appendedsysprompt += get_instruct_systag_end(false);
+ }
+ appendedsysprompt += "\n";
}
let truncated_memory = substring_to_boundary(current_memory, max_mem_len);
if (truncated_memory != null && truncated_memory != "") {
@@ -13432,6 +13550,17 @@
let et = get_instruct_endtag(true);
let me = get_my_multiplayer_chatname();
seqs = [st, et];
+ if(localsettings.separate_end_tags)
+ {
+ if(get_instruct_endtag_end(true))
+ {
+ seqs.push(get_instruct_endtag_end(true));
+ }
+ if(get_instruct_starttag_end(true) && get_instruct_starttag_end(true)!=get_instruct_endtag_end(true))
+ {
+ seqs.push(get_instruct_starttag_end(true));
+ }
+ }
if(localsettings.inject_chatnames_instruct)
{
if(me!="")
@@ -14942,6 +15071,11 @@
{
let st = get_instruct_starttag(true);
let et = get_instruct_endtag(true);
+ let stet_et = "";
+ if(localsettings.separate_end_tags && get_instruct_endtag_end(true))
+ {
+ stet_et = get_instruct_endtag_end(true);
+ }
//sometimes the OAI type endpoints get confused and repeat the instruct tag, so trim it
let earlymatch = gentxt.indexOf(et);
@@ -14966,6 +15100,17 @@
gentxt = splitresponse[0];
}
+ if(stet_et && stet_et!="")
+ {
+ found = gentxt.indexOf(stet_et);
+ splitresponse = [];
+ if (found != -1) //if found, truncate to it
+ {
+ splitresponse = gentxt.split(stet_et);
+ gentxt = splitresponse[0];
+ }
+ }
+
if(localsettings.inject_chatnames_instruct)
{
let st2 = mychatname + "\:";
@@ -16304,6 +16449,16 @@
let b = escape_html(get_instruct_endtag(false));
fulltxt = replaceAll(fulltxt,a,get_instruct_starttag(false));
fulltxt = replaceAll(fulltxt,b,get_instruct_endtag(false));
+ if (localsettings.separate_end_tags) {
+ if (get_instruct_endtag_end(true)) {
+ let a = escape_html(get_instruct_endtag_end(false));
+ fulltxt = replaceAll(fulltxt, a, get_instruct_endtag_end(false));
+ }
+ if (get_instruct_starttag_end(true)) {
+ let a = escape_html(get_instruct_starttag_end(false));
+ fulltxt = replaceAll(fulltxt, a, get_instruct_starttag_end(false));
+ }
+ }
}
}
if (stripimg)
@@ -16600,6 +16755,14 @@
fulltxt = replaceAll(fulltxt, get_instruct_endtag(false), `%SpcEtg%`);
fulltxt = replaceAll(fulltxt, get_instruct_starttag(true), `%SpcStg%`);
fulltxt = replaceAll(fulltxt, get_instruct_endtag(true), `%SpcEtg%`);
+ if (localsettings.separate_end_tags) {
+ if (get_instruct_endtag_end(true)) {
+ fulltxt = replaceAll(fulltxt, get_instruct_endtag_end(true), ``);
+ }
+ if (get_instruct_starttag_end(true)) {
+ fulltxt = replaceAll(fulltxt, get_instruct_starttag_end(true), ``);
+ }
+ }
if(localsettings.instruct_has_markdown && synchro_pending_stream=="")
{
@@ -16637,15 +16800,30 @@
}else{
fulltxt = replaceAll(fulltxt, get_instruct_starttag(true), `%SclStg%`+escape_html(get_instruct_starttag(true))+`%SpnEtg%`);
fulltxt = replaceAll(fulltxt, get_instruct_endtag(true), `%SclStg%`+escape_html(get_instruct_endtag(true))+`%SpnEtg%`);
+ if (localsettings.separate_end_tags) {
+ if (get_instruct_starttag_end(true) != "") {
+ fulltxt = replaceAll(fulltxt, get_instruct_starttag_end(true), `%SclStg%` + escape_html(get_instruct_starttag_end(true)) + `%SpnEtg%`);
+ }
+ if (get_instruct_endtag_end(true) != "") {
+ fulltxt = replaceAll(fulltxt, get_instruct_endtag_end(true), `%SclStg%` + escape_html(get_instruct_endtag_end(true)) + `%SpnEtg%`);
+ }
+ }
//failsafe to handle removing newline tags
fulltxt = replaceAll(fulltxt, instructstartplaceholder.trim(), `%SclStg%`+instructstartplaceholder.trim()+`%SpnEtg%`);
fulltxt = replaceAll(fulltxt, instructendplaceholder.trim(), `%SclStg%`+instructendplaceholder.trim()+`%SpnEtg%`);
+ fulltxt = replaceAll(fulltxt, instructstartplaceholder_end.trim(), `%SclStg%`+instructstartplaceholder_end.trim()+`%SpnEtg%`);
+ fulltxt = replaceAll(fulltxt, instructendplaceholder_end.trim(), `%SclStg%`+instructendplaceholder_end.trim()+`%SpnEtg%`);
if(get_instruct_systag(true)!="")
{
fulltxt = replaceAll(fulltxt, get_instruct_systag(true), `%SclStg%`+escape_html(get_instruct_systag(true))+`%SpnEtg%`);
+ if(get_instruct_systag_end(true)!="")
+ {
+ fulltxt = replaceAll(fulltxt, get_instruct_systag_end(true), `%SclStg%`+escape_html(get_instruct_systag_end(true))+`%SpnEtg%`);
+ }
}
fulltxt = replaceAll(fulltxt, instructsysplaceholder.trim(), `%SclStg%`+instructsysplaceholder.trim()+`%SpnEtg%`);
+ fulltxt = replaceAll(fulltxt, instructsysplaceholder_end.trim(), `%SclStg%`+instructsysplaceholder_end.trim()+`%SpnEtg%`);
}
//this is a hacky fix to handle instruct tags that use arrow brackets only
@@ -16984,6 +17162,20 @@
function repack_instruct_history(input) //repack all history into individual turns
{
+ if(localsettings.separate_end_tags) {
+ if (get_instruct_starttag_end(true)) {
+ input = replaceAll(input, get_instruct_starttag_end(false), "");
+ input = replaceAll(input, get_instruct_starttag_end(true), "");
+ }
+ if (get_instruct_endtag_end(true)) {
+ input = replaceAll(input, get_instruct_endtag_end(false), "");
+ input = replaceAll(input, get_instruct_endtag_end(true), "");
+ }
+ if (get_instruct_systag_end(true)) {
+ input = replaceAll(input, get_instruct_systag_end(false), "");
+ input = replaceAll(input, get_instruct_systag_end(true), "");
+ }
+ }
let myturnchat = false; //who is currently speaking?
let st = get_instruct_starttag(false);
let et = get_instruct_endtag(false);
@@ -17107,10 +17299,20 @@
{
let st = get_instruct_starttag(false);
let et = get_instruct_endtag(false);
+ let ste = "";
+ let ete = "";
+ if (localsettings.separate_end_tags) {
+ ste = get_instruct_starttag_end(false);
+ ete = get_instruct_endtag_end(false);
+ }
if(localsettings.placeholder_tags)
{
st = instructstartplaceholder;
et = instructendplaceholder;
+ if (localsettings.separate_end_tags) {
+ ste = instructstartplaceholder_end;
+ ete = instructendplaceholder_end;
+ }
}
for(let i=0;i<=idx;++i)
@@ -17119,7 +17321,7 @@
let chunk = cont;
if(i!=idx)
{
- chunk = (chatunits[i].myturn?st:et) + chunk;
+ chunk = (chatunits[i].myturn?st:et) + chunk + (chatunits[i].myturn?ste:ete);
}
if(i==idx-1)
{
@@ -17204,10 +17406,20 @@
{
let st = get_instruct_starttag(false);
let et = get_instruct_endtag(false);
+ let ste = "";
+ let ete = "";
+ if (localsettings.separate_end_tags) {
+ ste = get_instruct_starttag_end(false);
+ ete = get_instruct_endtag_end(false);
+ }
if(localsettings.placeholder_tags)
{
st = instructstartplaceholder;
et = instructendplaceholder;
+ if (localsettings.separate_end_tags) {
+ ste = instructstartplaceholder_end;
+ ete = instructendplaceholder_end;
+ }
}
let finalturnai = false;
@@ -17216,7 +17428,7 @@
let cont = (i==idx?newtxt:chatunits[i].msg);
if(cont!="")
{
- let chunk = (chatunits[i].myturn?st:et) + cont;
+ let chunk = (chatunits[i].myturn?st:et) + cont + (chatunits[i].myturn?ste:ete);
gametext_arr.push(chunk);
finalturnai = (chatunits[i].myturn?false:true);
}
@@ -18782,6 +18994,18 @@
function render_aesthetic_ui(input, isPreview) //class suffix string used to prevent defined styles from leaking into global scope
{
+ if(localsettings.separate_end_tags) {
+ if (get_instruct_starttag_end(true)) {
+ input = replaceAll(input, get_instruct_starttag_end(true), "");
+ }
+ if (get_instruct_endtag_end(true)) {
+ input = replaceAll(input, get_instruct_endtag_end(true), "");
+ }
+ if (get_instruct_systag_end(true)) {
+ input = replaceAll(input, get_instruct_systag_end(true), "");
+ }
+ }
+
if(!isPreview)
{
if(aestheticInstructUISettings.match_background)
@@ -19137,7 +19361,10 @@
//utility functions used in minisearch
let cleanupSpecialTags = function(text) {
- return text.replace(/\{\{\[INPUT\]\}\}/g, "").replace(/\{\{\[OUTPUT\]\}\}/g, "");
+ text = text.replace(/\{\{\[INPUT\]\}\}/g, "").replace(/\{\{\[OUTPUT\]\}\}/g, "");
+ text = text.replace(/\{\{\[INPUT_END\]\}\}/g, "").replace(/\{\{\[OUTPUT_END\]\}\}/g, "");
+ text = text.replace(/\{\{\[SYSTEM\]\}\}/g, "").replace(/\{\{\[SYSTEM_END\]\}\}/g, "");
+ return text;
}
let stripToTokens = function(text) {
@@ -20081,6 +20308,7 @@
System Tag ?The sequence to start the system prompt
+
@@ -20091,12 +20319,14 @@
User Tag ?The sequence to start an instruction prompt
+
Assistant Tag ?The sequence to start an assistant response
+
@@ -20177,6 +20407,11 @@
class="helptext">Automatically injects a jailbreak message after every instruct query, to make the AI more likely to obey you.
+
+
Separate End Tags ?Allows using separate Instruction and Response End Tags, instead of combing them with the start tag. Not recommended for beginners.