mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Added uploading story without saving
This commit is contained in:
53
aiserver.py
53
aiserver.py
@@ -2889,7 +2889,7 @@ def load_model(use_gpu=True, gpu_layers=None, disk_layers=None, initial_load=Fal
|
|||||||
koboldai_vars.allowsp = True
|
koboldai_vars.allowsp = True
|
||||||
loadmodelsettings()
|
loadmodelsettings()
|
||||||
loadsettings()
|
loadsettings()
|
||||||
tpu_mtj_backend.load_model(koboldai_vars.custmodpth, hf_checkpoint=koboldai_vars.model not in ("TPUMeshTransformerGPTJ", "TPUMeshTransformerGPTNeoX") and koboldai_vars.use_colab_tpu, **koboldai_vars.modelconfig)
|
tpool.execute(tpu_mtj_backend.load_model(koboldai_vars.custmodpth, hf_checkpoint=koboldai_vars.model not in ("TPUMeshTransformerGPTJ", "TPUMeshTransformerGPTNeoX") and koboldai_vars.use_colab_tpu, **koboldai_vars.modelconfig))
|
||||||
koboldai_vars.modeldim = int(tpu_mtj_backend.params.get("d_embed", tpu_mtj_backend.params["d_model"]))
|
koboldai_vars.modeldim = int(tpu_mtj_backend.params.get("d_embed", tpu_mtj_backend.params["d_model"]))
|
||||||
tokenizer = tpu_mtj_backend.tokenizer
|
tokenizer = tpu_mtj_backend.tokenizer
|
||||||
if(koboldai_vars.badwordsids is koboldai_settings.badwordsids_default and koboldai_vars.model_type not in ("gpt2", "gpt_neo", "gptj")):
|
if(koboldai_vars.badwordsids is koboldai_settings.badwordsids_default and koboldai_vars.model_type not in ("gpt2", "gpt_neo", "gptj")):
|
||||||
@@ -6640,8 +6640,8 @@ def loadJSON(json_text_or_dict):
|
|||||||
load_story_v1(json_data)
|
load_story_v1(json_data)
|
||||||
|
|
||||||
def load_story_v1(js):
|
def load_story_v1(js):
|
||||||
loadpath = js['v1_loadpath']
|
loadpath = js['v1_loadpath'] if 'v1_loadpath' in js else koboldai_vars.savedir
|
||||||
filename = js['v1_filename']
|
filename = js['v1_filename'] if 'v1_filename' in js else 'untitled.json'
|
||||||
|
|
||||||
_filename = filename
|
_filename = filename
|
||||||
if(filename.endswith('.json')):
|
if(filename.endswith('.json')):
|
||||||
@@ -7248,28 +7248,31 @@ def ui2_serve_themes(path):
|
|||||||
@socketio.on('upload_file')
|
@socketio.on('upload_file')
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def upload_file(data):
|
def upload_file(data):
|
||||||
if koboldai_vars.debug:
|
logger.debug("upload_file {}".format(data['filename']))
|
||||||
print("upload_file {}".format(data['filename']))
|
if data['upload_no_save']:
|
||||||
if 'current_folder' in session:
|
json_data = json.loads(data['data'].decode("utf-8"))
|
||||||
path = os.path.abspath(os.path.join(session['current_folder'], data['filename']).replace("\\", "/")).replace("\\", "/")
|
loadJSON(json_data)
|
||||||
if koboldai_vars.debug:
|
else:
|
||||||
print("Want to save to {}".format(path))
|
if 'current_folder' in session:
|
||||||
if 'popup_jailed_dir' not in session:
|
path = os.path.abspath(os.path.join(session['current_folder'], data['filename']).replace("\\", "/")).replace("\\", "/")
|
||||||
print("Someone is trying to upload a file to your server. Blocked.")
|
if koboldai_vars.debug:
|
||||||
elif session['popup_jailed_dir'] is None:
|
print("Want to save to {}".format(path))
|
||||||
if os.path.exists(path):
|
if 'popup_jailed_dir' not in session:
|
||||||
emit("error_popup", "The file already exists. Please delete it or rename the file before uploading", broadcast=False, room="UI_2");
|
print("Someone is trying to upload a file to your server. Blocked.")
|
||||||
else:
|
elif session['popup_jailed_dir'] is None:
|
||||||
with open(path, "wb") as f:
|
if os.path.exists(path):
|
||||||
f.write(data['data'])
|
emit("error_popup", "The file already exists. Please delete it or rename the file before uploading", broadcast=False, room="UI_2");
|
||||||
get_files_folders(session['current_folder'])
|
else:
|
||||||
elif session['popup_jailed_dir'] in session['current_folder']:
|
with open(path, "wb") as f:
|
||||||
if os.path.exists(path):
|
f.write(data['data'])
|
||||||
emit("error_popup", "The file already exists. Please delete it or rename the file before uploading", broadcast=False, room="UI_2");
|
get_files_folders(session['current_folder'])
|
||||||
else:
|
elif session['popup_jailed_dir'] in session['current_folder']:
|
||||||
with open(path, "wb") as f:
|
if os.path.exists(path):
|
||||||
f.write(data['data'])
|
emit("error_popup", "The file already exists. Please delete it or rename the file before uploading", broadcast=False, room="UI_2");
|
||||||
get_files_folders(session['current_folder'])
|
else:
|
||||||
|
with open(path, "wb") as f:
|
||||||
|
f.write(data['data'])
|
||||||
|
get_files_folders(session['current_folder'])
|
||||||
|
|
||||||
@socketio.on('popup_change_folder')
|
@socketio.on('popup_change_folder')
|
||||||
@logger.catch
|
@logger.catch
|
||||||
|
@@ -2183,7 +2183,7 @@ function upload_file(file_box) {
|
|||||||
for (file of fileList) {
|
for (file of fileList) {
|
||||||
reader = new FileReader();
|
reader = new FileReader();
|
||||||
reader.onload = function (event) {
|
reader.onload = function (event) {
|
||||||
socket.emit("upload_file", {'filename': file.name, "data": event.target.result});
|
socket.emit("upload_file", {'filename': file.name, "data": event.target.result, 'upload_no_save': document.getElementById('upload_no_save').checked});
|
||||||
};
|
};
|
||||||
reader.readAsArrayBuffer(file);
|
reader.readAsArrayBuffer(file);
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="display:flex;justify-content: space-between;">
|
<div style="display:flex;justify-content: space-between;">
|
||||||
<span>Drag file(s) above or click here to Upload File<input id="popup_upload_input" type=file onchange="upload_file(this)"></span>
|
<span>Drag file(s) above or click here to Upload File<input id="popup_upload_input" type=file onchange="upload_file(this)"></span>
|
||||||
|
<span>
|
||||||
|
Upload file without saving to google:
|
||||||
|
<input type=checkbox id="upload_no_save" class="setting_item_input"
|
||||||
|
data-size="mini" data-onstyle="success" data-toggle="toggle">
|
||||||
|
</span>
|
||||||
<button id="import_story_button" class="settings_button hidden" onclick="document.getElementById('import_aidg_club_popup').classList.remove('hidden');">
|
<button id="import_story_button" class="settings_button hidden" onclick="document.getElementById('import_aidg_club_popup').classList.remove('hidden');">
|
||||||
<span class="material-icons-outlined cursor" title="Import Story">cloud_download</span>
|
<span class="material-icons-outlined cursor" title="Import Story">cloud_download</span>
|
||||||
<span class="button_label">Import Story</span>
|
<span class="button_label">Import Story</span>
|
||||||
|
Reference in New Issue
Block a user