mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Zero-shot story review prompt thing beginnings
This commit is contained in:
35
aiserver.py
35
aiserver.py
@@ -9927,6 +9927,41 @@ def UI_2_refresh_auto_memory(data):
|
|||||||
koboldai_vars.auto_memory += "\n\n Final Result:\n" + output
|
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
|
# Get next 100 actions for infinate scroll
|
||||||
|
@@ -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("debug_message", function(data){console.log(data);});
|
||||||
socket.on("scratchpad_response", recieveScratchpadResponse);
|
socket.on("scratchpad_response", recieveScratchpadResponse);
|
||||||
socket.on("show_error_notification", function(data) { reportError(data.title, data.text) });
|
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});});
|
//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.
|
// Must be done before any elements are made; we track their changes.
|
||||||
@@ -6681,3 +6682,14 @@ 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}`)
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user