mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-03-11 00:50:09 +01:00
Added custom text box for loading models from specific path, or loading other models from hugging face.
This commit is contained in:
parent
5110e956d2
commit
11ed55f34a
28
aiserver.py
28
aiserver.py
@ -434,13 +434,15 @@ def getModelSelection(modellist):
|
||||
getModelSelection(mainmenu)
|
||||
|
||||
def check_if_dir_is_model(path):
|
||||
try:
|
||||
from transformers import AutoConfig
|
||||
model_config = AutoConfig.from_pretrained(path, revision=vars.revision, cache_dir="cache")
|
||||
except:
|
||||
if os.path.exists(path):
|
||||
try:
|
||||
from transformers import AutoConfig
|
||||
model_config = AutoConfig.from_pretrained(path, revision=vars.revision, cache_dir="cache")
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
#==================================================================#
|
||||
# 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
|
||||
# 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
|
||||
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:
|
||||
folder = "./models"
|
||||
else:
|
||||
folder = msg['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'):
|
||||
if check_if_dir_is_model(msg['path']):
|
||||
vars.model = msg['data']
|
||||
|
@ -1002,6 +1002,7 @@ function buildLoadModelList(ar, menu, breadcrumbs) {
|
||||
disableButtons([load_model_accept]);
|
||||
loadmodelcontent.html("");
|
||||
$("#loadmodellistbreadcrumbs").html("");
|
||||
$("#custommodelname").addClass("hidden");
|
||||
var 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>");
|
||||
@ -1056,6 +1057,8 @@ function buildLoadModelList(ar, menu, breadcrumbs) {
|
||||
highlightLoadLine($(this));
|
||||
}
|
||||
})(i));
|
||||
$("#custommodelname").removeClass("hidden");
|
||||
$("#custommodelname")[0].setAttribute("menu", menu);
|
||||
//Normal load
|
||||
} else {
|
||||
$("#loadmodel"+i).off("click").on("click", (function () {
|
||||
|
@ -289,6 +289,7 @@
|
||||
<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="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 class="popupfooter">
|
||||
<select class="form-control hidden" id="oaimodel"><option value="">Select OAI Model</option></select>
|
||||
|
Loading…
x
Reference in New Issue
Block a user