Zero-shot story review prompt thing beginnings

This commit is contained in:
somebody
2022-12-08 22:45:26 -06:00
parent 041ebbc388
commit 90e13f7f1f
2 changed files with 48 additions and 1 deletions

View File

@@ -9927,6 +9927,41 @@ def UI_2_refresh_auto_memory(data):
koboldai_vars.auto_memory += "\n\n Final Result:\n" + output
#==================================================================#
# Story review zero-shot
#==================================================================#
@socketio.on("story_review")
@logger.catch
def UI_2_story_review(data):
who = data["who"]
template = data.get("template", "\n\n%s's thoughts on this situation:\n\"")
prompt = template % who
logger.info(prompt)
context = koboldai_vars.calc_ai_text(
prompt,
return_text=True,
send_context=False
)
out_text = raw_generate(
context,
max_new=30,
).decoded[0]
out_text = re.sub(r"[\s\(\)]", " ", out_text)
# Beware contractions!
# out_text = re.sub(r"[\s!\.\?]'", " ", out_text)
while " " in out_text:
out_text = out_text.replace(" ", " ")
if '"' in out_text:
out_text = out_text.split('"')[0]
out_text = out_text.strip()
out_text = utils.trimincompletesentence(out_text)
emit("show_story_review", {"who": who, "review": out_text})
#==================================================================#
# Get next 100 actions for infinate scroll

View File

@@ -34,6 +34,7 @@ socket.on("log_message", function(data){process_log_message(data);});
socket.on("debug_message", function(data){console.log(data);});
socket.on("scratchpad_response", recieveScratchpadResponse);
socket.on("show_error_notification", function(data) { reportError(data.title, data.text) });
socket.on("show_story_review", showStoryReview);
//socket.onAny(function(event_name, data) {console.log({"event": event_name, "class": data.classname, "data": data});});
// Must be done before any elements are made; we track their changes.
@@ -6680,4 +6681,15 @@ function imgGenRetry() {
});
})();
})();
function requestStoryReview(who, template=null) {
let data = {who: who};
if (template) data.template = template;
socket.emit("story_review", data);
}
function showStoryReview(data) {
console.log(`${data.who}: ${data.review}`)
}