Skip to content

Commit 0ed65a4

Browse files
committed
Hide unavailable backends & Add tooltip over backend count
Hides unavailable backends from the user and if the program is launched without any backends made, it shows an error message to them stating no backends were found and to make them using the 'make' command Add tooltip when hovering over backend count label hovering over the new label that shows the backend count will explain what the numbers are, and show the users which backends are not available or built
1 parent 2a26398 commit 0ed65a4

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

koboldcpp.py

+32-3
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,6 @@ def show_new_gui():
662662
return
663663

664664
import customtkinter as ctk
665-
666665
nextstate = 0 #0=exit, 1=launch, 2=oldgui
667666
windowwidth = 520
668667
windowheight = 500
@@ -699,6 +698,7 @@ def show_new_gui():
699698
blasbatchsize_text = ["Don't Batch BLAS","32","64","128","256","512","1024"]
700699
contextsize_text = ["512", "1024", "2048", "3072", "4096", "6144", "8192"]
701700
runopts = [opt for lib, opt in lib_option_pairs if file_exists(lib) or os.name == 'nt' and file_exists(opt + ".dll")]
701+
antirunopts = [opt.replace("Use ", "") for lib, opt in lib_option_pairs if not file_exists(lib) or os.name == 'nt' and not file_exists(opt + ".dll")]
702702
if not any(runopts):
703703
show_gui_warning("No Backend Available")
704704
def tabbuttonaction(name):
@@ -851,6 +851,24 @@ def get_device_names():
851851
CUDA_quick_gpu_selector_box = ctk.CTkComboBox(quick_tab, values=CUdevices, width=180, variable=gpu_choice_var, state="readonly")
852852
quick_lowvram_box = makecheckbox(quick_tab, "Low VRAM", lowvram_var, 5)
853853

854+
def show_tooltip(event, tooltip_text=None):
855+
if hasattr(show_tooltip, "_tooltip"):
856+
tooltip = show_tooltip._tooltip
857+
else:
858+
tooltip = ctk.CTkToplevel(root)
859+
tooltip.configure(fg_color="#ffffe0")
860+
tooltip.withdraw()
861+
tooltip.overrideredirect(True)
862+
tooltip_label = ctk.CTkLabel(tooltip, text=tooltip_text, text_color="#000000", fg_color="#ffffe0")
863+
tooltip_label.pack(expand=True, padx=2, pady=1)
864+
show_tooltip._tooltip = tooltip
865+
x, y = root.winfo_pointerxy()
866+
tooltip.wm_geometry(f"+{x + 10}+{y + 10}")
867+
tooltip.deiconify()
868+
def hide_tooltip(event):
869+
if hasattr(show_tooltip, "_tooltip"):
870+
tooltip = show_tooltip._tooltip
871+
tooltip.withdraw()
854872
def changerunmode(a,b,c):
855873
index = runopts_var.get()
856874
if index == "Use CLBlast" or index == "Use CuBLAS/hipBLAS":
@@ -894,7 +912,12 @@ def changerunmode(a,b,c):
894912
runoptbox = ctk.CTkComboBox(quick_tab, values=runopts, width=180,variable=runopts_var, state="readonly")
895913
runoptbox.grid(row=1, column=1,padx=8, stick="nw")
896914
runoptbox.set(runopts[0])
897-
915+
# Tell user how many backends are available
916+
num_backends_built = makelabel(quick_tab, str(len(runopts)) + "/6", 5, 2)
917+
num_backends_built.grid(row=1, column=2, padx=0, pady=0)
918+
num_backends_built.configure(text_color="#00ff00")
919+
num_backends_built.bind("<Enter>", lambda event: show_tooltip(event, f"This is the number of backends you have built and available.\nMissing: {', '.join(antirunopts)}"))
920+
num_backends_built.bind("<Leave>", hide_tooltip)
898921
# threads
899922
makelabelentry(quick_tab, "Threads:" , threads_var, 8, 50)
900923

@@ -905,7 +928,6 @@ def changerunmode(a,b,c):
905928
quick_boxes = {"Launch Browser": launchbrowser , "High Priority" : highpriority, "Streaming Mode":stream, "Use SmartContext":smartcontext, "Unban Tokens":unbantokens, "Disable MMAP":disablemmap,}
906929
for idx, name, in enumerate(quick_boxes):
907930
makecheckbox(quick_tab, name, quick_boxes[name], int(idx/2) +20, idx%2)
908-
909931
# context size
910932
makeslider(quick_tab, "Context Size:", contextsize_text, context_var, 0, len(contextsize_text)-1, 30, set=2)
911933

@@ -929,6 +951,13 @@ def changerunmode(a,b,c):
929951
runoptbox.set(runopts[0])
930952
runopts_var.trace('w', changerunmode)
931953
changerunmode(1,1,1)
954+
955+
# Tell user how many backends are available
956+
num_backends_built = makelabel(hardware_tab, str(len(runopts)) + "/6", 5, 2)
957+
num_backends_built.grid(row=1, column=2, padx=0, pady=0)
958+
num_backends_built.configure(text_color="#00ff00")
959+
num_backends_built.bind("<Enter>", show_tooltip)
960+
num_backends_built.bind("<Leave>", hide_tooltip)
932961
# threads
933962
makelabelentry(hardware_tab, "Threads:" , threads_var, 8, 50)
934963

0 commit comments

Comments
 (0)