This commit is contained in:
ebolam
2022-08-24 14:10:31 -04:00
parent 851bddd07c
commit 6b429eb032
2 changed files with 8 additions and 5 deletions

View File

@@ -133,7 +133,7 @@ class koboldai_vars(object):
#Add constant world info entries to memory #Add constant world info entries to memory
for wi in self.worldinfo_v2: for wi in self.worldinfo_v2:
if wi['constant']: if wi['constant']:
if used_tokens+wi['token_length'] <= token_budget: if used_tokens+0 if 'token_length' not in wi else wi['token_length'] <= token_budget:
used_tokens+=wi['token_length'] used_tokens+=wi['token_length']
used_world_info.append(wi['uid']) used_world_info.append(wi['uid'])
self.worldinfo_v2.set_world_info_used(wi['uid']) self.worldinfo_v2.set_world_info_used(wi['uid'])
@@ -159,7 +159,7 @@ class koboldai_vars(object):
match=True match=True
break break
if match: if match:
if used_tokens+wi['token_length'] <= token_budget: if used_tokens+0 if 'token_length' not in wi else wi['token_length'] <= token_budget:
used_tokens+=wi['token_length'] used_tokens+=wi['token_length']
used_world_info.append(wi['uid']) used_world_info.append(wi['uid'])
text += wi['content'] text += wi['content']
@@ -236,7 +236,7 @@ class koboldai_vars(object):
match=True match=True
break break
if match: if match:
if used_tokens+wi['token_length'] <= token_budget: if used_tokens+0 if 'token_length' not in wi else wi['token_length'] <= token_budget:
used_tokens+=wi['token_length'] used_tokens+=wi['token_length']
used_world_info.append(wi['uid']) used_world_info.append(wi['uid'])
text += wi['content'] text += wi['content']

View File

@@ -51,6 +51,7 @@ map2.set(3, 'Tail Free Sampling')
map2.set(4, 'Typical Sampling') map2.set(4, 'Typical Sampling')
map2.set(5, 'Temperature') map2.set(5, 'Temperature')
var use_word_highlighting = true; var use_word_highlighting = true;
var calc_token_usage_timeout;
//-----------------------------------Server to UI Functions----------------------------------------------- //-----------------------------------Server to UI Functions-----------------------------------------------
function connect() { function connect() {
console.log("connected"); console.log("connected");
@@ -1466,7 +1467,8 @@ function world_info_entry(data) {
update_token_lengths(); update_token_lengths();
calc_token_usage(); clearTimeout(calc_token_usage_timeout);
calc_token_usage_timeout = setTimeout(calc_token_usage, 200);
return world_info_card; return world_info_card;
} }
@@ -2451,7 +2453,8 @@ function assign_world_info_to_action(action_item, uid) {
} }
function update_token_lengths() { function update_token_lengths() {
calc_token_usage(); clearTimeout(calc_token_usage_timeout);
calc_token_usage_timeout = setTimeout(calc_token_usage, 200);
return return
max_token_length = parseInt(document.getElementById("model_max_length_cur").value); max_token_length = parseInt(document.getElementById("model_max_length_cur").value);
included_world_info = []; included_world_info = [];