5
5
6
6
import psutil
7
7
import requests
8
+ from functools import partial
8
9
from PySide6 .QtCore import *
9
10
from PySide6 .QtGui import *
10
11
from PySide6 .QtWidgets import *
19
20
from error_handling import show_error , handle_error
20
21
from imports_and_globals import ensure_directory , open_file_safe , resource_path
21
22
from localizations import *
23
+ from ui_update import *
22
24
23
25
24
26
class AutoGGUF (QMainWindow ):
@@ -34,6 +36,19 @@ def __init__(self):
34
36
ensure_directory (os .path .abspath ("quantized_models" ))
35
37
ensure_directory (os .path .abspath ("models" ))
36
38
39
+ # References
40
+ self .update_base_model_visibility = partial (update_base_model_visibility , self )
41
+ self .update_assets = update_assets .__get__ (self )
42
+ self .update_cuda_option = update_cuda_option .__get__ (self )
43
+ self .update_cuda_backends = update_cuda_backends .__get__ (self )
44
+ self .update_threads_spinbox = partial (update_threads_spinbox , self )
45
+ self .update_threads_slider = partial (update_threads_slider , self )
46
+ self .update_gpu_offload_spinbox = partial (update_gpu_offload_spinbox , self )
47
+ self .update_gpu_offload_slider = partial (update_gpu_offload_slider , self )
48
+ self .update_model_info = partial (update_model_info , self .logger , self )
49
+ self .update_system_info = partial (update_system_info , self )
50
+ self .update_download_progress = partial (update_download_progress , self )
51
+
37
52
# Create a central widget and main layout
38
53
central_widget = QWidget ()
39
54
main_layout = QHBoxLayout (central_widget )
@@ -52,6 +67,23 @@ def __init__(self):
52
67
left_widget .setMinimumWidth (800 )
53
68
right_widget .setMinimumWidth (400 )
54
69
70
+ menubar = QMenuBar (self )
71
+ self .layout ().setMenuBar (menubar )
72
+
73
+ # File menu
74
+ file_menu = menubar .addMenu ("&File" )
75
+ close_action = QAction ("&Close" , self )
76
+ close_action .setShortcut (QKeySequence .Quit )
77
+ close_action .triggered .connect (self .close )
78
+ file_menu .addAction (close_action )
79
+
80
+ # Help menu
81
+ help_menu = menubar .addMenu ("&Help" )
82
+ about_action = QAction ("&About" , self )
83
+ about_action .setShortcut (QKeySequence ("Ctrl+Q" ))
84
+ about_action .triggered .connect (self .show_about )
85
+ help_menu .addAction (about_action )
86
+
55
87
left_layout = QVBoxLayout (left_widget )
56
88
right_layout = QVBoxLayout (right_widget )
57
89
@@ -679,9 +711,13 @@ def refresh_backends(self):
679
711
self .backend_combo .setEnabled (False )
680
712
self .logger .info (FOUND_VALID_BACKENDS .format (self .backend_combo .count ()))
681
713
682
- def update_base_model_visibility (self , index ):
683
- is_gguf = self .lora_output_type_combo .itemText (index ) == "GGUF"
684
- self .base_model_wrapper .setVisible (is_gguf )
714
+ def show_about (self ):
715
+ about_text = (
716
+ "AutoGGUF\n \n "
717
+ f"Version: { AUTOGGUF_VERSION } \n \n "
718
+ "A tool for managing and converting GGUF models."
719
+ )
720
+ QMessageBox .about (self , "About AutoGGUF" , about_text )
685
721
686
722
def save_preset (self ):
687
723
self .logger .info (SAVING_PRESET )
@@ -1174,20 +1210,6 @@ def refresh_releases(self):
1174
1210
except requests .exceptions .RequestException as e :
1175
1211
show_error (self .logger , ERROR_FETCHING_RELEASES .format (str (e )))
1176
1212
1177
- def update_assets (self ):
1178
- self .logger .debug (UPDATING_ASSET_LIST )
1179
- self .asset_combo .clear ()
1180
- release = self .release_combo .currentData ()
1181
- if release :
1182
- if "assets" in release :
1183
- for asset in release ["assets" ]:
1184
- self .asset_combo .addItem (asset ["name" ], userData = asset )
1185
- else :
1186
- show_error (
1187
- self .logger , NO_ASSETS_FOUND_FOR_RELEASE .format (release ["tag_name" ])
1188
- )
1189
- self .update_cuda_option ()
1190
-
1191
1213
def download_llama_cpp (self ):
1192
1214
self .logger .info (STARTING_LLAMACPP_DOWNLOAD )
1193
1215
asset = self .asset_combo .currentData ()
@@ -1209,45 +1231,6 @@ def download_llama_cpp(self):
1209
1231
self .download_button .setEnabled (False )
1210
1232
self .download_progress .setValue (0 )
1211
1233
1212
- def update_cuda_option (self ):
1213
- self .logger .debug (UPDATING_CUDA_OPTIONS )
1214
- asset = self .asset_combo .currentData ()
1215
-
1216
- # Handle the case where asset is None
1217
- if asset is None :
1218
- self .logger .warning (NO_ASSET_SELECTED_FOR_CUDA_CHECK )
1219
- self .cuda_extract_checkbox .setVisible (False )
1220
- self .cuda_backend_label .setVisible (False )
1221
- self .backend_combo_cuda .setVisible (False )
1222
- return # Exit the function early
1223
-
1224
- is_cuda = asset and "cudart" in asset ["name" ].lower ()
1225
- self .cuda_extract_checkbox .setVisible (is_cuda )
1226
- self .cuda_backend_label .setVisible (is_cuda )
1227
- self .backend_combo_cuda .setVisible (is_cuda )
1228
- if is_cuda :
1229
- self .update_cuda_backends ()
1230
-
1231
- def update_cuda_backends (self ):
1232
- self .logger .debug (UPDATING_CUDA_BACKENDS )
1233
- self .backend_combo_cuda .clear ()
1234
- llama_bin = os .path .abspath ("llama_bin" )
1235
- if os .path .exists (llama_bin ):
1236
- for item in os .listdir (llama_bin ):
1237
- item_path = os .path .join (llama_bin , item )
1238
- if os .path .isdir (item_path ) and "cudart-llama" not in item .lower ():
1239
- if "cu1" in item .lower (): # Only include CUDA-capable backends
1240
- self .backend_combo_cuda .addItem (item , userData = item_path )
1241
-
1242
- if self .backend_combo_cuda .count () == 0 :
1243
- self .backend_combo_cuda .addItem (NO_SUITABLE_CUDA_BACKENDS )
1244
- self .backend_combo_cuda .setEnabled (False )
1245
- else :
1246
- self .backend_combo_cuda .setEnabled (True )
1247
-
1248
- def update_download_progress (self , progress ):
1249
- self .download_progress .setValue (progress )
1250
-
1251
1234
def download_finished (self , extract_dir ):
1252
1235
self .download_button .setEnabled (True )
1253
1236
self .download_progress .setValue (100 )
@@ -1335,18 +1318,6 @@ def show_task_properties(self, item):
1335
1318
model_info_dialog .exec ()
1336
1319
break
1337
1320
1338
- def update_threads_spinbox (self , value ):
1339
- self .threads_spinbox .setValue (value )
1340
-
1341
- def update_threads_slider (self , value ):
1342
- self .threads_slider .setValue (value )
1343
-
1344
- def update_gpu_offload_spinbox (self , value ):
1345
- self .gpu_offload_spinbox .setValue (value )
1346
-
1347
- def update_gpu_offload_slider (self , value ):
1348
- self .gpu_offload_slider .setValue (value )
1349
-
1350
1321
def toggle_gpu_offload_auto (self , state ):
1351
1322
is_auto = state == Qt .CheckState .Checked
1352
1323
self .gpu_offload_slider .setEnabled (not is_auto )
@@ -1483,17 +1454,6 @@ def validate_quantization_inputs(self):
1483
1454
if errors :
1484
1455
raise ValueError ("\n " .join (errors ))
1485
1456
1486
- def update_system_info (self ):
1487
- ram = psutil .virtual_memory ()
1488
- cpu = psutil .cpu_percent ()
1489
- self .ram_bar .setValue (int (ram .percent ))
1490
- self .ram_bar .setFormat (
1491
- RAM_USAGE_FORMAT .format (
1492
- ram .percent , ram .used // 1024 // 1024 , ram .total // 1024 // 1024
1493
- )
1494
- )
1495
- self .cpu_label .setText (CPU_USAGE_FORMAT .format (cpu ))
1496
-
1497
1457
def add_kv_override (self , override_string = None ):
1498
1458
entry = KVOverrideEntry ()
1499
1459
entry .deleted .connect (self .remove_kv_override )
@@ -1679,10 +1639,6 @@ def quantize_model(self):
1679
1639
except Exception as e :
1680
1640
show_error (self .logger , ERROR_STARTING_QUANTIZATION .format (str (e )))
1681
1641
1682
- def update_model_info (self , model_info ):
1683
- self .logger .debug (UPDATING_MODEL_INFO .format (model_info ))
1684
- pass
1685
-
1686
1642
def parse_progress (self , line , task_item ):
1687
1643
# Parses the output line for progress information and updates the task item.
1688
1644
match = re .search (r"\[(\d+)/(\d+)\]" , line )
0 commit comments