Combine constant with types in wi

This commit is contained in:
somebody
2022-11-12 16:47:23 -06:00
parent 0d3f0a9788
commit ad7fa36c2f
5 changed files with 58 additions and 30 deletions

View File

@@ -8643,7 +8643,7 @@ def UI_2_edit_world_info(data):
koboldai_vars.worldinfo_v2.edit_item(data['uid'], data['title'], data['key'],
data['keysecondary'], data['folder'],
data['constant'], data['manual_text'],
data['comment'], wpp=data['wpp'], use_wpp=data['use_wpp'])
data['comment'], wi_type=data["type"], wpp=data['wpp'], use_wpp=data['use_wpp'])
#==================================================================#

View File

@@ -1727,7 +1727,8 @@ class KoboldWorldInfo(object):
self.socketio.emit("world_info_folder", {x: self.world_info_folder[x] for x in self.world_info_folder}, broadcast=True, room="UI_2")
def add_item(self, title, key, keysecondary, folder, constant, manual_text,
comment, use_wpp=False, wpp={'name': "", 'type': "", 'format': "W++", 'attributes': {}},
comment, wi_type="World Info", use_wpp=False,
wpp={'name': "", 'type': "", 'format': "W++", 'attributes': {}},
v1_uid=None, recalc=True, sync=True, send_to_ui=True):
if len(self.world_info) == 0:
uid = 0
@@ -1772,6 +1773,7 @@ class KoboldWorldInfo(object):
'manual_text': manual_text,
"content": content,
"comment": comment,
"type": wi_type,
"token_length": token_length,
"selective": len(keysecondary) > 0,
"used_in_game": constant,
@@ -1801,7 +1803,7 @@ class KoboldWorldInfo(object):
ignore = self.koboldai_vars.calc_ai_text()
return uid
def edit_item(self, uid, title, key, keysecondary, folder, constant, manual_text, comment, use_wpp=False, before=None, wpp={'name': "", 'type': "", 'format': "W++", 'attributes': {}}):
def edit_item(self, uid, title, key, keysecondary, folder, constant, manual_text, comment, wi_type, use_wpp=False, before=None, wpp={'name': "", 'type': "", 'format': "W++", 'attributes': {}}):
logger.debug("Editing World Info {}: {}".format(uid, title))
old_folder = self.world_info[uid]['folder']
#move the world info entry if the folder changed or if there is a new order requested
@@ -1836,6 +1838,7 @@ class KoboldWorldInfo(object):
'manual_text': manual_text,
"content": content,
"comment": comment,
"type": wi_type,
"token_length": token_length,
"selective": len(keysecondary) > 0,
"used_in_game": constant,
@@ -1943,6 +1946,7 @@ class KoboldWorldInfo(object):
item['constant'] if 'constant' in item else False,
item['manual_text'] if 'manual_text' in item else item['content'],
item['comment'] if 'comment' in item else '',
item.get('type', "World Info"),
use_wpp=item['use_wpp'] if 'use_wpp' in item else False,
wpp=item['wpp'] if 'wpp' in item else {'name': "", 'type': "", 'format': "W++", 'attributes': {}},
recalc=False, sync=False)

View File

@@ -1087,6 +1087,19 @@ td.server_vars {
filter: brightness(90%);
}
.world_info_always_include {
display: inline-block;
}
.world_info_upper_container {
display: flex;
justify-content: space-between;
}
.world_info_type {
margin: 0px;
}
.world_info_text {
width: auto;
margin: 0 0px 0px;

View File

@@ -1895,6 +1895,30 @@ function world_info_entry(data) {
reader.readAsDataURL(file);
});
const wiTypeSelector = world_info_card.querySelector(".world_info_type");
wiTypeSelector.value = world_info_data[data.uid].type;
wiTypeSelector.classList.remove("pulse");
wiTypeSelector.addEventListener("change", function(event) {
console.log(event);
switch (wiTypeSelector.value) {
case "Chat Character":
world_info_data[data.uid].constant = true;
break;
case "Memory":
world_info_data[data.uid].constant = true;
break;
case "World Info":
world_info_data[data.uid].constant = false;
break;
default:
reportError("Error", `Unknown WI type ${wiTypeSelector.value}`);
return;
}
world_info_data[data.uid].type = wiTypeSelector.value;
send_world_info(data.uid);
this.classList.add("pulse");
})
tags = world_info_card.querySelector('.world_info_tag_primary_area');
tags.id = "world_info_tags_"+data.uid;
//add tag content here
@@ -2078,27 +2102,6 @@ function world_info_entry(data) {
this.classList.add("pulse");
}
comment.classList.remove("pulse");
constant_area = world_info_card.querySelector('.world_info_always_include');
constant_area.id = "world_info_toggle_area_"+data.uid;
if (document.getElementById("world_info_constant_"+data.uid)) {
constant = document.getElementById("world_info_constant_"+data.uid);
} else {
constant = document.createElement("input");
constant.id = "world_info_constant_"+data.uid;
constant.setAttribute("type", "checkbox");
constant.setAttribute("uid", data.uid);
constant.setAttribute("data-size", "mini");
constant.setAttribute("data-onstyle", "success");
constant.setAttribute("data-toggle", "toggle");
constant.onchange = function () {
world_info_data[this.getAttribute('uid')]['constant'] = this.checked;
send_world_info(this.getAttribute('uid'));
this.classList.add("pulse");
}
constant_area.append(constant);
}
constant.checked = data.constant;
constant.classList.remove("pulse");
//Let's figure out the order to insert this card
var found = false;

View File

@@ -11,18 +11,26 @@
</div>
<span id="world_info_delete_" class="world_info_delete">X</span>
</div>
<div class="world_info_tag_area world_info_always_include" id="world_info_toggle_area_">
Always Include
<div class="world_info_upper_container world_info_tag_area">
<div class="world_info_wpp_toggle_area" id="world_info_wpp_toggle_area_">
Use W++
</div>
<select class="world_info_type settings_select">
<option>World Info</option>
<option>Memory</option>
<option>Chat Character</option>
</select>
</div>
<div id="world_info_tags_" class="world_info_tag_area world_info_tag_primary_area">
<div>Requires one of:</div>
</div>
<div id="world_info_secondtags_" class="world_info_tag_area world_info_tag_secondary_area">
<div>And (if present):</div>
</div>
<div class="world_info_tag_area world_info_wpp_toggle_area" id="world_info_wpp_toggle_area_">
Use W++
</div>
<div class="world_info_tag_area hidden world_info_wpp_area" id="world_info_wpp_area_">
<!--this part is very sensitive to location. Javascript uses parents to find the above tag for each of the inputs, so don't add stuff without messing with JS-->
<select id="wpp_format_" class="settings_select wpp_format">