mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
UI2 support for Horde
This commit is contained in:
16
aiserver.py
16
aiserver.py
@@ -1204,7 +1204,7 @@ def get_model_info(model, directory=""):
|
|||||||
key_value = js["oaiapikey"]
|
key_value = js["oaiapikey"]
|
||||||
if 'oaiurl' in js and js['oaiurl'] != "":
|
if 'oaiurl' in js and js['oaiurl'] != "":
|
||||||
default_url = js['oaiurl']
|
default_url = js['oaiurl']
|
||||||
get_cluster_models({'key': key_value, 'url': default_url})
|
get_cluster_models({'model': model, 'key': key_value, 'url': default_url})
|
||||||
elif model in [x[1] for x in model_menu['apilist']]:
|
elif model in [x[1] for x in model_menu['apilist']]:
|
||||||
if path.exists("settings/{}.v2_settings".format(model)):
|
if path.exists("settings/{}.v2_settings".format(model)):
|
||||||
with open("settings/{}.v2_settings".format(model), "r") as file:
|
with open("settings/{}.v2_settings".format(model), "r") as file:
|
||||||
@@ -1337,7 +1337,7 @@ def get_oai_models(data):
|
|||||||
emit('oai_engines', {'data': engines, 'online_model': online_model}, broadcast=False, room="UI_2")
|
emit('oai_engines', {'data': engines, 'online_model': online_model}, broadcast=False, room="UI_2")
|
||||||
else:
|
else:
|
||||||
# Something went wrong, print the message and quit since we can't initialize an engine
|
# Something went wrong, print the message and quit since we can't initialize an engine
|
||||||
print("{0}ERROR!{1}".format(colors.RED, colors.END), room="UI_1")
|
print("{0}ERROR!{1}".format(colors.RED, colors.END))
|
||||||
print(req.json())
|
print(req.json())
|
||||||
emit('from_server', {'cmd': 'errmsg', 'data': req.json()})
|
emit('from_server', {'cmd': 'errmsg', 'data': req.json()})
|
||||||
|
|
||||||
@@ -1345,6 +1345,7 @@ def get_oai_models(data):
|
|||||||
def get_cluster_models(msg):
|
def get_cluster_models(msg):
|
||||||
koboldai_vars.oaiapikey = msg['key']
|
koboldai_vars.oaiapikey = msg['key']
|
||||||
koboldai_vars.apikey = koboldai_vars.oaiapikey
|
koboldai_vars.apikey = koboldai_vars.oaiapikey
|
||||||
|
model = msg['model']
|
||||||
url = msg['url']
|
url = msg['url']
|
||||||
|
|
||||||
|
|
||||||
@@ -1369,8 +1370,8 @@ def get_cluster_models(msg):
|
|||||||
# If the client settings file doesn't exist, create it
|
# If the client settings file doesn't exist, create it
|
||||||
# Write API key to file
|
# Write API key to file
|
||||||
os.makedirs('settings', exist_ok=True)
|
os.makedirs('settings', exist_ok=True)
|
||||||
if path.exists(get_config_filename(koboldai_vars.model_selected)):
|
if path.exists(get_config_filename(model)):
|
||||||
with open(get_config_filename(koboldai_vars.model_selected), "r") as file:
|
with open(get_config_filename(model), "r") as file:
|
||||||
js = json.load(file)
|
js = json.load(file)
|
||||||
if 'online_model' in js:
|
if 'online_model' in js:
|
||||||
online_model = js['online_model']
|
online_model = js['online_model']
|
||||||
@@ -1381,11 +1382,12 @@ def get_cluster_models(msg):
|
|||||||
changed=True
|
changed=True
|
||||||
if changed:
|
if changed:
|
||||||
js={}
|
js={}
|
||||||
with open(get_config_filename(koboldai_vars.model_selected), "w") as file:
|
with open(get_config_filename(model), "w") as file:
|
||||||
js["apikey"] = koboldai_vars.oaiapikey
|
js["apikey"] = koboldai_vars.oaiapikey
|
||||||
file.write(json.dumps(js, indent=3))
|
file.write(json.dumps(js, indent=3))
|
||||||
|
|
||||||
emit('from_server', {'cmd': 'oai_engines', 'data': engines, 'online_model': online_model}, broadcast=True)
|
emit('from_server', {'cmd': 'oai_engines', 'data': engines, 'online_model': online_model}, broadcast=True, room="UI_1")
|
||||||
|
emit('oai_engines', {'data': engines, 'online_model': online_model}, broadcast=False, room="UI_2")
|
||||||
else:
|
else:
|
||||||
# Something went wrong, print the message and quit since we can't initialize an engine
|
# Something went wrong, print the message and quit since we can't initialize an engine
|
||||||
print("{0}ERROR!{1}".format(colors.RED, colors.END))
|
print("{0}ERROR!{1}".format(colors.RED, colors.END))
|
||||||
@@ -3771,7 +3773,7 @@ def get_message(msg):
|
|||||||
elif(msg['cmd'] == 'OAI_Key_Update'):
|
elif(msg['cmd'] == 'OAI_Key_Update'):
|
||||||
get_oai_models({'model': koboldai_vars.model, 'key': msg['key']})
|
get_oai_models({'model': koboldai_vars.model, 'key': msg['key']})
|
||||||
elif(msg['cmd'] == 'Cluster_Key_Update'):
|
elif(msg['cmd'] == 'Cluster_Key_Update'):
|
||||||
get_cluster_models(msg)
|
get_cluster_models({'model': koboldai_vars.model, 'key': msg['key'], 'url': msg['url']})
|
||||||
elif(msg['cmd'] == 'loadselect'):
|
elif(msg['cmd'] == 'loadselect'):
|
||||||
koboldai_vars.loadselect = msg["data"]
|
koboldai_vars.loadselect = msg["data"]
|
||||||
elif(msg['cmd'] == 'spselect'):
|
elif(msg['cmd'] == 'spselect'):
|
||||||
|
@@ -1168,6 +1168,25 @@ function selected_model_info(data) {
|
|||||||
} else {
|
} else {
|
||||||
document.getElementById("modelurl").classList.add("hidden");
|
document.getElementById("modelurl").classList.add("hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//change model loading on url if needed
|
||||||
|
if (data.models_on_url) {
|
||||||
|
document.getElementById("modelurl").onchange = function () {socket.emit('get_cluster_models', {'key': document.getElementById("modelkey").value, 'url': this.value});};
|
||||||
|
document.getElementById("modelkey").onchange = function () {socket.emit('get_cluster_models', {'key': this.value, 'url': document.getElementById("modelurl").value});};
|
||||||
|
} else {
|
||||||
|
document.getElementById("modelkey").ochange = function () {socket.emit('OAI_Key_Update', {'model': document.getElementById('btn_loadmodelaccept').getAttribute('selected_model'), 'key': this.value});};
|
||||||
|
document.getElementById("modelurl").ochange = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Multiple Model Select?
|
||||||
|
if (data.multi_online_models) {
|
||||||
|
document.getElementById("oaimodel").setAttribute("multiple", "");
|
||||||
|
document.getElementById("oaimodel").options[0].textContent = "All"
|
||||||
|
} else {
|
||||||
|
document.getElementById("oaimodel").removeAttribute("multiple");
|
||||||
|
document.getElementById("oaimodel").options[0].textContent = "Select Model(s)"
|
||||||
|
}
|
||||||
|
|
||||||
//hide or unhide the use gpu checkbox
|
//hide or unhide the use gpu checkbox
|
||||||
if (data.gpu) {
|
if (data.gpu) {
|
||||||
document.getElementById("use_gpu_div").classList.remove("hidden");
|
document.getElementById("use_gpu_div").classList.remove("hidden");
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
<div id="loadmodellistcontent" class="popup_list_area"></div>
|
<div id="loadmodellistcontent" class="popup_list_area"></div>
|
||||||
<div class="popup_load_cancel">
|
<div class="popup_load_cancel">
|
||||||
<div>
|
<div>
|
||||||
<input class="hidden fullwidth" type="text" placeholder="key" id="modelkey" onblur="socket.emit('OAI_Key_Update', {'model': document.getElementById('btn_loadmodelaccept').getAttribute('selected_model'), 'key': this.value});">
|
<input class="hidden fullwidth" type="text" placeholder="key" id="modelkey" onchange="socket.emit('OAI_Key_Update', {'model': document.getElementById('btn_loadmodelaccept').getAttribute('selected_model'), 'key': this.value});">
|
||||||
<input class="hidden fullwidth" type="text" placeholder="Enter the URL of the server (For example a trycloudflare link)" id="modelurl" onchange="check_enable_model_load()">
|
<input class="hidden fullwidth" type="text" placeholder="Enter the URL of the server (For example a trycloudflare link)" id="modelurl" onchange="check_enable_model_load()">
|
||||||
<input class="hidden fullwidth" type="text" placeholder="Model Path or Hugging Face Name" id="custommodelname" menu="" onblur="socket.send({'cmd': 'selectmodel', 'data': $(this).attr('menu'), 'path_modelname': $('#custommodelname')[0].value});">
|
<input class="hidden fullwidth" type="text" placeholder="Model Path or Hugging Face Name" id="custommodelname" menu="" onblur="socket.send({'cmd': 'selectmodel', 'data': $(this).attr('menu'), 'path_modelname': $('#custommodelname')[0].value});">
|
||||||
<select class="hidden fullwidth settings_select" id="oaimodel"><option value="">Select OAI Model</option></select>
|
<select class="hidden fullwidth settings_select" id="oaimodel"><option value="">Select OAI Model</option></select>
|
||||||
|
Reference in New Issue
Block a user