diff --git a/public/index.html b/public/index.html index 4ac0433ff..8041b69a1 100644 --- a/public/index.html +++ b/public/index.html @@ -730,17 +730,17 @@ let needsToScan = true; let allActivatedEntries = new Set(); + const sortedEntries = Object.keys(world_info_data.entries).map(x => world_info_data.entries[x]).sort((a, b) => (b.constant - a.constant) || (b.order - a.order)); while (needsToScan) { - let activatedNow = []; + let activatedNow = new Set(); - for (let entryUid in world_info_data.entries) { - const entry = world_info_data.entries[entryUid]; + for (let entry of sortedEntries) { if (allActivatedEntries.has(entry.uid)) { continue; } if (entry.constant) { - activatedNow.push(entry.uid); + activatedNow.add(entry.uid); } if (Array.isArray(entry.key) && entry.key.length) { @@ -749,12 +749,12 @@ if (entry.selective && Array.isArray(entry.keysecondary) && entry.keysecondary.length) { secondary: for (let keysecondary of entry.keysecondary) { if (keysecondary && textToScan.includes(keysecondary.trim().toLowerCase())) { - activatedNow.push(entry.uid); + activatedNow.add(entry.uid); break secondary; } } } else { - activatedNow.push(entry.uid); + activatedNow.add(entry.uid); break primary; } } @@ -762,8 +762,11 @@ } } - needsToScan = activatedNow.length > 0; - const newContents = activatedNow.map(x => world_info_data.entries[x]).map(x => x.content); + needsToScan = activatedNow.size > 0; + const newContents = [...activatedNow] + .map(x => world_info_data.entries[x]) + .sort((a, b) => sortedEntries.indexOf(a) - sortedEntries.indexOf(b)) + .map(x => x.content); for (const content of newContents) { worldInfo = `${worldInfo}${content}\n`; @@ -3336,7 +3339,7 @@ contentInput.val(entry.content).trigger('input'); // selective - const selectiveInput = template.find('input[name="selective"]') + const selectiveInput = template.find('input[name="selective"]'); selectiveInput.data('uid', entry.uid); selectiveInput.on('input', function() { const uid = $(this).data('uid'); @@ -3354,7 +3357,7 @@ // constant - const constantInput = template.find('input[name="constant"]') + const constantInput = template.find('input[name="constant"]'); constantInput.data('uid', entry.uid); constantInput.on('input', function() { const uid = $(this).data('uid'); @@ -3367,6 +3370,17 @@ $(this).siblings('input').click(); }); + // order + const orderInput = template.find('input[name="order"]'); + orderInput.data('uid', entry.uid); + orderInput.on('input', function() { + const uid = $(this).data('uid'); + const value = Number($(this).val()); + world_info_data.entries[uid].order = !isNaN(value) ? value : 0; + saveWorldInfo(); + }); + orderInput.val(entry.order).trigger('input'); + // display uid template.find('.world_entry_form_uid_value').html(entry.uid); @@ -3400,6 +3414,7 @@ content: '', constant: false, selective: false, + order: 0, }; const newUid = getFreeWorldEntryUid(); @@ -3654,26 +3669,37 @@
-
- - +
+
+ + +
+
+ + +
-
- - -
-
- - +
+
+ + +
+
+ + +

- Budget (?) + Token Budget (?)

budget
diff --git a/public/notes/13.html b/public/notes/13.html index 341d4c2e2..5415c25a5 100644 --- a/public/notes/13.html +++ b/public/notes/13.html @@ -29,6 +29,8 @@
A list of supplementary keywords that are used in conjunction with the main keywords (see Selective).
Content
The text that is inserted into the prompt upon entry activation.
+
Insertion Order
+
Numeric value. Defines a priority of the entry if multiple were activated at once. Entries with higher order number will be inserted first.
Comment
A supplemental text comment for the your convenience, which is not utilized by the AI.
Constant
diff --git a/public/notes/13_1.html b/public/notes/13_1.html index c70265c68..e53b0f17e 100644 --- a/public/notes/13_1.html +++ b/public/notes/13_1.html @@ -13,7 +13,7 @@

Scan Depth

Defines how many messages in the chat history should be scanned for World Info keys.

If set to 1, then TavernAI only scans the message you send and the most recent reply.

-

This stacks up to 5 message pairs it total.

+

This stacks up to 10 message pairs it total.

diff --git a/public/notes/13_2.html b/public/notes/13_2.html index 8f9f2e446..d6403c6e5 100644 --- a/public/notes/13_2.html +++ b/public/notes/13_2.html @@ -13,7 +13,8 @@

World Info Budget

Defines how many tokens could be used by World Info entries at once.

If the budget was exhausted, then no more entries are activated even if the keys are present in the prompt.

-

Constant entries always take the priority.

+

Constant entries will be inserted first. Then entries with higher order numbers.

+

Entries inserted by direct mentioning of their keys have higher priority than those that were mentioned in other entries contents.

diff --git a/public/style.css b/public/style.css index a6acc66b4..4cf56d790 100644 --- a/public/style.css +++ b/public/style.css @@ -1315,6 +1315,19 @@ input[type=button] { margin: 0 10px; } +.world_entry_thin_controls { + display: flex; + flex-direction: row; +} + +.world_entry_thin_controls > div { + flex: 1; +} + +.checkbox_fancy { + cursor: pointer; +} + .world_entry_form_control label { margin-left: 10px; } diff --git a/public/worlds/Toaru.json b/public/worlds/Toaru.json index 8f6161fe0..a1f0555e5 100644 --- a/public/worlds/Toaru.json +++ b/public/worlds/Toaru.json @@ -1 +1 @@ -{"entries":{"0":{"uid":0,"key":["Tokiwadai Middle School","Tokiwadai"],"keysecondary":[],"comment":"","content":"Place(\"Tokiwadai Middle School\")[\"prestigious girls' school\" + \"females only\" + \"renowned in the world\" + \"requires Esper ability Level Three or higher\"]","constant":false,"selective":false},"1":{"uid":1,"key":["Esper","Ability User","Level"],"keysecondary":[],"comment":"","content":"Category(\"Esper\")[\"psychic\" + \"user of supernatural powers\" + \"scientifically based\" + \"emits AIM\" + \"ranked by Levels of strength\"]","constant":false,"selective":false},"2":{"uid":2,"key":["Anti-Skill","Guard","police","Anti Skill"],"keysecondary":[],"comment":"","content":"Faction(\"Anti-Skill\")[\"police of Academy City\" + \"security forces\" + \"SWAT unit\" + \"purple symbol\" + \"blue uniform\" + \"SWAT armor\" + \"riot shields\" + \"firearms\"]","constant":false,"selective":false},"3":{"uid":3,"key":["Level 5","Level Five"],"keysecondary":[],"comment":"","content":"Category(\"Level Five Rank\")[\"highest esper level achieved\" + \"only seven people in Academy City have this rank\"]","constant":false,"selective":false},"4":{"uid":4,"key":["Academy City","Gakuen Toshi","City"],"keysecondary":[],"comment":"","content":"Place(\"Academy City\")[\"Located west of Tokyo\" + \"city of several schools\" + \"most advanced city in the world\" + \"scientists research on psychic powers and higher technology\" + \"composed of 23 districts\" + \"population over 2 million\"]","constant":false,"selective":false},"5":{"uid":5,"key":["Saten Ruiko","Saten","Ruiko","Saten-san"],"keysecondary":[],"comment":"","content":"Character(\"Saten Ruiko\")[\"Female\" + \"outgoing\" + \"friendly\" + \"shameless\" + \"attends Sakugawa Middle School\" + \"Classmate of Uiharu\" + \"Level Zero Esper\" + \"friends with: {Misaka, Uiharu, Kuroko}\"]","constant":false,"selective":false},"6":{"uid":6,"key":["Misaka Mikoto","Misaka","Mikoto","Onee-sama"],"keysecondary":[],"comment":"","content":"Character(\"Misaka Mikoto\")[\"Female\" + \"tsundere\" + \"short-tempered\" + \"boyish\" + \"Level Five Esper\" + \"third most powerful esper of Academy City\" + \"attends Tokiwadai Middle School\" + \"Railgun\" + \"Electromaster\" + \"Roommate of Kuroko\" + \"Friends with: {Kuroko, Uiharu, Saten}\"]","constant":false,"selective":false},"7":{"uid":7,"key":["Kuroko","Shirai Kuroko","Shirai"],"keysecondary":[],"comment":"","content":"Character(\"Shirai Kuroko\")[\"Female\" + \"Level Four Esper\" + \"Teleporter powers\" + \"attends Tokiwadai Middle School\", \"works at Judgement with Uiharu\" + \"Roommate of Misaka\" + \"obsessed with Misaka\" + \"calls Misaka Onee-sama\" + \"Friends with: {Misaka, Uiharu, Saten}\"]","constant":false,"selective":false},"8":{"uid":8,"key":["Uiharu","Uiharu Kazari","Kazari"],"keysecondary":[],"comment":"","content":"Character(\"Uiharu Kazari\")[\"Female\" + \"Level One Esper\" + \"attends Sakugawa Middle School\" + \"Thermal Hand powers\" + \"works for Judgement with Kuroko\" + \"expert in computers and hacking\" + \"wears a flower circlet\" + \"friends with: {Misaka, Saten, Kuroko}\" + \"Classmate of Saten\"]","constant":false,"selective":false},"9":{"uid":9,"key":["Judgement"],"keysecondary":[],"comment":"","content":"Faction(\"Judgement\")[\"composed of students\" + \"student-based disciplinary committee\" + \"tasked to maintain peace-and-order within the school system\" + \"members wear armbands on right sleeves\" + \"green shield symbol with white stripes\" + \"known members: {Uiharu, Kuroko}]","constant":false,"selective":false},"10":{"uid":10,"key":["AIM","An Involuntary Movement"],"keysecondary":[],"comment":"","content":"Concept(\"AIM\")[\"stands for An Involuntary Movement\" + \"invisible energy field emitting by espers from their body\" + \"can only be detected by machines or specialized espers\"]","constant":false,"selective":false},"11":{"uid":11,"key":["Personal Reality"],"keysecondary":[],"comment":"","content":"Concept(\"Personal Reality\")[\"foundation of an esper's power\" + \"the source from which all esper powers brought\"+ \"related to quantum theory\"]","constant":false,"selective":false},"12":{"uid":12,"key":["Level Zero","Level 0"],"keysecondary":[],"comment":"","content":"Category(\"Level Zero Rank\")[\"lowest esper rank\" + \"person with no psychic powers or unable to control it\"]","constant":false,"selective":false},"13":{"uid":13,"key":["Sakugawa Middle School","Sakugawa"],"keysecondary":[],"comment":"","content":"Place(\"Sakugawa Middle School\")[\"typical co-ed middle school\" + \"attended by Saten and Uiharu\"]","constant":false,"selective":false},"14":{"uid":14,"key":["Sisters","Clone"],"keysecondary":[],"comment":"","content":"Faction(\"Sisters\")[\"group of clones of Misaka Mikoto produced from a sample of her DNA\" + \"total 20000 clones were created\" + \"less than 10000 are still alive\" + \"emotionally supressed\" + \"speak in third person\" + \"connected to Misaka Network\" + \"were murdered by Accelerator as a part of Level Six shift experiment\"]","constant":false,"selective":false},"15":{"uid":15,"key":["Misaka Network","Radio Noise"],"keysecondary":[],"comment":"","content":"Concept(\"Misaka Network\")[\"also known as Radio Noise\" + \"brainwave network of Sisters\" + \"clones can talk in a quasi-telepathic manner, experience and share the same memories of all the other clones\"]","constant":false,"selective":false},"16":{"uid":16,"key":["Accelerator","strongest"],"keysecondary":[],"comment":"","content":"Person(\"Accelerator\")[\"Male\" + \"Level Five Esper\" + \"ability to manipulate vectors\" + \"strongest Esper of Academy City\" + \"deals with Dark Side of Academy City\" + \"skinny\" + \"pale\" + \"maniacal\" + \"sadistic\"]","constant":false,"selective":false},"17":{"uid":17,"key":["Level Six shift","Level 6 shift","Level 6","Level Six"],"keysecondary":[],"comment":"","content":"Concept(\"Level Six shift\")[\"series of experiments to create a Level Six Esper\" + \"sanctioned by Academy City government\" + \"no successful attempts so far\" + \"no Level Six Espers exist\"]","constant":false,"selective":false}}} \ No newline at end of file +{"entries":{"0":{"uid":0,"key":["Tokiwadai Middle School","Tokiwadai"],"keysecondary":[],"comment":"","content":"Place(\"Tokiwadai Middle School\")[\"prestigious girls' school\" + \"females only\" + \"renowned in the world\" + \"requires Esper ability Level Three or higher\"]","constant":false,"selective":false,"order":8},"1":{"uid":1,"key":["Esper","Ability User","Level"],"keysecondary":[],"comment":"","content":"Category(\"Esper\")[\"psychic\" + \"user of supernatural powers\" + \"scientifically based\" + \"emits AIM\" + \"ranked by Levels of strength\"]","constant":false,"selective":false,"order":5},"2":{"uid":2,"key":["Anti-Skill","Guard","police","Anti Skill"],"keysecondary":[],"comment":"","content":"Faction(\"Anti-Skill\")[\"police of Academy City\" + \"security forces\" + \"SWAT unit\" + \"purple symbol\" + \"blue uniform\" + \"SWAT armor\" + \"riot shields\" + \"firearms\"]","constant":false,"selective":false,"order":5},"3":{"uid":3,"key":["Level 5","Level Five"],"keysecondary":[],"comment":"","content":"Category(\"Level Five Rank\")[\"highest esper level achieved\" + \"only seven people in Academy City have this rank\"]","constant":false,"selective":false,"order":4},"4":{"uid":4,"key":["Academy City","Gakuen Toshi","City"],"keysecondary":[],"comment":"","content":"Place(\"Academy City\")[\"Located west of Tokyo\" + \"city of several schools\" + \"most advanced city in the world\" + \"scientists research on psychic powers and higher technology\" + \"composed of 23 districts\" + \"population over 2 million\"]","constant":false,"selective":false,"order":3},"5":{"uid":5,"key":["Saten Ruiko","Saten","Ruiko","Saten-san"],"keysecondary":[],"comment":"","content":"Character(\"Saten Ruiko\")[\"Female\" + \"outgoing\" + \"friendly\" + \"shameless\" + \"attends Sakugawa Middle School\" + \"Classmate of Uiharu\" + \"Level Zero Esper\" + \"friends with: {Misaka, Uiharu, Kuroko}\"]","constant":false,"selective":false,"order":7},"6":{"uid":6,"key":["Misaka Mikoto","Misaka","Mikoto","Onee-sama"],"keysecondary":[],"comment":"","content":"Character(\"Misaka Mikoto\")[\"Female\" + \"tsundere\" + \"short-tempered\" + \"boyish\" + \"Level Five Esper\" + \"third most powerful esper of Academy City\" + \"attends Tokiwadai Middle School\" + \"Railgun\" + \"Electromaster\" + \"Roommate of Kuroko\" + \"Friends with: {Kuroko, Uiharu, Saten}\"]","constant":false,"selective":false,"order":7},"7":{"uid":7,"key":["Kuroko","Shirai Kuroko","Shirai"],"keysecondary":[],"comment":"","content":"Character(\"Shirai Kuroko\")[\"Female\" + \"Level Four Esper\" + \"Teleporter powers\" + \"attends Tokiwadai Middle School\", \"works at Judgement with Uiharu\" + \"Roommate of Misaka\" + \"obsessed with Misaka\" + \"calls Misaka Onee-sama\" + \"Friends with: {Misaka, Uiharu, Saten}\"]","constant":false,"selective":false,"order":7},"8":{"uid":8,"key":["Uiharu","Uiharu Kazari","Kazari"],"keysecondary":[],"comment":"","content":"Character(\"Uiharu Kazari\")[\"Female\" + \"Level One Esper\" + \"attends Sakugawa Middle School\" + \"Thermal Hand powers\" + \"works for Judgement with Kuroko\" + \"expert in computers and hacking\" + \"wears a flower circlet\" + \"friends with: {Misaka, Saten, Kuroko}\" + \"Classmate of Saten\"]","constant":false,"selective":false,"order":7},"9":{"uid":9,"key":["Judgement"],"keysecondary":[],"comment":"","content":"Faction(\"Judgement\")[\"composed of students\" + \"student-based disciplinary committee\" + \"tasked to maintain peace-and-order within the school system\" + \"members wear armbands on right sleeves\" + \"green shield symbol with white stripes\" + \"known members: {Uiharu, Kuroko}]","constant":false,"selective":false,"order":5},"10":{"uid":10,"key":["AIM","An Involuntary Movement"],"keysecondary":[],"comment":"","content":"Concept(\"AIM\")[\"stands for An Involuntary Movement\" + \"invisible energy field emitting by espers from their body\" + \"can only be detected by machines or specialized espers\"]","constant":false,"selective":false,"order":1},"11":{"uid":11,"key":["Personal Reality"],"keysecondary":[],"comment":"","content":"Concept(\"Personal Reality\")[\"foundation of an esper's power\" + \"the source from which all esper powers brought\"+ \"related to quantum theory\"]","constant":false,"selective":false,"order":1},"12":{"uid":12,"key":["Level Zero","Level 0"],"keysecondary":[],"comment":"","content":"Category(\"Level Zero Rank\")[\"lowest esper rank\" + \"person with no psychic powers or unable to control it\"]","constant":false,"selective":false,"order":5},"13":{"uid":13,"key":["Sakugawa Middle School","Sakugawa"],"keysecondary":[],"comment":"","content":"Place(\"Sakugawa Middle School\")[\"typical co-ed middle school\" + \"attended by Saten and Uiharu\"]","constant":false,"selective":false,"order":5},"14":{"uid":14,"key":["Sisters","Clone"],"keysecondary":[],"comment":"","content":"Faction(\"Sisters\")[\"group of clones of Misaka Mikoto produced from a sample of her DNA\" + \"total 20000 clones were created\" + \"less than 10000 are still alive\" + \"emotionally supressed\" + \"speak in third person\" + \"connected to Misaka Network\" + \"were murdered by Accelerator as a part of Level Six shift experiment\"]","constant":false,"selective":false,"order":6},"15":{"uid":15,"key":["Misaka Network","Radio Noise"],"keysecondary":[],"comment":"","content":"Concept(\"Misaka Network\")[\"also known as Radio Noise\" + \"brainwave network of Sisters\" + \"clones can talk in a quasi-telepathic manner, experience and share the same memories of all the other clones\"]","constant":false,"selective":false,"order":5},"16":{"uid":16,"key":["Accelerator","strongest"],"keysecondary":[],"comment":"","content":"Person(\"Accelerator\")[\"Male\" + \"Level Five Esper\" + \"ability to manipulate vectors\" + \"strongest Esper of Academy City\" + \"deals with Dark Side of Academy City\" + \"skinny\" + \"pale\" + \"maniacal\" + \"sadistic\"]","constant":false,"selective":false,"order":6},"17":{"uid":17,"key":["Level Six shift","Level 6 shift","Level 6","Level Six"],"keysecondary":[],"comment":"","content":"Concept(\"Level Six shift\")[\"series of experiments to create a Level Six Esper\" + \"sanctioned by Academy City government\" + \"no successful attempts so far\" + \"no Level Six Espers exist\"]","constant":false,"selective":false,"order":3}}} \ No newline at end of file