Skip to content

Commit

Permalink
handle accidentally selecting a kcpps file as model instead
Browse files Browse the repository at this point in the history
  • Loading branch information
LostRuins committed Dec 4, 2023
1 parent 8602f5a commit a5a5839
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions koboldcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,15 @@ def auto_gpu_heuristics():
changed_gpu_choice_var()
return

def on_picked_model_file(filepath):
if filepath.lower().endswith('.kcpps'):
#load it as a config file instead
with open(filepath, 'r') as f:
dict = json.load(f)
import_vars(dict)
else:
autoset_gpu_layers(filepath)

def autoset_gpu_layers(filepath): #shitty algo to determine how many layers to use
try:
global gui_layers_untouched
Expand Down Expand Up @@ -1370,7 +1379,7 @@ def changerunmode(a,b,c):
makeslider(quick_tab, "Context Size:", contextsize_text, context_var, 0, len(contextsize_text)-1, 30, set=3)

# load model
makefileentry(quick_tab, "Model:", "Select GGML Model File", model_var, 40, 170, onchoosefile=autoset_gpu_layers)
makefileentry(quick_tab, "Model:", "Select GGML Model File", model_var, 40, 170, onchoosefile=on_picked_model_file)

# Hardware Tab
hardware_tab = tabcontent["Hardware"]
Expand Down Expand Up @@ -1441,7 +1450,7 @@ def togglerope(a,b,c):
# Model Tab
model_tab = tabcontent["Model"]

makefileentry(model_tab, "Model:", "Select GGML Model File", model_var, 1, onchoosefile=autoset_gpu_layers)
makefileentry(model_tab, "Model:", "Select GGML Model File", model_var, 1, onchoosefile=on_picked_model_file)
makefileentry(model_tab, "Lora:", "Select Lora File",lora_var, 3)
makefileentry(model_tab, "Lora Base:", "Select Lora Base File", lora_base_var, 5)
makefileentry(model_tab, "Preloaded Story:", "Select Preloaded Story File", preloadstory_var, 7)
Expand Down

0 comments on commit a5a5839

Please sign in to comment.