mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Fix for dynamic world info not properly disabling
Fix for world info drag (still can't select text)
This commit is contained in:
54
aiserver.py
54
aiserver.py
@@ -1630,7 +1630,7 @@ def get_oai_models(data):
|
||||
def get_cluster_models(msg):
|
||||
koboldai_vars.oaiapikey = msg['key']
|
||||
koboldai_vars.apikey = koboldai_vars.oaiapikey
|
||||
model = msg['model']
|
||||
model='CLUSTER'
|
||||
url = msg['url']
|
||||
# Get list of models from public cluster
|
||||
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(
|
||||
gen_in[0],
|
||||
max_new=koboldai_vars.genamt,
|
||||
do_streaming=True,
|
||||
do_dynamic_wi=True,
|
||||
do_streaming=koboldai_vars.output_streaming,
|
||||
do_dynamic_wi=koboldai_vars.dynamicscan,
|
||||
batch_count=numseqs,
|
||||
# Real max length is handled by CoreStopper.
|
||||
bypass_hf_maxlength=True,
|
||||
@@ -5182,7 +5182,8 @@ def raw_generate(
|
||||
batch_count: int = 1,
|
||||
bypass_hf_maxlength: bool = False,
|
||||
generation_settings: Optional[dict] = None,
|
||||
is_core: bool = False
|
||||
is_core: bool = False,
|
||||
found_entries: set = ()
|
||||
) -> GenerationResult:
|
||||
|
||||
koboldai_vars.inference_config.do_core = is_core
|
||||
@@ -5460,15 +5461,18 @@ def cluster_raw_generate(
|
||||
cluster_metadata = {
|
||||
'prompt': decoded_prompt,
|
||||
'params': reqdata,
|
||||
'api_key': koboldai_vars.apikey,
|
||||
'models': [x for x in koboldai_vars.cluster_requested_models if x],
|
||||
'trusted_workers': False,
|
||||
}
|
||||
|
||||
cluster_headers = {'apikey': koboldai_vars.apikey}
|
||||
|
||||
try:
|
||||
# Create request
|
||||
req = requests.post(
|
||||
koboldai_vars.colaburl[:-8] + "/api/v1/generate/async",
|
||||
koboldai_vars.colaburl[:-8] + "/api/v2/generate/async",
|
||||
json=cluster_metadata,
|
||||
headers=cluster_headers
|
||||
)
|
||||
except requests.exceptions.ConnectionError:
|
||||
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.",
|
||||
"type": "service_unavailable",
|
||||
}}), mimetype="application/json", status=503))
|
||||
if vars.use_colab_tpu:
|
||||
if koboldai_vars.use_colab_tpu:
|
||||
import tpu_mtj_backend
|
||||
if hasattr(body, "sampler_seed"):
|
||||
# If a seed was specified, we need to save the global RNG state so we
|
||||
# can restore it later
|
||||
old_seed = vars.seed
|
||||
old_rng_state = tpu_mtj_backend.get_rng_state() if vars.use_colab_tpu else torch.get_rng_state()
|
||||
vars.seed = body.sampler_seed
|
||||
old_seed = koboldai_vars.seed
|
||||
old_rng_state = tpu_mtj_backend.get_rng_state() if koboldai_vars.use_colab_tpu else torch.get_rng_state()
|
||||
koboldai_vars.seed = body.sampler_seed
|
||||
# We should try to use a previously saved RNG state with the same seed
|
||||
if body.sampler_seed in vars.rng_states:
|
||||
if vars.use_colab_tpu:
|
||||
tpu_mtj_backend.set_rng_state(vars.rng_states[body.sampler_seed])
|
||||
if body.sampler_seed in koboldai_vars.rng_states:
|
||||
if koboldai_vars.use_colab_tpu:
|
||||
tpu_mtj_backend.set_rng_state(koboldai_vars.rng_states[body.sampler_seed])
|
||||
else:
|
||||
torch.set_rng_state(vars.rng_states[body.sampler_seed])
|
||||
torch.set_rng_state(koboldai_vars.rng_states[body.sampler_seed])
|
||||
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))
|
||||
else:
|
||||
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 len(body.sampler_order) < 7:
|
||||
body.sampler_order = [6] + body.sampler_order
|
||||
@@ -9452,8 +9456,8 @@ def _generate_text(body: GenerationInputSchema):
|
||||
"max_context_length": ("koboldai_vars", "max_length", None),
|
||||
"n": ("koboldai_vars", "numseqs", None),
|
||||
"quiet": ("koboldai_vars", "quiet", None),
|
||||
"sampler_order": ("vars", "sampler_order", None),
|
||||
"sampler_full_determinism": ("vars", "full_determinism", None),
|
||||
"sampler_order": ("koboldai_vars", "sampler_order", None),
|
||||
"sampler_full_determinism": ("koboldai_vars", "full_determinism", None),
|
||||
}
|
||||
saved_settings = {}
|
||||
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:
|
||||
spRequest(old_spfilename)
|
||||
if hasattr(body, "sampler_seed"):
|
||||
vars.seed = old_seed
|
||||
if vars.use_colab_tpu:
|
||||
koboldai_vars.seed = old_seed
|
||||
if koboldai_vars.use_colab_tpu:
|
||||
tpu_mtj_backend.set_rng_state(old_rng_state)
|
||||
else:
|
||||
torch.set_rng_state(old_rng_state)
|
||||
@@ -11734,7 +11738,7 @@ def get_config_sampler_seed():
|
||||
example:
|
||||
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_schema_wrap
|
||||
@@ -11759,13 +11763,13 @@ def put_config_sampler_seed(body: SamplerSeedSettingSchema):
|
||||
schema: EmptySchema
|
||||
{api_validation_error_response}
|
||||
"""
|
||||
if vars.use_colab_tpu:
|
||||
if koboldai_vars.use_colab_tpu:
|
||||
import tpu_mtj_backend
|
||||
tpu_mtj_backend.set_rng_seed(body.value)
|
||||
else:
|
||||
import torch
|
||||
torch.manual_seed(body.value)
|
||||
vars.seed = body.value
|
||||
koboldai_vars.seed = body.value
|
||||
return {}
|
||||
|
||||
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)
|
||||
class KoboldMeta:
|
||||
route_name = "sampler_order"
|
||||
obj = "vars"
|
||||
obj = "koboldai_vars"
|
||||
var_name = "sampler_order"
|
||||
name = "sampler order"
|
||||
example_yaml_value = "[6, 0, 1, 2, 3, 4, 5]"
|
||||
@@ -11980,7 +11984,7 @@ class SamplerFullDeterminismSettingSchema(KoboldSchema):
|
||||
value = fields.Boolean(required=True)
|
||||
class KoboldMeta:
|
||||
route_name = "sampler_full_determinism"
|
||||
obj = "vars"
|
||||
obj = "koboldai_vars"
|
||||
var_name = "full_determinism"
|
||||
name = "sampler full determinism"
|
||||
example_yaml_value = "false"
|
||||
|
@@ -1639,6 +1639,7 @@ function world_info_entry(data) {
|
||||
title.setAttribute("uid", data.uid);
|
||||
title.setAttribute("original_text", data.title);
|
||||
title.setAttribute("contenteditable", true);
|
||||
title.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
|
||||
title.onblur = function () {
|
||||
if (this.textContent != this.getAttribute("original_text")) {
|
||||
world_info_data[this.getAttribute('uid')]['title'] = this.textContent;
|
||||
@@ -1738,6 +1739,7 @@ function world_info_entry(data) {
|
||||
label.textContent = "\xa0\xa0\xa0\xa0Attribute: ";
|
||||
attribute_area.append(label);
|
||||
input = document.createElement("input");
|
||||
input.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
|
||||
input.value = attribute;
|
||||
input.type = "text";
|
||||
input.setAttribute("uid", data.uid);
|
||||
@@ -1755,6 +1757,7 @@ function world_info_entry(data) {
|
||||
value_area.append(label);
|
||||
input = document.createElement("input");
|
||||
input.type = "text";
|
||||
input.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
|
||||
input.onchange = function() {do_wpp(this.parentElement.parentElement)};
|
||||
input.value = value;
|
||||
input.setAttribute("uid", data.uid);
|
||||
@@ -1769,6 +1772,7 @@ function world_info_entry(data) {
|
||||
value_area.append(label);
|
||||
input = document.createElement("input");
|
||||
input.type = "text";
|
||||
input.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
|
||||
input.setAttribute("uid", data.uid);
|
||||
input.setAttribute("data_type", "value");
|
||||
input.id = "wpp_"+data.uid+"_value_"+i+"_blank";
|
||||
@@ -1786,6 +1790,7 @@ function world_info_entry(data) {
|
||||
input = document.createElement("input");
|
||||
input.value = "";
|
||||
input.type = "text";
|
||||
input.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
|
||||
input.setAttribute("uid", data.uid);
|
||||
input.setAttribute("value_num", i);
|
||||
input.setAttribute("data_type", "attribute");
|
||||
@@ -3038,6 +3043,8 @@ function add_tags(tags, data) {
|
||||
for (tag of data.key) {
|
||||
tag_item = document.createElement("span");
|
||||
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.textContent = "x ";
|
||||
x.classList.add("delete_icon");
|
||||
@@ -3103,6 +3110,7 @@ function add_secondary_tags(tags, data) {
|
||||
for (tag of data.keysecondary) {
|
||||
tag_item = document.createElement("span");
|
||||
tag_item.classList.add("tag");
|
||||
tag_item.ondragstart=function() {console.log("Killing drag");event.preventDefault();event.stopPropagation();};
|
||||
x = document.createElement("span");
|
||||
x.textContent = "x ";
|
||||
x.classList.add("delete_icon");
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<div draggable="true" class="world_info_card" id="world_info_">
|
||||
<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>
|
||||
</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
|
||||
</div>
|
||||
<div id="world_info_tags_" class="world_info_tag_area">
|
||||
@@ -24,28 +24,28 @@
|
||||
<table>
|
||||
<tr>
|
||||
<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>
|
||||
<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>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div id="world_info_basic_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 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>
|
||||
<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>
|
||||
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 id="empty_bias">
|
||||
|
Reference in New Issue
Block a user