mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Added custom text box for loading models from specific path, or loading other models from hugging face.
This commit is contained in:
18
aiserver.py
18
aiserver.py
@ -434,13 +434,15 @@ def getModelSelection(modellist):
|
|||||||
getModelSelection(mainmenu)
|
getModelSelection(mainmenu)
|
||||||
|
|
||||||
def check_if_dir_is_model(path):
|
def check_if_dir_is_model(path):
|
||||||
|
if os.path.exists(path):
|
||||||
try:
|
try:
|
||||||
from transformers import AutoConfig
|
from transformers import AutoConfig
|
||||||
model_config = AutoConfig.from_pretrained(path, revision=vars.revision, cache_dir="cache")
|
model_config = AutoConfig.from_pretrained(path, revision=vars.revision, cache_dir="cache")
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
# Return all keys in tokenizer dictionary containing char
|
# Return all keys in tokenizer dictionary containing char
|
||||||
@ -3056,12 +3058,24 @@ def get_message(msg):
|
|||||||
# The data variable will contain the model name. But our Custom lines need a bit more processing
|
# The data variable will contain the model name. But our Custom lines need a bit more processing
|
||||||
# If we're on a custom line that we have selected a model for, the path variable will be in msg
|
# If we're on a custom line that we have selected a model for, the path variable will be in msg
|
||||||
# so if that's missing we need to run the menu to show the model folders in the models folder
|
# so if that's missing we need to run the menu to show the model folders in the models folder
|
||||||
if msg['data'] in ('NeoCustom', 'GPT2Custom') and 'path' not in msg:
|
if msg['data'] in ('NeoCustom', 'GPT2Custom') and 'path' not in msg and 'path_modelname' not in msg:
|
||||||
if 'folder' not in msg:
|
if 'folder' not in msg:
|
||||||
folder = "./models"
|
folder = "./models"
|
||||||
else:
|
else:
|
||||||
folder = msg['folder']
|
folder = msg['folder']
|
||||||
sendModelSelection(menu=msg['data'], folder=folder)
|
sendModelSelection(menu=msg['data'], folder=folder)
|
||||||
|
elif msg['data'] in ('NeoCustom', 'GPT2Custom') and 'path_modelname' in msg:
|
||||||
|
#Here the user entered custom text in the text box. This could be either a model name or a path.
|
||||||
|
if check_if_dir_is_model(msg['path_modelname']):
|
||||||
|
vars.model = msg['data']
|
||||||
|
vars.custmodpth = msg['path_modelname']
|
||||||
|
get_model_info(msg['data'], directory=msg['path'])
|
||||||
|
else:
|
||||||
|
vars.model = msg['path_modelname']
|
||||||
|
try:
|
||||||
|
get_model_info(vars.model)
|
||||||
|
except:
|
||||||
|
emit('from_server', {'cmd': 'errmsg', 'data': "The model entered doesn't exist."})
|
||||||
elif msg['data'] in ('NeoCustom', 'GPT2Custom'):
|
elif msg['data'] in ('NeoCustom', 'GPT2Custom'):
|
||||||
if check_if_dir_is_model(msg['path']):
|
if check_if_dir_is_model(msg['path']):
|
||||||
vars.model = msg['data']
|
vars.model = msg['data']
|
||||||
|
@ -1002,6 +1002,7 @@ function buildLoadModelList(ar, menu, breadcrumbs) {
|
|||||||
disableButtons([load_model_accept]);
|
disableButtons([load_model_accept]);
|
||||||
loadmodelcontent.html("");
|
loadmodelcontent.html("");
|
||||||
$("#loadmodellistbreadcrumbs").html("");
|
$("#loadmodellistbreadcrumbs").html("");
|
||||||
|
$("#custommodelname").addClass("hidden");
|
||||||
var i;
|
var i;
|
||||||
for(i=0; i<breadcrumbs.length; i++) {
|
for(i=0; i<breadcrumbs.length; i++) {
|
||||||
$("#loadmodellistbreadcrumbs").append("<button class=\"breadcrumbitem\" id='model_breadcrumbs"+i+"' name='"+ar[0][1]+"' value='"+breadcrumbs[i][0]+"'>"+breadcrumbs[i][1]+"</button><font color=white>\\</font>");
|
$("#loadmodellistbreadcrumbs").append("<button class=\"breadcrumbitem\" id='model_breadcrumbs"+i+"' name='"+ar[0][1]+"' value='"+breadcrumbs[i][0]+"'>"+breadcrumbs[i][1]+"</button><font color=white>\\</font>");
|
||||||
@ -1056,6 +1057,8 @@ function buildLoadModelList(ar, menu, breadcrumbs) {
|
|||||||
highlightLoadLine($(this));
|
highlightLoadLine($(this));
|
||||||
}
|
}
|
||||||
})(i));
|
})(i));
|
||||||
|
$("#custommodelname").removeClass("hidden");
|
||||||
|
$("#custommodelname")[0].setAttribute("menu", menu);
|
||||||
//Normal load
|
//Normal load
|
||||||
} else {
|
} else {
|
||||||
$("#loadmodel"+i).off("click").on("click", (function () {
|
$("#loadmodel"+i).off("click").on("click", (function () {
|
||||||
|
@ -289,6 +289,7 @@
|
|||||||
<div class="popupfooter">
|
<div class="popupfooter">
|
||||||
<input class="form-control hidden" type="text" placeholder="key" id="modelkey" onblur="socket.send({'cmd': 'OAI_Key_Update', 'key': $('#modelkey')[0].value});">
|
<input class="form-control hidden" type="text" placeholder="key" id="modelkey" onblur="socket.send({'cmd': 'OAI_Key_Update', 'key': $('#modelkey')[0].value});">
|
||||||
<input class="form-control hidden" type="text" placeholder="Enter the URL of the server (For example a trycloudflare link)" id="modelurl" onchange="check_enable_model_load()">
|
<input class="form-control hidden" type="text" placeholder="Enter the URL of the server (For example a trycloudflare link)" id="modelurl" onchange="check_enable_model_load()">
|
||||||
|
<input class="form-control hidden" 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});">
|
||||||
</div>
|
</div>
|
||||||
<div class="popupfooter">
|
<div class="popupfooter">
|
||||||
<select class="form-control hidden" id="oaimodel"><option value="">Select OAI Model</option></select>
|
<select class="form-control hidden" id="oaimodel"><option value="">Select OAI Model</option></select>
|
||||||
|
Reference in New Issue
Block a user