@@ -5019,16 +5019,16 @@ Current version indicated by LITEVER below.
50195019 console.log("Not a RISU card.");
50205020 return null;
50215021 }
5022-
5023- function generate_compressed_story(save_images,export_settings,export_aesthetic_settings) {
5022+
5023+ function generate_compressed_story(save_images,export_settings,export_aesthetic_settings, shouldCompress = false ) {
50245024 //encode the current story into a sharable url
50255025 //a tiny json format which gets compressed by LZMA then b64url
50265026
50275027 let story = generate_savefile(save_images,export_settings,export_aesthetic_settings);
50285028 let storyjson = JSON.stringify(story);
50295029 console.log("Exporting story: ", story);
50305030
5031- var cstoryjson = buf_to_b64(lz_c.compress(storyjson, 1));
5031+ var cstoryjson = shouldCompress && localsettings.disableSaveCompressionLocally ? storyjson : buf_to_b64(lz_c.compress(storyjson, 1));
50325032 return cstoryjson;
50335033 }
50345034 function autosave_compressed_story(save_images,export_settings,export_aesthetic_settings) {
@@ -5044,9 +5044,9 @@ Current version indicated by LITEVER below.
50445044 }
50455045 console.log("Autosave Start: ", story);
50465046 (function retry_autosave(json) {
5047- lz_c.compress(json, 1, function(res) {
5048- let compressedstory = buf_to_b64(res);
5049- indexeddb_save("story",compressedstory ).then(()=>{
5047+ if (localsettings.disableSaveCompressionLocally)
5048+ {
5049+ indexeddb_save("story", json ).then(()=>{
50505050 console.log("Autosave Done");
50515051 let newer = pending_storyjson_autosave;
50525052 if (newer && newer !== json) {
@@ -5056,11 +5056,38 @@ Current version indicated by LITEVER below.
50565056 pending_storyjson_autosave = null;
50575057 }
50585058 });
5059- });
5059+ }
5060+ else
5061+ {
5062+ lz_c.compress(json, 1, function(res) {
5063+ let compressedstory = buf_to_b64(res);
5064+ indexeddb_save("story",compressedstory).then(()=>{
5065+ console.log("Autosave Done");
5066+ let newer = pending_storyjson_autosave;
5067+ if (newer && newer !== json) {
5068+ console.log("Updating Autosave");
5069+ retry_autosave(newer);
5070+ }else{
5071+ pending_storyjson_autosave = null;
5072+ }
5073+ });
5074+ });
5075+ }
50605076 })(storyjson);
50615077 }
50625078 function decompress_story(cstoryjson) //decompress story from LZMA to json object
50635079 {
5080+ try {
5081+ if (cstoryjson == null || cstoryjson == "") {
5082+ return null;
5083+ } else {
5084+ return JSON.parse(cstoryjson);
5085+ }
5086+ }
5087+ catch (e) {
5088+ // Surpress and try loading with the decompression logic
5089+ }
5090+
50645091 var story = null;
50655092 try
50665093 {
@@ -11152,7 +11179,7 @@ Current version indicated by LITEVER below.
1115211179 let defaultsavename = (localsettings.opmode==1?"Untitled Story":(localsettings.opmode==2?"Untitled Adventure":(localsettings.opmode==3?"Untitled Chat":"Untitled Instruct")));
1115311180 let savename = defaultsavename + " " + new Date().toLocaleString();
1115411181 let slotnumshown = (parseInt(slot)+1);
11155- let newcompressedstory = generate_compressed_story(true, true, true);
11182+ let newcompressedstory = generate_compressed_story(true, true, true, true );
1115611183 if(islocal)
1115711184 {
1115811185 indexeddb_load("slot_"+slot+"_meta","").then(testslot=>{
@@ -26810,7 +26837,7 @@ let checkFinalThoughtsPrompt = `Action: {"command":{"name":"thought","args":{"me
2681026837 }
2681126838
2681226839 let currentOrderOfActionsOverall = [], currentOrderOfActionDescriptionsOverall = []
26813- let recentActions = [], maxActionsInHistory = 20 , currentAgentCycle = null, endCurrent = false
26840+ let recentActions = [], maxActionsInHistory = 1000 , currentAgentCycle = null, endCurrent = false
2681426841
2681526842 let runAgentCycle = async (initialPrompt = undefined) => {
2681626843 endCurrent = false
@@ -27061,6 +27088,10 @@ let checkFinalThoughtsPrompt = `Action: {"command":{"name":"thought","args":{"me
2706127088 {
2706227089 console.log(i)
2706327090 addThought(createSysPrompt, `Chain of thought had an exception: ${e}`)
27091+ if (resp === null || resp.indexOf("evaluate_formula") === -1)
27092+ {
27093+ break
27094+ }
2706427095 }
2706527096 }
2706627097 currentAgentCycle = null
@@ -27078,13 +27109,15 @@ let checkFinalThoughtsPrompt = `Action: {"command":{"name":"thought","args":{"me
2707827109 document.getElementById("agentCOTMaxnumeric").value = localsettings.agentCOTMax;
2707927110 document.getElementById("agentCOTRepeatsMax").value = localsettings.agentCOTRepeatsMax;
2708027111 document.getElementById("agentCOTRepeatsMaxnumeric").value = localsettings.agentCOTRepeatsMax;
27112+ document.getElementById("disableSaveCompressionLocally").checked = localsettings.disableSaveCompressionLocally;
2708127113 }
2708227114
2708327115 confirm_settings = () => {
2708427116 localsettings.agentBehaviour = (document.getElementById("agentBehaviour").checked ? true : false);
2708527117 localsettings.agentHideCOT = (document.getElementById("agentHideCOT").checked ? true : false);
2708627118 localsettings.agentCOTMax = document.getElementById("agentCOTMax").value;
2708727119 localsettings.agentCOTRepeatsMax = document.getElementById("agentCOTRepeatsMax").value;
27120+ localsettings.disableSaveCompressionLocally = (document.getElementById("disableSaveCompressionLocally").checked ? true : false);
2708827121 originalConfirmSettings()
2708927122 }
2709027123
@@ -27286,6 +27319,10 @@ let checkFinalThoughtsPrompt = `Action: {"command":{"name":"thought","args":{"me
2728627319 {
2728727320 localsettings.agentCOTRepeatsMax = 1
2728827321 }
27322+ if (localsettings?.disableSaveCompressionLocally == undefined)
27323+ {
27324+ localsettings.disableSaveCompressionLocally = true
27325+ }
2728927326
2729027327 let createSettingElemBool = (inputElemId, labelTitle, labelText) => {
2729127328 let settingLabelElem = document.createElement("div")
@@ -27381,7 +27418,13 @@ let checkFinalThoughtsPrompt = `Action: {"command":{"name":"thought","args":{"me
2738127418 settingLabelElem = createSettingElemRange("agentCOTMax", "Maximum agent actions", "Defines the maximum number of actions the agent can take without a user input", 1, 20, 1, 5)
2738227419 lastSettingContainer.append(settingLabelElem)
2738327420
27421+ // Hidden as this is no longer is in use for now
2738427422 settingLabelElem = createSettingElemRange("agentCOTRepeatsMax", "Maximum repeated agent actions of a type", "Defines the maximum number of actions the agent can take of the same type without a user input", 1, 20, 1, 1)
27423+ settingLabelElem.style.display = "none"
27424+ lastSettingContainer.append(settingLabelElem)
27425+
27426+ lastSettingContainer = document.querySelector("#settingsmenuadvanced > .settingitem:nth-last-child(-n+2)")
27427+ settingLabelElem = createSettingElemBool("disableSaveCompressionLocally", "Disables save compression locally", "Disables save compression locally - Improves load / autosave performance with larger saves. The save compression is left enabled for sharing saves or uploading to the main server)")
2738527428 lastSettingContainer.append(settingLabelElem)
2738627429
2738727430 createStopThinkingButton()
0 commit comments