mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Change debug prints to only print with --debug
This commit is contained in:
69
aiserver.py
69
aiserver.py
@@ -6792,10 +6792,12 @@ def ui2_serve_themes(path):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('upload_file')
|
@socketio.on('upload_file')
|
||||||
def upload_file(data):
|
def upload_file(data):
|
||||||
print("upload_file {}".format(data['filename']))
|
if koboldai_vars.debug:
|
||||||
|
print("upload_file {}".format(data['filename']))
|
||||||
if 'current_folder' in session:
|
if 'current_folder' in session:
|
||||||
path = os.path.abspath(os.path.join(session['current_folder'], data['filename']).replace("\\", "/")).replace("\\", "/")
|
path = os.path.abspath(os.path.join(session['current_folder'], data['filename']).replace("\\", "/")).replace("\\", "/")
|
||||||
print("Want to save to {}".format(path))
|
if koboldai_vars.debug:
|
||||||
|
print("Want to save to {}".format(path))
|
||||||
if 'popup_jailed_dir' not in session:
|
if 'popup_jailed_dir' not in session:
|
||||||
print("Someone is trying to upload a file to your server. Blocked.")
|
print("Someone is trying to upload a file to your server. Blocked.")
|
||||||
elif session['popup_jailed_dir'] is None:
|
elif session['popup_jailed_dir'] is None:
|
||||||
@@ -6815,7 +6817,8 @@ def upload_file(data):
|
|||||||
|
|
||||||
@socketio.on('popup_change_folder')
|
@socketio.on('popup_change_folder')
|
||||||
def popup_change_folder(data):
|
def popup_change_folder(data):
|
||||||
print("Doing popup change folder: {}".format(data))
|
if koboldai_vars.debug:
|
||||||
|
print("Doing popup change folder: {}".format(data))
|
||||||
if 'popup_jailed_dir' not in session:
|
if 'popup_jailed_dir' not in session:
|
||||||
print("Someone is trying to get at files in your server. Blocked.")
|
print("Someone is trying to get at files in your server. Blocked.")
|
||||||
return
|
return
|
||||||
@@ -7104,7 +7107,8 @@ def UI_2_var_change(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('save_story')
|
@socketio.on('save_story')
|
||||||
def UI_2_save_story(data):
|
def UI_2_save_story(data):
|
||||||
print("Saving Story")
|
if koboldai_vars.debug:
|
||||||
|
print("Saving Story")
|
||||||
if data is None:
|
if data is None:
|
||||||
#We need to check to see if there is a file already and if it's not the same story so we can ask the client if this is OK
|
#We need to check to see if there is a file already and if it's not the same story so we can ask the client if this is OK
|
||||||
save_name = koboldai_vars.story_name if koboldai_vars.story_name != "" else "untitled"
|
save_name = koboldai_vars.story_name if koboldai_vars.story_name != "" else "untitled"
|
||||||
@@ -7143,7 +7147,8 @@ def UI_2_save_to_json():
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('Set Selected Text')
|
@socketio.on('Set Selected Text')
|
||||||
def UI_2_Set_Selected_Text(data):
|
def UI_2_Set_Selected_Text(data):
|
||||||
print("Updating Selected Text: {}".format(data))
|
if koboldai_vars.quiet:
|
||||||
|
print("Updating Selected Text: {}".format(data))
|
||||||
koboldai_vars.actions[int(data['id'])] = data['text']
|
koboldai_vars.actions[int(data['id'])] = data['text']
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
@@ -7163,16 +7168,17 @@ def UI_2_Use_Option_Text(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('submit')
|
@socketio.on('submit')
|
||||||
def UI_2_submit(data):
|
def UI_2_submit(data):
|
||||||
print(data)
|
|
||||||
if not koboldai_vars.noai and data['theme'] != "":
|
if not koboldai_vars.noai and data['theme'] != "":
|
||||||
print("doing random prompt")
|
if koboldai_vars.debug:
|
||||||
|
print("doing random prompt")
|
||||||
memory = koboldai_vars.memory
|
memory = koboldai_vars.memory
|
||||||
koboldai_vars.memory = "{}\n\nYou generate the following {} story concept :".format(koboldai_vars.memory, data['theme'])
|
koboldai_vars.memory = "{}\n\nYou generate the following {} story concept :".format(koboldai_vars.memory, data['theme'])
|
||||||
koboldai_vars.lua_koboldbridge.feedback = None
|
koboldai_vars.lua_koboldbridge.feedback = None
|
||||||
actionsubmit("", force_submit=True, force_prompt_gen=True)
|
actionsubmit("", force_submit=True, force_prompt_gen=True)
|
||||||
koboldai_vars.memory = memory
|
koboldai_vars.memory = memory
|
||||||
else:
|
else:
|
||||||
print("doing normal input")
|
if koboldai_vars.debug:
|
||||||
|
print("doing normal input")
|
||||||
koboldai_vars.actions.clear_unused_options()
|
koboldai_vars.actions.clear_unused_options()
|
||||||
koboldai_vars.lua_koboldbridge.feedback = None
|
koboldai_vars.lua_koboldbridge.feedback = None
|
||||||
koboldai_vars.recentrng = koboldai_vars.recentrngm = None
|
koboldai_vars.recentrng = koboldai_vars.recentrngm = None
|
||||||
@@ -7186,9 +7192,9 @@ def UI_2_submit(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('abort')
|
@socketio.on('abort')
|
||||||
def UI_2_abort(data):
|
def UI_2_abort(data):
|
||||||
print("got abort")
|
if koboldai_vars.debug:
|
||||||
|
print("got abort")
|
||||||
koboldai_vars.abort = True
|
koboldai_vars.abort = True
|
||||||
print(koboldai_vars.abort)
|
|
||||||
|
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
@@ -7203,7 +7209,8 @@ def UI_2_Pinning(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('back')
|
@socketio.on('back')
|
||||||
def UI_2_back(data):
|
def UI_2_back(data):
|
||||||
print("back")
|
if koboldai_vars.debug:
|
||||||
|
print("back")
|
||||||
koboldai_vars.actions.clear_unused_options()
|
koboldai_vars.actions.clear_unused_options()
|
||||||
ignore = koboldai_vars.actions.pop()
|
ignore = koboldai_vars.actions.pop()
|
||||||
|
|
||||||
@@ -7241,7 +7248,6 @@ def UI_2_load_model_button(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('select_model')
|
@socketio.on('select_model')
|
||||||
def UI_2_select_model(data):
|
def UI_2_select_model(data):
|
||||||
print(data)
|
|
||||||
|
|
||||||
#We've selected a menu
|
#We've selected a menu
|
||||||
if data['model'] in model_menu:
|
if data['model'] in model_menu:
|
||||||
@@ -7265,7 +7271,6 @@ def UI_2_select_model(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('load_model')
|
@socketio.on('load_model')
|
||||||
def UI_2_load_model(data):
|
def UI_2_load_model(data):
|
||||||
print(data)
|
|
||||||
if not os.path.exists("settings/"):
|
if not os.path.exists("settings/"):
|
||||||
os.mkdir("settings")
|
os.mkdir("settings")
|
||||||
changed = True
|
changed = True
|
||||||
@@ -7361,7 +7366,8 @@ def story_sort(base_path, desc=False):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('load_story')
|
@socketio.on('load_story')
|
||||||
def UI_2_load_story(file):
|
def UI_2_load_story(file):
|
||||||
print("loading {}".format(file))
|
if koboldai_vars.debug:
|
||||||
|
print("loading {}".format(file))
|
||||||
loadRequest(file)
|
loadRequest(file)
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
@@ -7377,7 +7383,6 @@ def UI_2_new_story(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('move_wi')
|
@socketio.on('move_wi')
|
||||||
def UI_2_move_wi(data):
|
def UI_2_move_wi(data):
|
||||||
print(data)
|
|
||||||
if data['folder'] is None:
|
if data['folder'] is None:
|
||||||
koboldai_vars.worldinfo_v2.reorder(int(data['dragged_id']), int(data['drop_id']))
|
koboldai_vars.worldinfo_v2.reorder(int(data['dragged_id']), int(data['drop_id']))
|
||||||
else:
|
else:
|
||||||
@@ -7388,7 +7393,6 @@ def UI_2_move_wi(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('wi_set_folder')
|
@socketio.on('wi_set_folder')
|
||||||
def UI_2_wi_set_folder(data):
|
def UI_2_wi_set_folder(data):
|
||||||
print(data)
|
|
||||||
koboldai_vars.worldinfo_v2.add_item_to_folder(int(data['dragged_id']), data['folder'])
|
koboldai_vars.worldinfo_v2.add_item_to_folder(int(data['dragged_id']), data['folder'])
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
@@ -7396,8 +7400,9 @@ def UI_2_wi_set_folder(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('Rename_World_Info_Folder')
|
@socketio.on('Rename_World_Info_Folder')
|
||||||
def UI_2_Rename_World_Info_Folder(data):
|
def UI_2_Rename_World_Info_Folder(data):
|
||||||
print("Rename_World_Info_Folder")
|
if koboldai_vars.debug:
|
||||||
print(data)
|
print("Rename_World_Info_Folder")
|
||||||
|
print(data)
|
||||||
koboldai_vars.worldinfo_v2.rename_folder(data['old_folder'], data['new_folder'])
|
koboldai_vars.worldinfo_v2.rename_folder(data['old_folder'], data['new_folder'])
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
@@ -7405,8 +7410,9 @@ def UI_2_Rename_World_Info_Folder(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('edit_world_info')
|
@socketio.on('edit_world_info')
|
||||||
def UI_2_edit_world_info(data):
|
def UI_2_edit_world_info(data):
|
||||||
print("edit_world_info")
|
if koboldai_vars.debug:
|
||||||
print(data)
|
print("edit_world_info")
|
||||||
|
print(data)
|
||||||
|
|
||||||
if data['uid'] < 0:
|
if data['uid'] < 0:
|
||||||
koboldai_vars.worldinfo_v2.add_item(data['title'], data['key'],
|
koboldai_vars.worldinfo_v2.add_item(data['title'], data['key'],
|
||||||
@@ -7491,7 +7497,6 @@ def UI_2_import_world_info(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('phrase_bias_update')
|
@socketio.on('phrase_bias_update')
|
||||||
def UI_2_phrase_bias_update(biases):
|
def UI_2_phrase_bias_update(biases):
|
||||||
print(biases)
|
|
||||||
koboldai_vars.biases = biases
|
koboldai_vars.biases = biases
|
||||||
|
|
||||||
|
|
||||||
@@ -7513,7 +7518,8 @@ def socket_io_relay(queue, socketio):
|
|||||||
# Event triggered when program errors out
|
# Event triggered when program errors out
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def my_except_hook(exctype, value, traceback):
|
def my_except_hook(exctype, value, traceback):
|
||||||
print("sending error to clients")
|
if koboldai_vars.debug:
|
||||||
|
print("sending error to clients")
|
||||||
socketio.emit("error", "{}: {}".format(exctype, value), broadcast=True, room="UI_2")
|
socketio.emit("error", "{}: {}".format(exctype, value), broadcast=True, room="UI_2")
|
||||||
sys.__excepthook__(exctype, value, traceback)
|
sys.__excepthook__(exctype, value, traceback)
|
||||||
sys.excepthook = my_except_hook
|
sys.excepthook = my_except_hook
|
||||||
@@ -7527,7 +7533,8 @@ def handle_exception(e):
|
|||||||
return e
|
return e
|
||||||
|
|
||||||
# now you're handling non-HTTP exceptions only
|
# now you're handling non-HTTP exceptions only
|
||||||
print("sending error to clients")
|
if koboldai_vars.debug:
|
||||||
|
print("sending error to clients")
|
||||||
socketio.emit("error", "{}: {}".format(e.message, e.args), broadcast=True, room="UI_2")
|
socketio.emit("error", "{}: {}".format(e.message, e.args), broadcast=True, room="UI_2")
|
||||||
return render_template("500_generic.html", e=e), 500
|
return render_template("500_generic.html", e=e), 500
|
||||||
|
|
||||||
@@ -7570,7 +7577,8 @@ def get_softprompt_desc(item_full_path, item, valid_selection):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('load_softprompt')
|
@socketio.on('load_softprompt')
|
||||||
def UI_2_load_softprompt(data):
|
def UI_2_load_softprompt(data):
|
||||||
print("Load softprompt: {}".format(data))
|
if koboldai_vars.debug:
|
||||||
|
print("Load softprompt: {}".format(data))
|
||||||
spRequest(data)
|
spRequest(data)
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
@@ -7586,7 +7594,8 @@ def UI_2_load_userscripts_list(data):
|
|||||||
column_widths=['200px', '150px', 'auto'])
|
column_widths=['200px', '150px', 'auto'])
|
||||||
|
|
||||||
def valid_userscripts_to_load(file):
|
def valid_userscripts_to_load(file):
|
||||||
print("{} is valid: {}".format(file, file.endswith(".lua") and os.path.basename(file) not in koboldai_vars.userscripts))
|
if koboldai_vars.debug:
|
||||||
|
print("{} is valid: {}".format(file, file.endswith(".lua") and os.path.basename(file) not in koboldai_vars.userscripts))
|
||||||
return file.endswith(".lua") and os.path.basename(file) not in koboldai_vars.userscripts
|
return file.endswith(".lua") and os.path.basename(file) not in koboldai_vars.userscripts
|
||||||
|
|
||||||
def valid_userscripts_to_unload(file):
|
def valid_userscripts_to_unload(file):
|
||||||
@@ -7637,6 +7646,7 @@ def get_userscripts_desc(item_full_path, item, valid_selection):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('load_userscripts')
|
@socketio.on('load_userscripts')
|
||||||
def UI_2_load_userscripts(data):
|
def UI_2_load_userscripts(data):
|
||||||
|
if koboldai_vars.debug:
|
||||||
print("Loading Userscripts: {}".format(os.path.basename(data)))
|
print("Loading Userscripts: {}".format(os.path.basename(data)))
|
||||||
koboldai_vars.userscripts = [x for x in koboldai_vars.userscripts if x != os.path.basename(data)]+[os.path.basename(data)]
|
koboldai_vars.userscripts = [x for x in koboldai_vars.userscripts if x != os.path.basename(data)]+[os.path.basename(data)]
|
||||||
load_lua_scripts()
|
load_lua_scripts()
|
||||||
@@ -7646,7 +7656,8 @@ def UI_2_load_userscripts(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('unload_userscripts')
|
@socketio.on('unload_userscripts')
|
||||||
def UI_2_unload_userscripts(data):
|
def UI_2_unload_userscripts(data):
|
||||||
print("Unloading Userscript: {}".format(data))
|
if koboldai_vars.debug:
|
||||||
|
print("Unloading Userscript: {}".format(data))
|
||||||
koboldai_vars.userscripts = [x for x in koboldai_vars.userscripts if x != data]
|
koboldai_vars.userscripts = [x for x in koboldai_vars.userscripts if x != data]
|
||||||
load_lua_scripts()
|
load_lua_scripts()
|
||||||
|
|
||||||
@@ -7657,7 +7668,8 @@ def UI_2_unload_userscripts(data):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
@socketio.on('load_aidg_club')
|
@socketio.on('load_aidg_club')
|
||||||
def UI_2_load_aidg_club(data):
|
def UI_2_load_aidg_club(data):
|
||||||
print("Load aidg.club: {}".format(data))
|
if koboldai_vars.debug:
|
||||||
|
print("Load aidg.club: {}".format(data))
|
||||||
importAidgRequest(data)
|
importAidgRequest(data)
|
||||||
|
|
||||||
|
|
||||||
@@ -7671,7 +7683,8 @@ def UI_2_theme_change(data):
|
|||||||
for key, value in data['theme'].items():
|
for key, value in data['theme'].items():
|
||||||
f.write("\t{}: {};\n".format(key, value.replace(";", "").replace("--", "-")))
|
f.write("\t{}: {};\n".format(key, value.replace(";", "").replace("--", "-")))
|
||||||
f.write("}")
|
f.write("}")
|
||||||
print("Theme Saved")
|
if koboldai_vars.debug:
|
||||||
|
print("Theme Saved")
|
||||||
|
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
|
Reference in New Issue
Block a user