mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Track original text
This commit is contained in:
@@ -8526,7 +8526,12 @@ def UI_2_download_story():
|
||||
def UI_2_Set_Selected_Text(data):
|
||||
if not koboldai_vars.quiet:
|
||||
print("Updating Selected Text: {}".format(data))
|
||||
koboldai_vars.actions[int(data['id'])] = data['text']
|
||||
action_id = int(data["id"])
|
||||
|
||||
if not koboldai_vars.actions.actions[action_id].get("Original Text"):
|
||||
koboldai_vars.actions.actions[action_id]["Original Text"] = data["text"]
|
||||
|
||||
koboldai_vars.actions[action_id] = data['text']
|
||||
|
||||
#==================================================================#
|
||||
# Event triggered when Option is Selected
|
||||
|
@@ -1471,7 +1471,7 @@ class KoboldStoryRegister(object):
|
||||
old_text = None
|
||||
old_length = None
|
||||
old = None
|
||||
self.actions[i] = {"Selected Text": text, "Probabilities": [], "Options": [], "Time": int(time.time())}
|
||||
self.actions[i] = {"Selected Text": text, "Probabilities": [], "Options": [], "Time": int(time.time()), "Original Text": text}
|
||||
|
||||
self.story_settings.assign_world_info_to_actions(action_id=i, no_transmit=True)
|
||||
process_variable_changes(self.socketio, "story", 'actions', {"id": i, 'action': self.actions[i]}, old)
|
||||
@@ -1510,6 +1510,9 @@ class KoboldStoryRegister(object):
|
||||
if "Time" not in json_data["actions"][item]:
|
||||
json_data["actions"][item]["Time"] = int(time.time())
|
||||
|
||||
if "Original Text" not in json_data["actions"][item]:
|
||||
json_data["actions"][item]["Original Text"] = json_data["actions"][item]["Selected Text"]
|
||||
|
||||
temp[int(item)] = json_data['actions'][item]
|
||||
if int(item) >= self.action_count-100: #sending last 100 items to UI
|
||||
data_to_send.append({"id": item, 'action': temp[int(item)]})
|
||||
@@ -1548,6 +1551,7 @@ class KoboldStoryRegister(object):
|
||||
if self.actions[action_id]["Selected Text"] != text:
|
||||
self.actions[action_id]["Selected Text"] = text
|
||||
self.actions[action_id]["Time"] = self.actions[action_id].get("Time", int(time.time()))
|
||||
self.actions[action_id]["Original Text"] = self.actions[action_id].get("Original Text", text)
|
||||
if 'buffer' in self.actions[action_id]:
|
||||
if self.koboldai_vars.tokenizer is not None:
|
||||
tokens = self.koboldai_vars.tokenizer.encode(text)
|
||||
@@ -1573,6 +1577,7 @@ class KoboldStoryRegister(object):
|
||||
"Options": [],
|
||||
"Probabilities": [],
|
||||
"Time": int(time.time()),
|
||||
"Original Text": text,
|
||||
}
|
||||
|
||||
if submission:
|
||||
|
Reference in New Issue
Block a user