mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
W++ Commit. Data can be synced (not used yet, needs formatting)
This commit is contained in:
10
aiserver.py
10
aiserver.py
@@ -7238,19 +7238,23 @@ def UI_2_Rename_World_Info_Folder(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('edit_world_info')
|
@socketio.on('edit_world_info')
|
||||||
def UI_2_edit_world_info(data):
|
def UI_2_edit_world_info(data):
|
||||||
print("Rename_World_Info_Folder")
|
print("edit_world_info")
|
||||||
print(data)
|
print(data)
|
||||||
|
if 'wpp' not in data:
|
||||||
|
wpp = {'name': "", 'type': "", 'attributes': {}}
|
||||||
|
else:
|
||||||
|
wpp = data['wpp']
|
||||||
if data['uid'] == -1:
|
if data['uid'] == -1:
|
||||||
koboldai_vars.worldinfo_v2.add_item(data['title'], data['key'],
|
koboldai_vars.worldinfo_v2.add_item(data['title'], data['key'],
|
||||||
data['keysecondary'], data['folder'],
|
data['keysecondary'], data['folder'],
|
||||||
data['constant'], data['content'],
|
data['constant'], data['content'],
|
||||||
data['comment'])
|
data['comment'], wpp=wpp)
|
||||||
emit("delete_new_world_info_entry", {})
|
emit("delete_new_world_info_entry", {})
|
||||||
else:
|
else:
|
||||||
koboldai_vars.worldinfo_v2.edit_item(data['uid'], data['title'], data['key'],
|
koboldai_vars.worldinfo_v2.edit_item(data['uid'], data['title'], data['key'],
|
||||||
data['keysecondary'], data['folder'],
|
data['keysecondary'], data['folder'],
|
||||||
data['constant'], data['content'],
|
data['constant'], data['content'],
|
||||||
data['comment'])
|
data['comment'], wpp=wpp)
|
||||||
|
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
|
@@ -99,7 +99,7 @@ gensettingstf = [
|
|||||||
"max": 1.0,
|
"max": 1.0,
|
||||||
"step": 0.01,
|
"step": 0.01,
|
||||||
"default": 0.0,
|
"default": 0.0,
|
||||||
"tooltip": "Alternative sampling method that reduces the randomness of the AI whenever the probability of one token is much higher than all the others. Higher values have a stronger effect. (Put this value on 1 to disable its effect)",
|
"tooltip": "Alternative sampling method that reduces the randomness of the AI whenever the probability of one token is much higher than all the others. Higher values have a stronger effect. (Put this value on 0 to disable its effect)",
|
||||||
"menu_path": "Settings",
|
"menu_path": "Settings",
|
||||||
"sub_path": "Sampling",
|
"sub_path": "Sampling",
|
||||||
"classname": "model",
|
"classname": "model",
|
||||||
@@ -189,7 +189,7 @@ gensettingstf = [
|
|||||||
"max": 5,
|
"max": 5,
|
||||||
"step": 1,
|
"step": 1,
|
||||||
"default": 3,
|
"default": 3,
|
||||||
"tooltip": "Number of historic actions to scan for W Info keys.",
|
"tooltip": "Number of historic actions to scan for World Info keys.",
|
||||||
"menu_path": "World Info",
|
"menu_path": "World Info",
|
||||||
"sub_path": "",
|
"sub_path": "",
|
||||||
"classname": "user",
|
"classname": "user",
|
||||||
@@ -264,7 +264,7 @@ gensettingstf = [
|
|||||||
"max": 1,
|
"max": 1,
|
||||||
"step": 1,
|
"step": 1,
|
||||||
"default": 0,
|
"default": 0,
|
||||||
"tooltip": "Scan the AI's output for world info keys as it's generating the output.",
|
"tooltip": "Scan the AI's output for World Info keys as it's generating the output.",
|
||||||
"menu_path": "World Info",
|
"menu_path": "World Info",
|
||||||
"sub_path": "",
|
"sub_path": "",
|
||||||
"classname": "story",
|
"classname": "story",
|
||||||
@@ -565,7 +565,7 @@ gensettingsik =[{
|
|||||||
"max": 5,
|
"max": 5,
|
||||||
"step": 1,
|
"step": 1,
|
||||||
"default": 3,
|
"default": 3,
|
||||||
"tooltip": "Number of historic actions to scan for W Info keys.",
|
"tooltip": "Number of historic actions to scan for World Info keys.",
|
||||||
"menu_path": "User",
|
"menu_path": "User",
|
||||||
"classname": "user",
|
"classname": "user",
|
||||||
"name": "widepth"
|
"name": "widepth"
|
||||||
|
@@ -1166,7 +1166,7 @@ class KoboldWorldInfo(object):
|
|||||||
self.sync_world_info_to_old_format()
|
self.sync_world_info_to_old_format()
|
||||||
self.socketio.emit("world_info_folder", {x: self.world_info_folder[x] for x in self.world_info_folder}, broadcast=True, room="UI_2")
|
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, content, comment):
|
def add_item(self, title, key, keysecondary, folder, constant, content, comment, wpp={'name': "", 'type': "", 'attributes': {}}):
|
||||||
if len(self.world_info) == 0:
|
if len(self.world_info) == 0:
|
||||||
uid = 0
|
uid = 0
|
||||||
else:
|
else:
|
||||||
@@ -1198,7 +1198,8 @@ class KoboldWorldInfo(object):
|
|||||||
"comment": comment,
|
"comment": comment,
|
||||||
"token_length": token_length,
|
"token_length": token_length,
|
||||||
"selective": len(keysecondary) > 0,
|
"selective": len(keysecondary) > 0,
|
||||||
"used_in_game": constant
|
"used_in_game": constant,
|
||||||
|
'wpp': wpp
|
||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
print("Error:")
|
print("Error:")
|
||||||
@@ -1215,7 +1216,7 @@ class KoboldWorldInfo(object):
|
|||||||
self.socketio.emit("world_info_entry", self.world_info[uid], broadcast=True, room="UI_2")
|
self.socketio.emit("world_info_entry", self.world_info[uid], broadcast=True, room="UI_2")
|
||||||
ignore = self.koboldai_vars.calc_ai_text()
|
ignore = self.koboldai_vars.calc_ai_text()
|
||||||
|
|
||||||
def edit_item(self, uid, title, key, keysecondary, folder, constant, content, comment, before=None):
|
def edit_item(self, uid, title, key, keysecondary, folder, constant, content, comment, before=None, wpp={'name': "", 'type': "", 'attributes': {}}):
|
||||||
old_folder = self.world_info[uid]['folder']
|
old_folder = self.world_info[uid]['folder']
|
||||||
#move the world info entry if the folder changed or if there is a new order requested
|
#move the world info entry if the folder changed or if there is a new order requested
|
||||||
if old_folder != folder or before is not None:
|
if old_folder != folder or before is not None:
|
||||||
@@ -1236,7 +1237,9 @@ class KoboldWorldInfo(object):
|
|||||||
"content": content,
|
"content": content,
|
||||||
"comment": comment,
|
"comment": comment,
|
||||||
"token_length": token_length,
|
"token_length": token_length,
|
||||||
"selective": len(keysecondary) > 0
|
"selective": len(keysecondary) > 0,
|
||||||
|
"used_in_game": constant,
|
||||||
|
'wpp': wpp
|
||||||
}
|
}
|
||||||
|
|
||||||
self.story_settings.gamesaved = False
|
self.story_settings.gamesaved = False
|
||||||
|
@@ -680,16 +680,7 @@ td.server_vars {
|
|||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#story_menu_notes{
|
.story_category_area{
|
||||||
margin: 10px 10px 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#story_menu_memory{
|
|
||||||
margin: 10px 10px 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#story_menu_author{
|
|
||||||
margin: 10px 10px 0 10px;
|
margin: 10px 10px 0 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1264,7 +1264,7 @@ function world_info_entry(data) {
|
|||||||
wpp_toggle.id = "world_info_wpp_toggle_"+data.uid;
|
wpp_toggle.id = "world_info_wpp_toggle_"+data.uid;
|
||||||
wpp_toggle.setAttribute("type", "checkbox");
|
wpp_toggle.setAttribute("type", "checkbox");
|
||||||
wpp_toggle.setAttribute("uid", data.uid);
|
wpp_toggle.setAttribute("uid", data.uid);
|
||||||
wpp_toggle.checked = ((data.wpp != "") && (data.wpp != undefined));
|
wpp_toggle.checked = ((data.wpp.type != ""));
|
||||||
wpp_toggle.setAttribute("data-size", "mini");
|
wpp_toggle.setAttribute("data-size", "mini");
|
||||||
wpp_toggle.setAttribute("data-onstyle", "success");
|
wpp_toggle.setAttribute("data-onstyle", "success");
|
||||||
wpp_toggle.setAttribute("data-toggle", "toggle");
|
wpp_toggle.setAttribute("data-toggle", "toggle");
|
||||||
@@ -1283,54 +1283,62 @@ function world_info_entry(data) {
|
|||||||
//w++ data
|
//w++ data
|
||||||
world_info_wpp_area = world_info_card.querySelector('#world_info_wpp_area_');
|
world_info_wpp_area = world_info_card.querySelector('#world_info_wpp_area_');
|
||||||
world_info_wpp_area.id = "world_info_wpp_area_"+data.uid;
|
world_info_wpp_area.id = "world_info_wpp_area_"+data.uid;
|
||||||
|
world_info_wpp_area.setAttribute("uid", data.uid);
|
||||||
wpp_type = world_info_card.querySelector('#wpp_type_');
|
wpp_type = world_info_card.querySelector('#wpp_type_');
|
||||||
wpp_type.id = "wpp_type_"+data.uid;
|
wpp_type.id = "wpp_type_"+data.uid;
|
||||||
wpp_type.setAttribute("uid", data.uid);
|
wpp_type.setAttribute("uid", data.uid);
|
||||||
|
wpp_type.setAttribute("data_type", "type");
|
||||||
if ("wpp" in data) {
|
if ("wpp" in data) {
|
||||||
wpp_type.value = data.wpp.type;
|
wpp_type.value = data.wpp.type;
|
||||||
}
|
}
|
||||||
wpp_name = world_info_card.querySelector('#wpp_name_');
|
wpp_name = world_info_card.querySelector('#wpp_name_');
|
||||||
wpp_name.id = "wpp_name_"+data.uid;
|
wpp_name.id = "wpp_name_"+data.uid;
|
||||||
wpp_name.setAttribute("uid", data.uid);
|
wpp_name.setAttribute("uid", data.uid);
|
||||||
|
wpp_name.setAttribute("data_type", "name");
|
||||||
if ("wpp" in data) {
|
if ("wpp" in data) {
|
||||||
wpp_name.value = data.wpp.name;
|
wpp_name.value = data.wpp.name;
|
||||||
}
|
}
|
||||||
if (data.wpp != null) {
|
if ('attributes' in data.wpp) {
|
||||||
for (attribute of data.wpp.attributes) {
|
for (const [attribute, value] of Object.entries(data.wpp.attributes)) {
|
||||||
attribute_area = document.createElement("div");
|
if (attribute != '') {
|
||||||
label = document.createElement("span");
|
attribute_area = document.createElement("div");
|
||||||
label.textContent = "Attribute: ";
|
label = document.createElement("span");
|
||||||
attribute_area.append(label);
|
label.textContent = "Attribute: ";
|
||||||
input = document.createElement("input");
|
attribute_area.append(label);
|
||||||
input.value = attribute.attribute;
|
input = document.createElement("input");
|
||||||
input.setAttribute("uid", data.uid);
|
input.value = attribute;
|
||||||
input.setAttribute("attribute", attribute.attribute);
|
input.type = "text";
|
||||||
input.onchange = function() {do_wpp(this.parentElement.parentElement)};
|
input.setAttribute("uid", data.uid);
|
||||||
attribute_area.append(input);
|
input.setAttribute("data_type", "attribute");
|
||||||
world_info_wpp_area.append(attribute_area);
|
input.onchange = function() {do_wpp(this.parentElement.parentElement)};
|
||||||
for (value of attribute.values) {
|
attribute_area.append(input);
|
||||||
|
world_info_wpp_area.append(attribute_area);
|
||||||
|
for (value of value) {
|
||||||
|
value_area = document.createElement("div");
|
||||||
|
label = document.createElement("span");
|
||||||
|
label.textContent = " Value: ";
|
||||||
|
value_area.append(label);
|
||||||
|
input = document.createElement("input");
|
||||||
|
input.type = "text";
|
||||||
|
input.onchange = function() {do_wpp(this.parentElement.parentElement)};
|
||||||
|
input.value = value;
|
||||||
|
input.setAttribute("uid", data.uid);
|
||||||
|
input.setAttribute("data_type", "value");
|
||||||
|
value_area.append(input);
|
||||||
|
world_info_wpp_area.append(value_area);
|
||||||
|
}
|
||||||
value_area = document.createElement("div");
|
value_area = document.createElement("div");
|
||||||
label = document.createElement("span");
|
label = document.createElement("span");
|
||||||
label.textContent = " Value: ";
|
label.textContent = " Value: ";
|
||||||
value_area.append(label);
|
value_area.append(label);
|
||||||
input = document.createElement("input");
|
input = document.createElement("input");
|
||||||
input.onchange = function() {do_wpp(this.parentElement.parentElement)};
|
input.type = "text";
|
||||||
input.value = value;
|
|
||||||
input.setAttribute("uid", data.uid);
|
input.setAttribute("uid", data.uid);
|
||||||
input.setAttribute("attribute", attribute.attribute);
|
input.setAttribute("data_type", "value");
|
||||||
|
input.onchange = function() {do_wpp(this.parentElement.parentElement)};
|
||||||
value_area.append(input);
|
value_area.append(input);
|
||||||
world_info_wpp_area.append(value_area);
|
world_info_wpp_area.append(value_area);
|
||||||
}
|
}
|
||||||
value_area = document.createElement("div");
|
|
||||||
label = document.createElement("span");
|
|
||||||
label.textContent = " Value: ";
|
|
||||||
value_area.append(label);
|
|
||||||
input = document.createElement("input");
|
|
||||||
input.setAttribute("uid", data.uid);
|
|
||||||
input.setAttribute("attribute", attribute.attribute);
|
|
||||||
input.onchange = function() {do_wpp(this.parentElement.parentElement)};
|
|
||||||
value_area.append(input);
|
|
||||||
world_info_wpp_area.append(value_area);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attribute_area = document.createElement("div");
|
attribute_area = document.createElement("div");
|
||||||
@@ -1339,8 +1347,9 @@ function world_info_entry(data) {
|
|||||||
attribute_area.append(label);
|
attribute_area.append(label);
|
||||||
input = document.createElement("input");
|
input = document.createElement("input");
|
||||||
input.value = "";
|
input.value = "";
|
||||||
|
input.type = "text";
|
||||||
input.setAttribute("uid", data.uid);
|
input.setAttribute("uid", data.uid);
|
||||||
input.setAttribute("attribute", "");
|
input.setAttribute("data_type", "attribute");
|
||||||
input.onchange = function() {do_wpp(this.parentElement.parentElement)};
|
input.onchange = function() {do_wpp(this.parentElement.parentElement)};
|
||||||
attribute_area.append(input);
|
attribute_area.append(input);
|
||||||
world_info_wpp_area.append(attribute_area);
|
world_info_wpp_area.append(attribute_area);
|
||||||
@@ -1421,6 +1430,16 @@ function world_info_entry(data) {
|
|||||||
|
|
||||||
$('#world_info_constant_'+data.uid).bootstrapToggle();
|
$('#world_info_constant_'+data.uid).bootstrapToggle();
|
||||||
$('#world_info_wpp_toggle_'+data.uid).bootstrapToggle();
|
$('#world_info_wpp_toggle_'+data.uid).bootstrapToggle();
|
||||||
|
|
||||||
|
//hide/unhide w++
|
||||||
|
if (data.wpp.type != "") {
|
||||||
|
world_info_wpp_area.classList.remove("hidden");
|
||||||
|
content_area.classList.add("hidden");
|
||||||
|
} else {
|
||||||
|
world_info_wpp_area.classList.add("hidden");
|
||||||
|
content_area.classList.remove("hidden");
|
||||||
|
}
|
||||||
|
|
||||||
assign_world_info_to_action(null, data.uid);
|
assign_world_info_to_action(null, data.uid);
|
||||||
|
|
||||||
update_token_lengths();
|
update_token_lengths();
|
||||||
@@ -1576,7 +1595,28 @@ function show_error_message(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function do_wpp(wpp_area) {
|
function do_wpp(wpp_area) {
|
||||||
console.log(wpp_area);
|
wpp = {};
|
||||||
|
wpp['attributes'] = {};
|
||||||
|
uid = wpp_area.getAttribute("uid");
|
||||||
|
attribute = "";
|
||||||
|
for (input of wpp_area.querySelectorAll('input')) {
|
||||||
|
if (input.getAttribute("data_type") == "name") {
|
||||||
|
wpp['name'] = input.value;
|
||||||
|
} else if (input.getAttribute("data_type") == "type") {
|
||||||
|
wpp['type'] = input.value;
|
||||||
|
} else if (input.getAttribute("data_type") == "attribute") {
|
||||||
|
attribute = input.value;
|
||||||
|
if (!(input.value in wpp['attributes'])) {
|
||||||
|
console.log("adding attribute");
|
||||||
|
wpp['attributes'][input.value] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (input.getAttribute("data_type") == "value") {
|
||||||
|
wpp['attributes'][attribute].push(input.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
world_info_data[uid]['wpp'] = wpp;
|
||||||
|
send_world_info(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------UI to Server Functions----------------------------------
|
//--------------------------------------------UI to Server Functions----------------------------------
|
||||||
|
@@ -67,31 +67,33 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="story_menu_wi" class="story_category_area hidden">
|
<div id="story_menu_wi" class="story_category_area hidden">
|
||||||
<h4 class="section_header">World Info</h4>
|
<div>
|
||||||
<span class="help_text">
|
<h4 class="section_header">World Info</h4>
|
||||||
Lore information. Recalled by the AI when certain words are used.
|
<span class="help_text">
|
||||||
<span class="helpicon material-icons-outlined" title="Use this instead of Memory for information on things like characters, objects, events, places, and anything else with detail.">help_icon</span>
|
Lore information, which AI recalls using certain words.
|
||||||
</span>
|
<span class="helpicon material-icons-outlined" title="Use this instead of Memory for information on things like characters, objects, events, places, and anything else with detail.">help_icon</span>
|
||||||
<div class="setting_tile_area">
|
|
||||||
{% with menu='World Info' %}
|
|
||||||
{% with sub_path='' %}
|
|
||||||
{% include 'settings item.html' %}
|
|
||||||
{% endwith %}
|
|
||||||
{% endwith %}
|
|
||||||
</div>
|
|
||||||
<div id="WI_Area">
|
|
||||||
<span id="world_info_folder_New Folder" class="WI_Folder">
|
|
||||||
<h2>
|
|
||||||
<span id="world_info_folder_collapse_root" class="wi_folder_collapser material-icons-outlined" folder="root">expand_more</span>
|
|
||||||
<span id="world_info_folder_expand_root" class="wi_folder_collapser material-icons-outlined hidden" folder="root">chevron_right</span>
|
|
||||||
<span class="material-icons-outlined" folder="root">folder</span>
|
|
||||||
<span original_text="root" contenteditable="true">root</span>
|
|
||||||
</h2>
|
|
||||||
<span class="wi_add_button">
|
|
||||||
<span class="material-icons-outlined">post_add</span>
|
|
||||||
<span folder="root">Add World Info Entry</span>
|
|
||||||
</span>
|
|
||||||
</span>
|
</span>
|
||||||
|
<div class="setting_tile_area">
|
||||||
|
{% with menu='World Info' %}
|
||||||
|
{% with sub_path='' %}
|
||||||
|
{% include 'settings item.html' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endwith %}
|
||||||
|
</div>
|
||||||
|
<div id="WI_Area">
|
||||||
|
<span id="world_info_folder_New Folder" class="WI_Folder">
|
||||||
|
<h2>
|
||||||
|
<span id="world_info_folder_collapse_root" class="wi_folder_collapser material-icons-outlined" folder="root">expand_more</span>
|
||||||
|
<span id="world_info_folder_expand_root" class="wi_folder_collapser material-icons-outlined hidden" folder="root">chevron_right</span>
|
||||||
|
<span class="material-icons-outlined" folder="root">folder</span>
|
||||||
|
<span original_text="root" contenteditable="true">root</span>
|
||||||
|
</h2>
|
||||||
|
<span class="wi_add_button">
|
||||||
|
<span class="material-icons-outlined">post_add</span>
|
||||||
|
<span folder="root">Add World Info Entry</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@@ -19,15 +19,11 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Type:</td>
|
<td>Type:</td>
|
||||||
<td><input type=text id="wpp_type_" onchange="world_info_data[this.getAttribute('uid')]['wpp_type'] = this.value;
|
<td><input type=text id="wpp_type_" onchange="do_wpp(this.parentElement.parentElement.parentElement.parentElement.parentElement)"></td>
|
||||||
send_world_info(this.getAttribute('uid'));
|
|
||||||
this.classList.add('pulse');"></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Name:</td>
|
<td>Name:</td>
|
||||||
<td><input type=text id="wpp_name_" onchange="world_info_data[this.getAttribute('uid')]['wpp_type'] = this.value;
|
<td><input type=text id="wpp_name_" onchange="do_wpp(this.parentElement.parentElement.parentElement.parentElement.parentElement)"></td>
|
||||||
send_world_info(this.getAttribute('uid'));
|
|
||||||
this.classList.add('pulse');"></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user