@@ -12,7 +12,7 @@ Current version indicated by LITEVER below.
1212-->
1313
1414<script>
15- const LITEVER = 231 ;
15+ const LITEVER = 232 ;
1616 const urlParams = new URLSearchParams(window.location.search);
1717 var localflag = urlParams.get('local'); //this will be replaced automatically in embedded kcpp
1818 const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_";
@@ -3076,6 +3076,7 @@ Current version indicated by LITEVER below.
30763076 var koboldcpp_admin_type = 0; //0 = no admin, 1=has admin, 2=protected admin
30773077 var lastSearchQuery = "";
30783078 var lastSearchResults = [];
3079+ var recentSearchQueries = [];
30793080 var multiplayer_active = false;
30803081 var multiplayer_pinged = false;
30813082 var multiplayer_override_name = "";
@@ -3237,12 +3238,13 @@ Current version indicated by LITEVER below.
32373238 regexreplace_data: [],
32383239 placeholder_tags_data: [],
32393240 thinking_pattern: "<think>([\\s\\S]+?)<\/think>",
3240- thinking_action: 1, //0=display, 1=collapse, 2=hide, 3=remove
3241+ thinking_action: 1, //0=display, 1=collapse, 2=hide
32413242 start_thinking_tag: "<think>",
32423243 force_thinking_tag: false,
3243- strip_past_thinking: true,
3244+ strip_thinking_mode: 1, //0=no stripping, 1=strip except recent, 2=strip all
32443245 websearch_enabled: false,
32453246 websearch_multipass: false,
3247+ websearch_retain: false,
32463248 websearch_template: "",
32473249
32483250 max_context_length: (localflag?4096:1800),
@@ -5400,11 +5402,11 @@ Current version indicated by LITEVER below.
54005402 .replace(/<\/blockquote\>\n<blockquote\>/g, "\n<br>")
54015403 .replace(/!\[(.*?)\]\((.*?) "(.*?)"\)/gm,'<img alt="$1" src="$2" $3 />')
54025404 .replace(/!\[(.*?)\]\((.*?)\)/gm, '<img alt="$1" src="$2" />')
5403- .replace(/\[(.*?)\]\((.*?) "new"\)/gm, '<a href="$2" target=_new >$1</a>')
5404- .replace(/\[(.*?)\]\((.*?) "(.*?)"\)/gm, '<a href="$2" title="$3">$1</a>')
5405- .replace(/<http(.*?)\>/gm, '<a href="http$1">http$1</a>')
5406- .replace(/\[(.*?)\]\(\)/gm, '<a href="$1">$1</a>')
5407- .replace(/\[(.*?)\]\((.*?)\)/gm, '<a href="$2">$1</a>')
5405+ .replace(/\[(.*?)\]\((.*?) "new"\)/gm, '<a href="$2" target="_blank" rel="noopener noreferrer" >$1</a>')
5406+ .replace(/\[(.*?)\]\((.*?) "(.*?)"\)/gm, '<a href="$2" title="$3" target="_blank" rel="noopener noreferrer" >$1</a>')
5407+ .replace(/<http(.*?)\>/gm, '<a href="http$1" target="_blank" rel="noopener noreferrer" >http$1</a>')
5408+ .replace(/\[(.*?)\]\(\)/gm, '<a href="$1" target="_blank" rel="noopener noreferrer" >$1</a>')
5409+ .replace(/\[(.*?)\]\((.*?)\)/gm, '<a href="$2" target="_blank" rel="noopener noreferrer" >$1</a>')
54085410
54095411 .replace(/^[\*+-][ .](.*)/gm, "<ul><li>$1</li></ul>")
54105412 .replace(/\%SpcEtg\%(\d\d?)[.](.*)([\n]?)/gm, "\%SpcEtg\%\n$1.$2\n")
@@ -6690,7 +6692,7 @@ Current version indicated by LITEVER below.
66906692 let old_thinking_action = localsettings.thinking_action;
66916693 let old_start_thinking_tag = localsettings.start_thinking_tag;
66926694 let old_force_thinking_tag = localsettings.force_thinking_tag;
6693- let old_strip_past_thinking = localsettings.strip_past_thinking ;
6695+ let old_strip_thinking_mode = localsettings.strip_thinking_mode ;
66946696
66956697 //determine if oldui file or newui file format
66966698 restart_new_game(false);
@@ -6822,10 +6824,6 @@ Current version indicated by LITEVER below.
68226824 {
68236825 localsettings.force_thinking_tag = storyobj.force_thinking_tag;
68246826 }
6825- if(storyobj.strip_past_thinking===false || storyobj.strip_past_thinking===true)
6826- {
6827- localsettings.strip_past_thinking = storyobj.strip_past_thinking;
6828- }
68296827 if(storyobj.start_thinking_tag)
68306828 {
68316829 localsettings.start_thinking_tag = storyobj.start_thinking_tag;
@@ -6944,7 +6942,7 @@ Current version indicated by LITEVER below.
69446942 localsettings.thinking_action = old_thinking_action;
69456943 localsettings.start_thinking_tag = old_start_thinking_tag;
69466944 localsettings.force_thinking_tag = old_force_thinking_tag;
6947- localsettings.strip_past_thinking = old_strip_past_thinking ;
6945+ localsettings.strip_thinking_mode = old_strip_thinking_mode ;
69486946 }
69496947
69506948 localsettings.my_api_key = tmpapikey1;
@@ -7489,16 +7487,27 @@ Current version indicated by LITEVER below.
74897487 {
74907488 hide_popups();
74917489 document.getElementById("charcreator_name").value = document.getElementById("charcreator_persona").value = document.getElementById("charcreator_scenario").value = document.getElementById("charcreator_greeting").value = "";
7490+ document.getElementById("usecharactertemplate").checked = false;
74927491 document.getElementById("charactercreator").classList.remove("hidden");
74937492 tempAestheticInstructUISettings = deepCopyAestheticSettings(aestheticInstructUISettings);
74947493 character_creator_updateimg();
7494+ character_creator_template_toggle();
74957495 }
74967496 function character_creator_updateimg()
74977497 {
74987498 document.getElementById("charcreator_avatar").style.backgroundImage = `url(` + (aestheticInstructUISettings.AI_portrait != "default" ? aestheticInstructUISettings.AI_portrait : niko_square) + `)`;
74997499 }
7500+ function character_creator_template_toggle()
7501+ {
7502+ if (document.getElementById("usecharactertemplate").checked) {
7503+ document.getElementById("nocharactertemplate").classList.add("hidden");
7504+ } else {
7505+ document.getElementById("nocharactertemplate").classList.remove("hidden");
7506+ }
7507+ }
75007508 function character_creator_done(confirm)
75017509 {
7510+ let usingtemplate = document.getElementById("usecharactertemplate").checked; //are we using Peter's template?
75027511 if (!confirm)
75037512 {
75047513 aestheticInstructUISettings = deepCopyAestheticSettings(tempAestheticInstructUISettings);
@@ -7520,6 +7529,18 @@ Current version indicated by LITEVER below.
75207529 scenario = "\n[Scenario: "+scenario+"]";
75217530 }
75227531 let combinedmem = memory + scenario;
7532+
7533+ if(usingtemplate)
7534+ {
7535+ let introduction = "[Overview: <give the AI a one sentence overview of what your intention is here>]";
7536+ let character = "\n\n[" + chatopponent + "'s Character definition:\nAge:\nHeight:\nWeight:\nBuild:\nHair:\nEyes:\nEyebrows:\nClothing Preferences:\nPersonality:\nMind:\nSpeech:\nAccent:\nMannerisms:\nLikes:\nDislikes:\nHobbies:\nShort-term Goals:\nLong-term Goals:\n" + chatopponent + "’s primary goal is:\nChildhood memories of " + chatopponent + ":\nLong-term memories of " + chatopponent + ": <also add descriptions of friends and similar persons from the life of " + chatopponent + " here>\nShort-term Memories relevant for the scenario: ]";
7537+ let genre = "\n\n[Genre: <add one or more genre definitions for your scenario here>]";
7538+ let tags = "\n\n[Tags: <add one or more tags describing your role-play for the AI here>]";
7539+ let scenario = "\n\n[Scenario: <add your scenario here>]";
7540+ let examples = "\n\n" + chatopponent + ": <add some example messages (hidden) for " + chatopponent + " here>";
7541+ combinedmem = introduction + character + genre + tags + scenario + examples;
7542+ }
7543+
75237544 greeting = "\n{{char}}: "+ greeting;
75247545 restart_new_game(false);
75257546
@@ -7542,6 +7563,10 @@ Current version indicated by LITEVER below.
75427563 }
75437564 tempAestheticInstructUISettings = null;
75447565 hide_popups();
7566+ if (confirm && usingtemplate)
7567+ {
7568+ btn_memory();
7569+ }
75457570 }
75467571
75477572 function click_scenario(idx)
@@ -11139,6 +11164,7 @@ Current version indicated by LITEVER below.
1113911164 }
1114011165 document.getElementById("websearch_enabled").checked = localsettings.websearch_enabled;
1114111166 document.getElementById("websearch_multipass").checked = localsettings.websearch_multipass;
11167+ document.getElementById("websearch_retain").checked = localsettings.websearch_retain;
1114211168 document.getElementById("websearch_template").value = (localsettings.websearch_template==""?default_websearch_template:localsettings.websearch_template);
1114311169 if(is_using_kcpp_with_websearch())
1114411170 {
@@ -11600,6 +11626,7 @@ Current version indicated by LITEVER below.
1160011626 }
1160111627 localsettings.websearch_enabled = document.getElementById("websearch_enabled").checked?true:false;
1160211628 localsettings.websearch_multipass = document.getElementById("websearch_multipass").checked?true:false;
11629+ localsettings.websearch_retain = document.getElementById("websearch_retain").checked?true:false;
1160311630 localsettings.websearch_template = (document.getElementById("websearch_template").value==default_websearch_template?"":document.getElementById("websearch_template").value);
1160411631 if(validate_regex(localsettings.thinking_pattern))
1160511632 {
@@ -11611,7 +11638,7 @@ Current version indicated by LITEVER below.
1161111638 }
1161211639 localsettings.thinking_action = parseInt(document.getElementById("thinking_action").value);
1161311640 localsettings.force_thinking_tag = document.getElementById("force_thinking_tag").checked?true:false;
11614- localsettings.strip_past_thinking = document.getElementById("strip_past_thinking ").checked?true:false ;
11641+ localsettings.strip_thinking_mode = parseInt( document.getElementById("strip_thinking_mode ").value) ;
1161511642 localsettings.start_thinking_tag = document.getElementById("start_thinking_tag").value;
1161611643
1161711644
@@ -12433,6 +12460,8 @@ Current version indicated by LITEVER below.
1243312460 last_known_filename = "saved_story.json";
1243412461 is_impersonate_user = false;
1243512462 voice_is_processing = false;
12463+ recentSearchQueries = [];
12464+ lastSearchResults = [];
1243612465 if (!keep_memory)
1243712466 {
1243812467 personal_notes = "";
@@ -13848,10 +13877,25 @@ Current version indicated by LITEVER below.
1384813877 truncated_context = truncated_context.replace(/\xA0/g,' '); //replace non breaking space nbsp
1384913878
1385013879 //remove past thoughts
13851- if(localsettings.strip_past_thinking && localsettings.thinking_action>0 && localsettings. thinking_pattern!="") //removal of cot
13880+ if(localsettings.thinking_pattern!="") //removal of cot
1385213881 {
13853- let pat = new RegExp(localsettings.thinking_pattern, "gm");
13854- truncated_context = truncated_context.replace(pat, "");
13882+ if(localsettings.strip_thinking_mode==2) //strip all thinking
13883+ {
13884+ let pat = new RegExp(localsettings.thinking_pattern, "gm");
13885+ truncated_context = truncated_context.replace(pat, "");
13886+ }
13887+ else if(localsettings.strip_thinking_mode==1) //strip except recent
13888+ {
13889+ let endmatcher = (localsettings.placeholder_tags ? instructendplaceholder : get_instruct_endtag(true));
13890+ let lastInstructIdx = truncated_context.lastIndexOf(endmatcher);
13891+ if (lastInstructIdx !== -1) {
13892+ let beforePart = truncated_context.slice(0, lastInstructIdx); // Split into two parts
13893+ let afterPart = truncated_context.slice(lastInstructIdx);
13894+ let pat = new RegExp(localsettings.thinking_pattern, "gm"); // Remove all thinking before splitpoint
13895+ beforePart = beforePart.replace(pat, "");
13896+ truncated_context = beforePart + afterPart; // Combine and done
13897+ }
13898+ }
1385513899 }
1385613900
1385713901 let max_allowed_characters = getMaxAllowedCharacters(truncated_context, maxctxlen, maxgenamt);
@@ -14162,6 +14206,15 @@ Current version indicated by LITEVER below.
1416214206 let snippet = `\n[Search Snippet: ${sresult.title}\nSource: ${sresult.url}\nExcerpt: ${((sresult.content && sresult.content!="")?sresult.content:sresult.desc)}]`;
1416314207 wistr = snippet + wistr;
1416414208 }
14209+ if(recentSearchQueries && recentSearchQueries.length>0 && localsettings.websearch_retain)
14210+ {
14211+ for(let i=0;i<recentSearchQueries.length;++i)
14212+ {
14213+ let sresult = recentSearchQueries[i];
14214+ let snippet = `\n[Old Search Snippet: ${sresult.title}\nSource: ${sresult.url}\nExcerpt: ${((sresult.content && sresult.content!="")?sresult.content:sresult.desc)}]`;
14215+ wistr = snippet + wistr;
14216+ }
14217+ }
1416514218 }
1416614219
1416714220 // TextDB Long term memory minisearch
@@ -15901,11 +15954,6 @@ Current version indicated by LITEVER below.
1590115954 }
1590215955 }
1590315956 }
15904- if(localsettings.thinking_action==3 && localsettings.thinking_pattern!="") //removal of cot
15905- {
15906- let pat = new RegExp(localsettings.thinking_pattern, "gm");
15907- gentxt = gentxt.replace(pat, "");
15908- }
1590915957
1591015958 //trim trailing whitespace, and multiple newlines
1591115959 if (localsettings.trimwhitespace) {
@@ -19119,7 +19167,7 @@ Current version indicated by LITEVER below.
1911919167 document.getElementById("thinking_pattern").value = localsettings.thinking_pattern;
1912019168 document.getElementById("thinking_action").value = localsettings.thinking_action;
1912119169 document.getElementById("force_thinking_tag").checked = localsettings.force_thinking_tag;
19122- document.getElementById("strip_past_thinking ").checked = localsettings.strip_past_thinking ;
19170+ document.getElementById("strip_thinking_mode ").value = localsettings.strip_thinking_mode ;
1912319171 document.getElementById("start_thinking_tag").value = localsettings.start_thinking_tag;
1912419172 }
1912519173
@@ -20417,6 +20465,14 @@ Current version indicated by LITEVER below.
2041720465 .then(x => x.json())
2041820466 .then(values => {
2041920467 lastSearchQuery = webSearchQuery;
20468+ if(lastSearchResults && lastSearchResults.length>0)
20469+ {
20470+ recentSearchQueries.push(lastSearchResults[0]);
20471+ if(recentSearchQueries.length>2)
20472+ {
20473+ recentSearchQueries.shift();
20474+ }
20475+ }
2042020476 lastSearchResults = values;
2042120477 if(pending_response_id=="-1")
2042220478 {
@@ -20428,6 +20484,7 @@ Current version indicated by LITEVER below.
2042820484 .catch(error => {
2042920485 console.log("WebSearch Error: " + error);
2043020486 lastSearchResults = [];
20487+ recentSearchQueries = [];
2043120488 lastSearchQuery = "";
2043220489 if(pending_response_id=="-1")
2043320490 {
@@ -20476,6 +20533,7 @@ Current version indicated by LITEVER below.
2047620533 else
2047720534 {
2047820535 lastSearchResults = [];
20536+ recentSearchQueries = [];
2047920537 lastSearchQuery = "";
2048020538 websearch_in_progress = false;
2048120539 onDone();
@@ -20894,7 +20952,7 @@ Current version indicated by LITEVER below.
2089420952 </div>
2089520953 </span>
2089620954 </div>
20897- <textarea title="Edit Memory" class="form-control menuinput_multiline" id="memorytext" style="height: 120px ;"
20955+ <textarea title="Edit Memory" class="form-control menuinput_multiline" id="memorytext" style="height: 160px ;"
2089820956 placeholder="Edit the memory to be sent with each request to the AI."></textarea>
2089920957 <div class="settinglabel">
2090020958 <div class="justifyleft"><br>Author's Note<span class="helpicon">?<span
@@ -21819,6 +21877,11 @@ Current version indicated by LITEVER below.
2181921877 <textarea title="Multipass WebSearch Template" style="height: 80px;" class="form-control menuinput_multiline" id="websearch_template"
2182021878 placeholder=""></textarea>
2182121879 </div>
21880+ <div class="settinglabel" style="padding: 4px;">
21881+ <div class="justifyleft settingsmall" title="Retain Previous Searches">Retain Recent Searches <span class="helpicon">?<span
21882+ class="helptext">Normally search results are only used once and then discarded. Enable this to retain search results for the previous 3 turns.</span></span></div>
21883+ <input title="Retain Previous Searches" type="checkbox" id="websearch_retain" style="margin:0px 0 0;">
21884+ </div>
2182221885 </div>
2182321886 </div>
2182421887 </div>
@@ -21884,13 +21947,18 @@ Current version indicated by LITEVER below.
2188421947 <div id="expandthinking" class="hidden">
2188521948 <div class="settinglabel justifyleft">This allows you to specify regex to handle output from reasoning models, to hide, remove, or ignore the Chain-Of-Thought.</div>
2188621949 <div style="padding:4px" class="settinglabel justifyleft">CoT Regex Pattern: <input class="settinglabel miniinput" style="margin-left:4px;width:calc(100% - 132px);" type="text" placeholder="(Inactive)" value="" id="thinking_pattern"></div>
21887- <div style="padding:4px" class="settinglabel justifyleft">CoT Handling: <select class="form-control" style="margin-left:4px;height: 25px; font-size:12px; padding:2px;display:inline;width:120px" id="thinking_action">
21888- <option value="0" selected>Display</option>
21889- <option value="1">Collapse</option>
21950+ <div style="padding:4px" class="settinglabel justifyleft">CoT Display: <span class="helpicon">?<span
21951+ class="helptext">Controls the visibility of thinking sections in the UI. Does not affect submitted thinking tags.</span></span><select class="form-control" style="margin-left:4px;height: 25px; font-size:12px; padding:2px;display:inline;width:120px" id="thinking_action">
21952+ <option value="0">Display</option>
21953+ <option value="1" selected>Collapse</option>
2189021954 <option value="2">Hide</option>
21891- <option value="3">Remove</option>
2189221955 </select></div>
21893- <div style="padding:4px" class="settinglabel justifyleft">Don't Submit Old Thoughts <input title="Do not submit Past Thoughts" type="checkbox" id="strip_past_thinking" style="margin:4px;"></div>
21956+ <div style="padding:4px" class="settinglabel justifyleft">CoT Submitted: <span class="helpicon">?<span
21957+ class="helptext">Controls which thinking tags are submitted to the AI.</span></span><select class="form-control" style="margin-left:4px;height: 25px; font-size:12px; padding:2px;display:inline;width:160px" id="strip_thinking_mode">
21958+ <option value="0">Include All Thinking</option>
21959+ <option value="1" selected>Only Newest Thinking</option>
21960+ <option value="2">Exclude All Thinking</option>
21961+ </select></div>
2189421962 <div style="padding:4px" class="settinglabel justifyleft">Force Insert Thinking Tag <input title="Force Insert Thinking Tag" type="checkbox" id="force_thinking_tag" style="margin:4px;"><input class="settinglabel miniinput" style="margin-left:4px;width:100px;" type="text" placeholder="" value="" id="start_thinking_tag"></div>
2189521963 <div style="padding:4px" class="settinglabel justifyleft">Note: 'Force Insert Thinking Tags' does not work with the 'Remove' option of CoT handling regex.</div>
2189621964 </div>
@@ -22305,18 +22373,23 @@ Current version indicated by LITEVER below.
2230522373 <div id="charcreator_avatar" style="background-position: 50% 50%; background-size: 100% 100%; background-origin: content-box; background-repeat: no-repeat; width: 32px; height:32px; border-radius:100rem; background-clip: content-box; margin: 4px 4px; border:none;"></div>
2230622374 </div>
2230722375 <div class="inlinelabel">
22376+ <div class="justify-center" style="margin:4px;">Use Character Template <span class="helpicon">?<span class="helptext">Adds a character template to memory while creating the character instead.</span></span>
22377+ <input type="checkbox" title="Use Character Template" id="usecharactertemplate" onchange="character_creator_template_toggle()" style="margin:0px 0px 0px auto;"></div>
22378+ </div>
22379+ <div id="nocharactertemplate">
22380+ <div class="inlinelabel">
2230822381 <div class="justifyleft" style="padding:4px">Character Persona: </div>
2230922382 <input title="Character Persona" style="width:calc(100% - 136px);" type="text" placeholder="Describe this character (e.g. 25yo Male Elf, Brave, Chatty)" value="" id="charcreator_persona">
2231022383 </div>
2231122384 <div class="inlinelabel">
2231222385 <div class="justifyleft" style="padding:4px">Describe Scenario: </div>
2231322386 <input title="Describe Scenario" style="width:calc(100% - 136px);" type="text" placeholder="Describe the scenario (e.g. A fireside chat at the spooky campsite)" value="" id="charcreator_scenario">
2231422387 </div>
22388+ </div>
2231522389 <div class="inlinelabel">
2231622390 <div class="justifyleft" style="padding:4px">Character Greeting: </div>
2231722391 <input title="Character Greeting" style="width:calc(100% - 136px);" type="text" placeholder="First message greeting (e.g. Hello, traveller!)" value="" id="charcreator_greeting">
2231822392 </div>
22319-
2232022393 After creating your character, you can edit it further at any time in the 'Context' memory window.
2232122394 </div>
2232222395 <div class="popupfooter">
0 commit comments