Fix for dynamic world info not properly disabling

Fix for world info drag (still can't select text)
This commit is contained in:
ebolam
2022-10-14 10:50:56 -04:00
parent 1c0d0d8cef
commit 022b729cd9
3 changed files with 45 additions and 33 deletions

View File

@@ -1630,7 +1630,7 @@ def get_oai_models(data):
def get_cluster_models(msg): def get_cluster_models(msg):
koboldai_vars.oaiapikey = msg['key'] koboldai_vars.oaiapikey = msg['key']
koboldai_vars.apikey = koboldai_vars.oaiapikey koboldai_vars.apikey = koboldai_vars.oaiapikey
model = msg['model'] model='CLUSTER'
url = msg['url'] url = msg['url']
# Get list of models from public cluster # Get list of models from public cluster
print("{0}Retrieving engine list...{1}".format(colors.PURPLE, colors.END), end="") print("{0}Retrieving engine list...{1}".format(colors.PURPLE, colors.END), end="")
@@ -5048,8 +5048,8 @@ def core_generate(text: list, min: int, max: int, found_entries: set, is_core: b
result = raw_generate( result = raw_generate(
gen_in[0], gen_in[0],
max_new=koboldai_vars.genamt, max_new=koboldai_vars.genamt,
do_streaming=True, do_streaming=koboldai_vars.output_streaming,
do_dynamic_wi=True, do_dynamic_wi=koboldai_vars.dynamicscan,
batch_count=numseqs, batch_count=numseqs,
# Real max length is handled by CoreStopper. # Real max length is handled by CoreStopper.
bypass_hf_maxlength=True, bypass_hf_maxlength=True,
@@ -5182,7 +5182,8 @@ def raw_generate(
batch_count: int = 1, batch_count: int = 1,
bypass_hf_maxlength: bool = False, bypass_hf_maxlength: bool = False,
generation_settings: Optional[dict] = None, generation_settings: Optional[dict] = None,
is_core: bool = False is_core: bool = False,
found_entries: set = ()
) -> GenerationResult: ) -> GenerationResult:
koboldai_vars.inference_config.do_core = is_core koboldai_vars.inference_config.do_core = is_core
@@ -5460,15 +5461,18 @@ def cluster_raw_generate(
cluster_metadata = { cluster_metadata = {
'prompt': decoded_prompt, 'prompt': decoded_prompt,
'params': reqdata, 'params': reqdata,
'api_key': koboldai_vars.apikey,
'models': [x for x in koboldai_vars.cluster_requested_models if x], 'models': [x for x in koboldai_vars.cluster_requested_models if x],
'trusted_workers': False,
} }
cluster_headers = {'apikey': koboldai_vars.apikey}
try: try:
# Create request # Create request
req = requests.post( req = requests.post(
koboldai_vars.colaburl[:-8] + "/api/v1/generate/async", koboldai_vars.colaburl[:-8] + "/api/v2/generate/async",
json=cluster_metadata, json=cluster_metadata,
headers=cluster_headers
) )
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
errmsg = f"Horde unavailable. Please try again later" errmsg = f"Horde unavailable. Please try again later"
@@ -9404,26 +9408,26 @@ def _generate_text(body: GenerationInputSchema):
"msg": "Server is busy; please try again later.", "msg": "Server is busy; please try again later.",
"type": "service_unavailable", "type": "service_unavailable",
}}), mimetype="application/json", status=503)) }}), mimetype="application/json", status=503))
if vars.use_colab_tpu: if koboldai_vars.use_colab_tpu:
import tpu_mtj_backend import tpu_mtj_backend
if hasattr(body, "sampler_seed"): if hasattr(body, "sampler_seed"):
# If a seed was specified, we need to save the global RNG state so we # If a seed was specified, we need to save the global RNG state so we
# can restore it later # can restore it later
old_seed = vars.seed old_seed = koboldai_vars.seed
old_rng_state = tpu_mtj_backend.get_rng_state() if vars.use_colab_tpu else torch.get_rng_state() old_rng_state = tpu_mtj_backend.get_rng_state() if koboldai_vars.use_colab_tpu else torch.get_rng_state()
vars.seed = body.sampler_seed koboldai_vars.seed = body.sampler_seed
# We should try to use a previously saved RNG state with the same seed # We should try to use a previously saved RNG state with the same seed
if body.sampler_seed in vars.rng_states: if body.sampler_seed in koboldai_vars.rng_states:
if vars.use_colab_tpu: if koboldai_vars.use_colab_tpu:
tpu_mtj_backend.set_rng_state(vars.rng_states[body.sampler_seed]) tpu_mtj_backend.set_rng_state(koboldai_vars.rng_states[body.sampler_seed])
else: else:
torch.set_rng_state(vars.rng_states[body.sampler_seed]) torch.set_rng_state(koboldai_vars.rng_states[body.sampler_seed])
else: else:
if vars.use_colab_tpu: if koboldai_vars.use_colab_tpu:
tpu_mtj_backend.set_rng_state(tpu_mtj_backend.new_rng_state(body.sampler_seed)) tpu_mtj_backend.set_rng_state(tpu_mtj_backend.new_rng_state(body.sampler_seed))
else: else:
torch.manual_seed(body.sampler_seed) torch.manual_seed(body.sampler_seed)
vars.rng_states[body.sampler_seed] = tpu_mtj_backend.get_rng_state() if vars.use_colab_tpu else torch.get_rng_state() koboldai_vars.rng_states[body.sampler_seed] = tpu_mtj_backend.get_rng_state() if koboldai_vars.use_colab_tpu else torch.get_rng_state()
if hasattr(body, "sampler_order"): if hasattr(body, "sampler_order"):
if len(body.sampler_order) < 7: if len(body.sampler_order) < 7:
body.sampler_order = [6] + body.sampler_order body.sampler_order = [6] + body.sampler_order
@@ -9452,8 +9456,8 @@ def _generate_text(body: GenerationInputSchema):
"max_context_length": ("koboldai_vars", "max_length", None), "max_context_length": ("koboldai_vars", "max_length", None),
"n": ("koboldai_vars", "numseqs", None), "n": ("koboldai_vars", "numseqs", None),
"quiet": ("koboldai_vars", "quiet", None), "quiet": ("koboldai_vars", "quiet", None),
"sampler_order": ("vars", "sampler_order", None), "sampler_order": ("koboldai_vars", "sampler_order", None),
"sampler_full_determinism": ("vars", "full_determinism", None), "sampler_full_determinism": ("koboldai_vars", "full_determinism", None),
} }
saved_settings = {} saved_settings = {}
set_aibusy(1) set_aibusy(1)
@@ -9504,8 +9508,8 @@ def _generate_text(body: GenerationInputSchema):
if koboldai_vars.allowsp and getattr(body, "soft_prompt", None) is not None: if koboldai_vars.allowsp and getattr(body, "soft_prompt", None) is not None:
spRequest(old_spfilename) spRequest(old_spfilename)
if hasattr(body, "sampler_seed"): if hasattr(body, "sampler_seed"):
vars.seed = old_seed koboldai_vars.seed = old_seed
if vars.use_colab_tpu: if koboldai_vars.use_colab_tpu:
tpu_mtj_backend.set_rng_state(old_rng_state) tpu_mtj_backend.set_rng_state(old_rng_state)
else: else:
torch.set_rng_state(old_rng_state) torch.set_rng_state(old_rng_state)
@@ -11734,7 +11738,7 @@ def get_config_sampler_seed():
example: example:
value: 3475097509890965500 value: 3475097509890965500
""" """
return {"value": __import__("tpu_mtj_backend").get_rng_seed() if vars.use_colab_tpu else __import__("torch").initial_seed()} return {"value": __import__("tpu_mtj_backend").get_rng_seed() if koboldai_vars.use_colab_tpu else __import__("torch").initial_seed()}
@api_v1.put("/config/sampler_seed") @api_v1.put("/config/sampler_seed")
@api_schema_wrap @api_schema_wrap
@@ -11759,13 +11763,13 @@ def put_config_sampler_seed(body: SamplerSeedSettingSchema):
schema: EmptySchema schema: EmptySchema
{api_validation_error_response} {api_validation_error_response}
""" """
if vars.use_colab_tpu: if koboldai_vars.use_colab_tpu:
import tpu_mtj_backend import tpu_mtj_backend
tpu_mtj_backend.set_rng_seed(body.value) tpu_mtj_backend.set_rng_seed(body.value)
else: else:
import torch import torch
torch.manual_seed(body.value) torch.manual_seed(body.value)
vars.seed = body.value koboldai_vars.seed = body.value
return {} return {}
config_endpoint_schemas: List[Type[KoboldSchema]] = [] config_endpoint_schemas: List[Type[KoboldSchema]] = []
@@ -11970,7 +11974,7 @@ class SamplerOrderSettingSchema(KoboldSchema):
value = fields.List(fields.Integer(), validate=[validate.Length(min=6), permutation_validator], required=True) value = fields.List(fields.Integer(), validate=[validate.Length(min=6), permutation_validator], required=True)
class KoboldMeta: class KoboldMeta:
route_name = "sampler_order" route_name = "sampler_order"
obj = "vars" obj = "koboldai_vars"
var_name = "sampler_order" var_name = "sampler_order"
name = "sampler order" name = "sampler order"
example_yaml_value = "[6, 0, 1, 2, 3, 4, 5]" example_yaml_value = "[6, 0, 1, 2, 3, 4, 5]"
@@ -11980,7 +11984,7 @@ class SamplerFullDeterminismSettingSchema(KoboldSchema):
value = fields.Boolean(required=True) value = fields.Boolean(required=True)
class KoboldMeta: class KoboldMeta:
route_name = "sampler_full_determinism" route_name = "sampler_full_determinism"
obj = "vars" obj = "koboldai_vars"
var_name = "full_determinism" var_name = "full_determinism"
name = "sampler full determinism" name = "sampler full determinism"
example_yaml_value = "false" example_yaml_value = "false"

