Combine append and append_submit, add docstring to append.

Combine the append and append_submit methods, and add an optional
parameter to append to indicate whether it is a submission.
Add a docstring to append.
This commit is contained in:
Llama
2022-11-25 21:35:01 -08:00
parent 37257ca6fd
commit 8e538ba300
2 changed files with 14 additions and 10 deletions

View File

@@ -4716,7 +4716,7 @@ def actionsubmit(data, actionmode=0, force_submit=False, force_prompt_gen=False,
if(len(koboldai_vars.prompt.strip()) == 0):
koboldai_vars.prompt = data
else:
koboldai_vars.actions.append_submission(data)
koboldai_vars.actions.append(data, submission=True)
update_story_chunk('last')
send_debug()

View File

@@ -1400,16 +1400,15 @@ class KoboldStoryRegister(object):
ignore = self.koboldai_vars.calc_ai_text()
self.set_game_saved()
self.gen_all_audio()
def append_submission(self, text, action_id_offset=0, recalc=True):
self._append(text, action_id_offset=action_id_offset, recalc=recalc)
self.submission_id = self.action_count + action_id_offset
def append(self, text, action_id_offset=0, recalc=True):
self._append(text, action_id_offset=action_id_offset, recalc=recalc)
self.submission_id = 0
def append(self, text, action_id_offset=0, recalc=True, submission=False):
"""Create a new action and append it to the table of actions.
def _append(self, text, action_id_offset=0, recalc=True):
text: The text of the action.
action_id_offset: An optional offset added to action_count when assiging an action_id.
recalc: If True, recalculate the context and generate audio.
submission: If True, mark this action as a user submission.
"""
if self.koboldai_vars.remove_double_space:
while " " in text:
text = text.replace(" ", " ")
@@ -1441,7 +1440,12 @@ class KoboldStoryRegister(object):
"Probabilities": [],
"Time": int(time.time()),
}
if submission:
self.submission_id = action_id
else:
self.submission_id = 0
if self.story_settings is not None:
self.story_settings.assign_world_info_to_actions(action_id=action_id, no_transmit=True)
process_variable_changes(self.socketio, "story", 'actions', {"id": action_id, 'action': self.actions[action_id]}, None)