From b6bf33097995d9a0623fc4bbfd64ef5ead6ac17c Mon Sep 17 00:00:00 2001 From: ebolam Date: Fri, 23 Sep 2022 11:37:39 -0400 Subject: [PATCH] Temporarily added auto-memory box to UI. --- aiserver.py | 20 +++++++++----------- koboldai_settings.py | 1 + templates/story flyout.html | 8 ++++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/aiserver.py b/aiserver.py index 1c046373..1d94b4c7 100644 --- a/aiserver.py +++ b/aiserver.py @@ -8582,8 +8582,10 @@ def summarize(text, max_length=100, min_length=30): #==================================================================# # Test #==================================================================# -@app.route("/summarize") -def request_summarize(): +@socketio.on("refresh_auto_memory") +@logger.catch +def UI_2_refresh_auto_memory(data): + koboldai_vars.auto_memory = "Generating..." if koboldai_vars.summary_tokenizer is None: koboldai_vars.summary_tokenizer = AutoTokenizer.from_pretrained("models/{}".format(args.summarizer_model.replace('/', '_')), cache_dir="cache") #first, let's get all of our game text and split it into sentences @@ -8605,19 +8607,15 @@ def request_summarize(): new_sentences = [] i=0 for summary_chunk in summary_chunks: - print("summarizing chunk {}".format(i)) + logger.debug("summarizing chunk {}".format(i)) new_sentences.extend(re.split("(?<=[.!?])\s+", summarize(summary_chunk))) i+=1 - print("Summarized to {} sentencees from {}".format(len(new_sentences), len(sentences))) + logger.debug("Summarized to {} sentencees from {}".format(len(new_sentences), len(sentences))) sentences = new_sentences - for sentence in sentences: - print(sentence) - print("OK, doing final summarization") + koboldai_vars.auto_memory = "\n".join(sentences) + logger.debug("OK, doing final summarization") output = summarize(" ".join(sentences)) - print(output) - return "Input tokens: {}\nOutput tokens: {}\n{}".format(len(koboldai_vars.summary_tokenizer.encode(request.args['text'])), - len(koboldai_vars.summary_tokenizer.encode(output)), - output) + koboldai_vars.auto_memory += "\n" + output @app.route("/vars") @logger.catch diff --git a/koboldai_settings.py b/koboldai_settings.py index 7b6f28e8..c6a4c7f5 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -586,6 +586,7 @@ class story_settings(settings): self.autosave = False # Whether or not to automatically save after each action self.prompt = "" # Prompt self.memory = "" # Text submitted to memory field + self.auto_memory = "" self.authornote = "" # Text submitted to Author's Note field self.authornotetemplate = "[Author's note: <|>]" # Author's note template self.setauthornotetemplate = self.authornotetemplate # Saved author's note template in settings diff --git a/templates/story flyout.html b/templates/story flyout.html index 00d3c5c2..be09b35a 100644 --- a/templates/story flyout.html +++ b/templates/story flyout.html @@ -13,6 +13,14 @@ +
+

Auto-Memory (non-functional)

+ + What the system would use for automatic memory summarized from the game + + + +