fix: Hide Base Model label when GGML type selected

This commit is contained in:
BuildTools 2024-08-04 19:32:07 -07:00
parent 943c32fea0
commit 2dc5bd9e8a
2 changed files with 1624 additions and 1618 deletions

View File

@ -452,28 +452,32 @@ def __init__(self):
# Output Type Dropdown # Output Type Dropdown
self.lora_output_type_combo = QComboBox() self.lora_output_type_combo = QComboBox()
self.lora_output_type_combo.addItems(["GGML", "GGUF"]) self.lora_output_type_combo.addItems(["GGML", "GGUF"])
self.lora_output_type_combo.currentIndexChanged.connect( self.lora_output_type_combo.currentIndexChanged.connect(self.update_base_model_visibility)
self.update_base_model_visibility lora_layout.addRow(self.create_label(OUTPUT_TYPE, SELECT_OUTPUT_TYPE), self.lora_output_type_combo)
) # Connect to update visibility
lora_layout.addRow(
self.create_label(OUTPUT_TYPE, SELECT_OUTPUT_TYPE),
self.lora_output_type_combo,
)
# Base Model Path (initially hidden) # Base Model Path (initially hidden)
self.base_model_label = self.create_label(BASE_MODEL, SELECT_BASE_MODEL_FILE)
self.base_model_path = QLineEdit() self.base_model_path = QLineEdit()
base_model_button = QPushButton(BROWSE) base_model_button = QPushButton(BROWSE)
base_model_button.clicked.connect(self.browse_base_model) base_model_button.clicked.connect(self.browse_base_model)
base_model_layout = QHBoxLayout() base_model_layout = QHBoxLayout()
base_model_layout.addWidget(self.base_model_path) base_model_layout.addWidget(self.base_model_path, 1) # Give it a stretch factor
base_model_layout.addWidget(base_model_button) base_model_layout.addWidget(base_model_button)
self.base_model_widget = QWidget() self.base_model_widget = QWidget()
self.base_model_widget.setLayout(base_model_layout) self.base_model_widget.setLayout(base_model_layout)
self.base_model_widget.setVisible(False) # Initially hidden
lora_layout.addRow( # Create a wrapper widget to hold both label and input
self.create_label(BASE_MODEL, SELECT_BASE_MODEL_FILE), self.base_model_wrapper = QWidget()
self.base_model_widget, wrapper_layout = QHBoxLayout(self.base_model_wrapper)
) wrapper_layout.addWidget(self.base_model_label)
wrapper_layout.addWidget(self.base_model_widget, 1) # Give it a stretch factor
wrapper_layout.setContentsMargins(0, 0, 0, 0) # Remove margins for better alignment
# Add the wrapper to the layout
lora_layout.addRow(self.base_model_wrapper)
# Set initial visibility
self.update_base_model_visibility(self.lora_output_type_combo.currentIndex())
lora_convert_button = QPushButton(CONVERT_LORA) lora_convert_button = QPushButton(CONVERT_LORA)
lora_convert_button.clicked.connect(self.convert_lora) lora_convert_button.clicked.connect(self.convert_lora)
@ -542,6 +546,9 @@ def __init__(self):
self.task_list.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.task_list.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.task_list.customContextMenuRequested.connect(self.show_task_context_menu) self.task_list.customContextMenuRequested.connect(self.show_task_context_menu)
# Set inital state
self.update_base_model_visibility(self.lora_output_type_combo.currentIndex())
# Timer for updating system info # Timer for updating system info
self.timer = QTimer() self.timer = QTimer()
self.timer.timeout.connect(self.update_system_info) self.timer.timeout.connect(self.update_system_info)
@ -577,9 +584,8 @@ def refresh_backends(self):
self.logger.info(FOUND_VALID_BACKENDS.format(self.backend_combo.count())) self.logger.info(FOUND_VALID_BACKENDS.format(self.backend_combo.count()))
def update_base_model_visibility(self, index): def update_base_model_visibility(self, index):
self.base_model_widget.setVisible( is_gguf = self.lora_output_type_combo.itemText(index) == "GGUF"
self.lora_output_type_combo.itemText(index) == "GGUF" self.base_model_wrapper.setVisible(is_gguf)
)
def save_preset(self): def save_preset(self):
self.logger.info(SAVING_PRESET) self.logger.info(SAVING_PRESET)