View File

@@ -1639,6 +1639,7 @@ function world_info_entry(data) {
title.setAttribute("uid", data.uid); title.setAttribute("uid", data.uid);
title.setAttribute("original_text", data.title); title.setAttribute("original_text", data.title);
title.setAttribute("contenteditable", true); title.setAttribute("contenteditable", true);
title.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
title.onblur = function () { title.onblur = function () {
if (this.textContent != this.getAttribute("original_text")) { if (this.textContent != this.getAttribute("original_text")) {
world_info_data[this.getAttribute('uid')]['title'] = this.textContent; world_info_data[this.getAttribute('uid')]['title'] = this.textContent;
@@ -1738,6 +1739,7 @@ function world_info_entry(data) {
label.textContent = "\xa0\xa0\xa0\xa0Attribute: "; label.textContent = "\xa0\xa0\xa0\xa0Attribute: ";
attribute_area.append(label); attribute_area.append(label);
input = document.createElement("input"); input = document.createElement("input");
input.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
input.value = attribute; input.value = attribute;
input.type = "text"; input.type = "text";
input.setAttribute("uid", data.uid); input.setAttribute("uid", data.uid);
@@ -1755,6 +1757,7 @@ function world_info_entry(data) {
value_area.append(label); value_area.append(label);
input = document.createElement("input"); input = document.createElement("input");
input.type = "text"; input.type = "text";
input.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
input.onchange = function() {do_wpp(this.parentElement.parentElement)}; input.onchange = function() {do_wpp(this.parentElement.parentElement)};
input.value = value; input.value = value;
input.setAttribute("uid", data.uid); input.setAttribute("uid", data.uid);
@@ -1769,6 +1772,7 @@ function world_info_entry(data) {
value_area.append(label); value_area.append(label);
input = document.createElement("input"); input = document.createElement("input");
input.type = "text"; input.type = "text";
input.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
input.setAttribute("uid", data.uid); input.setAttribute("uid", data.uid);
input.setAttribute("data_type", "value"); input.setAttribute("data_type", "value");
input.id = "wpp_"+data.uid+"_value_"+i+"_blank"; input.id = "wpp_"+data.uid+"_value_"+i+"_blank";
@@ -1786,6 +1790,7 @@ function world_info_entry(data) {
input = document.createElement("input"); input = document.createElement("input");
input.value = ""; input.value = "";
input.type = "text"; input.type = "text";
input.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
input.setAttribute("uid", data.uid); input.setAttribute("uid", data.uid);
input.setAttribute("value_num", i); input.setAttribute("value_num", i);
input.setAttribute("data_type", "attribute"); input.setAttribute("data_type", "attribute");
@@ -3038,6 +3043,8 @@ function add_tags(tags, data) {
for (tag of data.key) { for (tag of data.key) {
tag_item = document.createElement("span"); tag_item = document.createElement("span");
tag_item.classList.add("tag"); tag_item.classList.add("tag");
tag_item.setAttribute("draggable", true);
tag_item.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
x = document.createElement("span"); x = document.createElement("span");
x.textContent = "x "; x.textContent = "x ";
x.classList.add("delete_icon"); x.classList.add("delete_icon");
@@ -3103,6 +3110,7 @@ function add_secondary_tags(tags, data) {
for (tag of data.keysecondary) { for (tag of data.keysecondary) {
tag_item = document.createElement("span"); tag_item = document.createElement("span");
tag_item.classList.add("tag"); tag_item.classList.add("tag");
tag_item.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
x = document.createElement("span"); x = document.createElement("span");
x.textContent = "x "; x.textContent = "x ";
x.classList.add("delete_icon"); x.classList.add("delete_icon");

View File

@@ -1,9 +1,9 @@
<div draggable="true" class="world_info_card" id="world_info_"> <div draggable="true" class="world_info_card" id="world_info_">
<div class="world_info_title_area"> <div class="world_info_title_area">
<h4 id="world_info_title_" class="world_info_title"></h4> <h4 draggable="true" ondragstart="event.preventDefault();event.stopPropagation();" id="world_info_title_" class="world_info_title"></h4>
<span id="world_info_delete_" class="world_info_delete">X</span> <span id="world_info_delete_" class="world_info_delete">X</span>
</div> </div>
<div class="world_info_tag_area" id="world_info_toggle_area_"> <div class="world_info_tag_area" id="world_info_toggle_area_">
Always Include Always Include
</div> </div>
<div id="world_info_tags_" class="world_info_tag_area"> <div id="world_info_tags_" class="world_info_tag_area">
@@ -24,28 +24,28 @@
<table> <table>
<tr> <tr>
<td>Type:</td> <td>Type:</td>
<td><input type=text id="wpp_type_" onchange="do_wpp(this.parentElement.parentElement.parentElement.parentElement.parentElement)"></td> <td><input draggable="true" ondragstart="event.preventDefault();event.stopPropagation();" type=text id="wpp_type_" onchange="do_wpp(this.parentElement.parentElement.parentElement.parentElement.parentElement)"></td>
</tr> </tr>
<tr> <tr>
<td>Name:</td> <td>Name:</td>
<td><input type=text id="wpp_name_" onchange="do_wpp(this.parentElement.parentElement.parentElement.parentElement.parentElement)"></td> <td><input draggable="true" ondragstart="event.preventDefault();event.stopPropagation();" type=text id="wpp_name_" onchange="do_wpp(this.parentElement.parentElement.parentElement.parentElement.parentElement)"></td>
</tr> </tr>
</table> </table>
</div> </div>
<div id="world_info_basic_text_"> <div id="world_info_basic_text_">
Text: Text:
<textarea id="world_info_entry_text_" class="world_info_text fullwidth" oninput="autoResize(this, 60)" onfocus="autoResize(this, 60)" onblur="this.style.height='60px';"></textarea> <textarea draggable="true" ondragstart="event.preventDefault();event.stopPropagation();" id="world_info_entry_text_" class="world_info_text fullwidth" oninput="autoResize(this, 60)" onfocus="autoResize(this, 60)" onblur="this.style.height='60px';"></textarea>
</div> </div>
<div id="world_info_entry_w++_" class="hidden"> <div id="world_info_entry_w++_" class="hidden">
<input type=text placeholder="Type"/><input type=text placeholder="Name"/> <input draggable="true" ondragstart="event.preventDefault();event.stopPropagation();" type=text placeholder="Type"/><input type=text placeholder="Name"/>
<div> <div>
<input type=text placeholder="attribute"/><input type=text placeholder="value"/> <input draggable="true" ondragstart="event.preventDefault();event.stopPropagation();" type=text placeholder="attribute"/><input type=text placeholder="value"/>
</div> </div>
</div> </div>
<div> <div>
Comment: Comment:
<textarea rows=1 id="world_info_comment_" class="world_info_text fullwidth" oninput="autoResize(this, 60)" onfocus="autoResize(this, 60)" onblur="this.style.height='60px';"></textarea> <textarea draggable="true" ondragstartondragstart="event.preventDefault();event.stopPropagation();" rows=1 id="world_info_comment_" class="world_info_text fullwidth" oninput="autoResize(this, 60)" onfocus="autoResize(this, 60)" onblur="this.style.height='60px';"></textarea>
</div> </div>
</div> </div>
<div id="empty_bias"> <div id="empty_bias">