mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Allow dicts to be synced, auto-upgrade story directories on load
This commit is contained in:
25
aiserver.py
25
aiserver.py
@@ -7397,6 +7397,7 @@ def loadRequest(loadpath, filename=None):
|
||||
if os.path.isdir(loadpath):
|
||||
if not valid_v3_story(loadpath):
|
||||
raise RuntimeError(f"Tried to load {loadpath}, a non-save directory.")
|
||||
koboldai_vars.update_story_path_structure(loadpath)
|
||||
loadpath = os.path.join(loadpath, "story.json")
|
||||
|
||||
start_time = time.time()
|
||||
@@ -8469,8 +8470,10 @@ def UI_2_var_change(data):
|
||||
value = str(data['value'])
|
||||
elif type(getattr(koboldai_vars, name)) == list:
|
||||
value = list(data['value'])
|
||||
elif type(getattr(koboldai_vars, name)) == dict:
|
||||
value = dict(data['value'])
|
||||
else:
|
||||
print("Unknown Type {} = {}".format(name, type(getattr(koboldai_vars, name))))
|
||||
raise ValueError("Unknown Type {} = {}".format(name, type(getattr(koboldai_vars, name))))
|
||||
|
||||
#print("Setting {} to {} as type {}".format(name, value, type(value)))
|
||||
setattr(koboldai_vars, name, value)
|
||||
@@ -9145,15 +9148,31 @@ def UI_2_get_wi_image(uid):
|
||||
except KeyError:
|
||||
return ":( Couldn't find image", 204
|
||||
|
||||
@app.route("/get_commentator_picture/<int(signed=True):commentator_id>", methods=["GET"])
|
||||
@logger.catch
|
||||
def UI_2_get_commentator_image(commentator_id):
|
||||
try:
|
||||
return send_file(os.path.join(koboldai_vars.save_paths.commentator_pictures, str(commentator_id)))
|
||||
except FileNotFoundError:
|
||||
# 404 Spams browser console
|
||||
return ":(", 204
|
||||
|
||||
|
||||
@app.route("/set_commentator_picture/<int(signed=True):commentator_id>", methods=["POST"])
|
||||
@logger.catch
|
||||
def UI_2_set_commentator_image(commentator_id):
|
||||
data = request.get_data()
|
||||
with open(os.path.join(koboldai_vars.save_paths.commentator_pictures, str(commentator_id)), "wb") as file:
|
||||
file.write(data)
|
||||
return ":)"
|
||||
|
||||
@socketio.on("scratchpad_prompt")
|
||||
@logger.catch
|
||||
def UI_2_scratchpad_prompt(data):
|
||||
print(data)
|
||||
out_text = raw_generate(
|
||||
data,
|
||||
max_new=80,
|
||||
).decoded
|
||||
print("data", data, "out", out_text)
|
||||
|
||||
socketio.emit("scratchpad_response", out_text, broadcast=True, room="UI_2")
|
||||
|
||||
|
Reference in New Issue
Block a user