mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
added --remote not allowing navigation outside of the model folder for custom models.
added a delete custom models option (will not delete models outside of the models directory, nor will it delete non-model directories)
This commit is contained in:
20
aiserver.py
20
aiserver.py
@ -354,6 +354,7 @@ from flask import Flask, render_template, Response, request, copy_current_reques
|
||||
from flask_socketio import SocketIO, emit
|
||||
app = Flask(__name__, root_path=os.getcwd())
|
||||
app.config['SECRET KEY'] = 'secret!'
|
||||
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||
socketio = SocketIO(app, async_method="eventlet")
|
||||
print("{0}OK!{1}".format(colors.GREEN, colors.END))
|
||||
|
||||
@ -364,6 +365,8 @@ def sendModelSelection(menu="mainmenu", folder="./models"):
|
||||
#If we send one of the manual load options, send back the list of model directories, otherwise send the menu
|
||||
if menu in ('NeoCustom', 'GPT2Custom'):
|
||||
(paths, breadcrumbs) = get_folder_path_info(folder)
|
||||
if args.remote:
|
||||
breadcrumbs = []
|
||||
menu_list = [[folder, menu, "", False] for folder in paths]
|
||||
menu_list.append(["Return to Main Menu", "mainmenu", "", True])
|
||||
emit('from_server', {'cmd': 'show_model_menu', 'data': menu_list, 'menu': menu, 'breadcrumbs': breadcrumbs}, broadcast=True)
|
||||
@ -2023,7 +2026,10 @@ def load_model(use_gpu=True, gpu_layers=None, initial_load=False, online_model="
|
||||
@app.route('/')
|
||||
@app.route('/index')
|
||||
def index():
|
||||
return render_template('index.html', hide_ai_menu=args.noaimenu)
|
||||
if 'new_ui' in request.args:
|
||||
return render_template('index_new.html', hide_ai_menu=args.noaimenu)
|
||||
else:
|
||||
return render_template('index.html', hide_ai_menu=args.noaimenu)
|
||||
@app.route('/favicon.ico')
|
||||
def favicon():
|
||||
return send_from_directory(app.root_path,
|
||||
@ -3090,7 +3096,17 @@ def get_message(msg):
|
||||
get_model_info(msg['data'], directory=msg['path'])
|
||||
else:
|
||||
get_model_info(vars.model)
|
||||
|
||||
elif(msg['cmd'] == 'delete_model'):
|
||||
if "{}/models".format(os.getcwd()) in msg['data'] or "{}\\models".format(os.getcwd()) in msg['data']:
|
||||
if check_if_dir_is_model(msg['data']):
|
||||
print("It's a model, now we really will kill it")
|
||||
import shutil
|
||||
shutil.rmtree(msg['data'])
|
||||
sendModelSelection(menu=msg['menu'])
|
||||
else:
|
||||
print("Not a model, don't delete")
|
||||
else:
|
||||
print("Ah ah ah, you didn't say the magic word: The selected directory is not in the KoboldAI Models directory, not doing anything.")
|
||||
elif(msg['cmd'] == 'OAI_Key_Update'):
|
||||
get_oai_models(msg['key'])
|
||||
elif(msg['cmd'] == 'loadselect'):
|
||||
|
Reference in New Issue
Block a user