Compare commits

..

2 Commits

View File

@ -16,6 +16,11 @@ extensions_folder = "./text-generation-webui/extensions"
loras_folder = "./text-generation-webui/loras" loras_folder = "./text-generation-webui/loras"
characters_folder = "./text-generation-webui/characters" characters_folder = "./text-generation-webui/characters"
if getattr(sys, 'frozen', False):
webui_file = sys._MEIPASS + '/webuiGUI.py'
else:
webui_file = 'webuiGUI.py'
# Get the current Max CPU threads to use, so the user can't exceed his thread count. # Get the current Max CPU threads to use, so the user can't exceed his thread count.
max_threads = psutil.cpu_count(logical=True) max_threads = psutil.cpu_count(logical=True)
@ -154,7 +159,7 @@ class MainWindow(QMainWindow):
self.Accelerate_settings_checkbox.stateChanged.connect(self.on_Accelerate_settings_checkbox_stateChanged) self.Accelerate_settings_checkbox.stateChanged.connect(self.on_Accelerate_settings_checkbox_stateChanged)
toolbar.addWidget(self.Accelerate_settings_checkbox) toolbar.addWidget(self.Accelerate_settings_checkbox)
if platform.system() == 'Windows': if platform.system() == 'Windows':
#self.Accelerate_settings_checkbox.setEnabled(False) self.Accelerate_settings_checkbox.setEnabled(False)
self.Accelerate_settings_checkbox.setToolTip("Accelerate is not Supported in Windows.") self.Accelerate_settings_checkbox.setToolTip("Accelerate is not Supported in Windows.")
################################################ ################################################
@ -1520,7 +1525,6 @@ class MainWindow(QMainWindow):
"use_cpu": self.cpu_radio_button.isChecked(), # Save the state of the CPU radio button "use_cpu": self.cpu_radio_button.isChecked(), # Save the state of the CPU radio button
"use_auto": self.auto_radio_button.isChecked(), # Save the state of the auto device radio button "use_auto": self.auto_radio_button.isChecked(), # Save the state of the auto device radio button
"built_in_ram": self.ram_slider.value(), # Save the value of the built-in RAM slider "built_in_ram": self.ram_slider.value(), # Save the value of the built-in RAM slider
#"prelayer": self.pre_layer_value_label.text(), # Saves the Prelayer value
"use_8bit": self.use_8bit_checkbox.isChecked(), # Saves the state of the 8bit checkbox "use_8bit": self.use_8bit_checkbox.isChecked(), # Saves the state of the 8bit checkbox
"no_stream": self.use_nostream_checkbox.isChecked(), # Saves the state of the no_stream checkbox "no_stream": self.use_nostream_checkbox.isChecked(), # Saves the state of the no_stream checkbox
"use_16bit": self.use_16bit_checkbox.isChecked(), # Saves the state of the use_16bit checkbox "use_16bit": self.use_16bit_checkbox.isChecked(), # Saves the state of the use_16bit checkbox
@ -1534,6 +1538,11 @@ class MainWindow(QMainWindow):
"sdp_attention": self.use_sdp_attention_checkbox.isChecked(), # Saves the state of the sdp_attention checkbox "sdp_attention": self.use_sdp_attention_checkbox.isChecked(), # Saves the state of the sdp_attention checkbox
"autogptq": self.use_autogptq_checkbox.isChecked(), # Saves the state of the autogptq checkbox "autogptq": self.use_autogptq_checkbox.isChecked(), # Saves the state of the autogptq checkbox
"triton": self.use_triton_checkbox.isChecked(), # Saves the state of the triton checkbox "triton": self.use_triton_checkbox.isChecked(), # Saves the state of the triton checkbox
"acceleration": self.Accelerate_settings_checkbox.isChecked(), # Saves the state of the Accelerate checkbox
"use_4bit": self.accelerate4bit_checkbox.isChecked(), # Saves the state of the accelerate4bit checkbox
"compute_dtype": self.accelerate4bit_compute_type_dropdown.currentText(), # Saves the state of the accelerate4bit_compute_type_dropdown
"quant_type": self.accelerate4bit_quant_type_dropdown.currentText(), # Saves the state of the accelerate4bit_quant_type_dropdown
"use_x2_quant": self.accelerate4bit_double_quant_checkbox.isChecked(), # Saves the state of the accelerate4bit_double_quant_checkbox
"deepspeed": self.deepspeed_settings_checkbox.isChecked(), # Saves the state of the deepspeed checkbox "deepspeed": self.deepspeed_settings_checkbox.isChecked(), # Saves the state of the deepspeed checkbox
"deepspeed_enabled": self.deepspeed_checkbox.isChecked(), # Saves the state of the deepspeed checkbox "deepspeed_enabled": self.deepspeed_checkbox.isChecked(), # Saves the state of the deepspeed checkbox
"deepspeed_gpu_num": self.deepspeed_gpu_num_spinbox.value(), # Saves the state of the deepspeed_gpu_num_spinbox "deepspeed_gpu_num": self.deepspeed_gpu_num_spinbox.value(), # Saves the state of the deepspeed_gpu_num_spinbox
@ -1603,7 +1612,6 @@ class MainWindow(QMainWindow):
def expression_check(self, command): def expression_check(self, command):
selected_model = self.model_dropdown.currentText() selected_model = self.model_dropdown.currentText()
#print(f"Selected model: {selected_model}")
# Use a regular expression to check if the selected model matches the pattern # Use a regular expression to check if the selected model matches the pattern
if re.search(r".*mpt.*7b", selected_model, re.IGNORECASE): if re.search(r".*mpt.*7b", selected_model, re.IGNORECASE):
@ -1649,9 +1657,8 @@ class MainWindow(QMainWindow):
command += f" --model {chosen_model}" command += f" --model {chosen_model}"
# Add the chosen model type to the command # Add the chosen model type to the command
chosen_model_type = self.model_type.currentText()
if self.model_type.currentText() != "none" and self.model_dropdown.currentText() != "none": if self.model_type.currentText() != "none" and self.model_dropdown.currentText() != "none":
command += f" --model_type {chosen_model_type}" command += f" --model_type {self.model_type.currentText()}"
# Add loras to the command # Add loras to the command
loras = [self.lora_list.item(i).text() for i in range(self.lora_list.count()) if self.lora_list.item(i).checkState() == Qt.Checked] loras = [self.lora_list.item(i).text() for i in range(self.lora_list.count()) if self.lora_list.item(i).checkState() == Qt.Checked]
@ -1660,22 +1667,18 @@ class MainWindow(QMainWindow):
command += f" --lora {' '.join(loras)}" command += f" --lora {' '.join(loras)}"
# Add Characters to the command # Add Characters to the command
chosen_characters = self.character_to_load.currentText()
if self.character_to_load.currentText() != "none": if self.character_to_load.currentText() != "none":
command += f" --character {chosen_characters}" command += f" --character {self.character_to_load.currentText()}"
print(chosen_characters)
# Adds wbits to the command, if not "none" # Adds wbits to the command, if not "none"
chosen_wbits = self.wbit_dropdown.currentText()
if self.wbit_dropdown.currentText() != "none": if self.wbit_dropdown.currentText() != "none":
if not self.cpu_radio_button.isChecked() and self.model_dropdown.currentText() != "none": if not self.cpu_radio_button.isChecked() and self.model_dropdown.currentText() != "none":
command += f" --wbits {chosen_wbits}" command += f" --wbits {self.wbit_dropdown.currentText()}"
# Adds Groupsize to the command, if not "none" # Adds Groupsize to the command, if not "none"
chosen_gsize = self.gsize_dropdown.currentText()
if self.gsize_dropdown.currentText() != "none": if self.gsize_dropdown.currentText() != "none":
if not self.cpu_radio_button.isChecked() and self.model_dropdown.currentText() != "none": if not self.cpu_radio_button.isChecked() and self.model_dropdown.currentText() != "none":
command += f" --groupsize {chosen_gsize}" command += f" --groupsize {self.gsize_dropdown.currentText()}"
# Add the chosen mode to the command (Chat, cai-chat, notebook) # Add the chosen mode to the command (Chat, cai-chat, notebook)
chosen_mode = self.mode_dropdown.currentText() chosen_mode = self.mode_dropdown.currentText()
@ -1750,10 +1753,10 @@ class MainWindow(QMainWindow):
if self.accelerate4bit_checkbox.isChecked(): if self.accelerate4bit_checkbox.isChecked():
command += " --load-in-4bit" command += " --load-in-4bit"
if self.accelerate4bit_compute_type_dropdown != "none": if self.accelerate4bit_compute_type_dropdown.currentText() != "none":
command += f" --compute_dtype {self.accelerate4bit_compute_type_dropdown.currentText()}" command += f" --compute_dtype {self.accelerate4bit_compute_type_dropdown.currentText()}"
if self.accelerate4bit_quant_type_dropdown != "none": if self.accelerate4bit_quant_type_dropdown.currentText() != "none":
command += f" --quant_type {self.accelerate4bit_quant_type_dropdown.currentText()}" command += f" --quant_type {self.accelerate4bit_quant_type_dropdown.currentText()}"
if self.accelerate4bit_double_quant_checkbox.isChecked(): if self.accelerate4bit_double_quant_checkbox.isChecked():
@ -1805,7 +1808,6 @@ class MainWindow(QMainWindow):
# If AutoGPTQ is checked # If AutoGPTQ is checked
if self.use_autogptq_checkbox.isChecked(): if self.use_autogptq_checkbox.isChecked():
command += " --autogptq" command += " --autogptq"
run_cmd_with_conda("pip install auto_gptq && exit")
# If triton is checked # If triton is checked
if self.use_triton_checkbox.isChecked(): if self.use_triton_checkbox.isChecked():
@ -1828,7 +1830,7 @@ class MainWindow(QMainWindow):
command += f" --api-streaming-port {self.api_streaming_port_SpinBox.text()}" command += f" --api-streaming-port {self.api_streaming_port_SpinBox.text()}"
# Just for debugging. # Just for debugging.
print(f"Command generated: python webuiGUI.py {command}") print(f"Command generated: python {webui_file} {command}")
# Based on the Model that's chosen, we will take care of some necessary stuff. # Based on the Model that's chosen, we will take care of some necessary stuff.
# Starts the webui in the conda env with the user given Options # Starts the webui in the conda env with the user given Options
@ -1848,15 +1850,15 @@ class MainWindow(QMainWindow):
if not self.deepspeed_checkbox.isChecked(): if not self.deepspeed_checkbox.isChecked():
if self.use_8bit_checkbox.isChecked(): if self.use_8bit_checkbox.isChecked():
run_cmd_with_conda(f"pip install accelerate && python webuiGUI.py {command}") run_cmd_with_conda(f"pip install accelerate && python {webui_file} {command}")
else: else:
run_cmd_with_conda(f"python webuiGUI.py {command}") run_cmd_with_conda(f"python {webui_file} {command}")
if self.use_autoclose_checkbox.isChecked(): if self.use_autoclose_checkbox.isChecked():
sys.exit() sys.exit()
def on_update_button_clicked(self): def on_update_button_clicked(self):
run_cmd_with_conda("python webuiGUI.py --update && exit") run_cmd_with_conda(f"python {webui_file} --update && exit")
def load_profile(self, profile_file): def load_profile(self, profile_file):
with open(profile_file, "r") as file: with open(profile_file, "r") as file:
@ -1909,6 +1911,11 @@ class MainWindow(QMainWindow):
self.use_sdp_attention_checkbox.setChecked(settings.get("sdp_attention", False)) self.use_sdp_attention_checkbox.setChecked(settings.get("sdp_attention", False))
self.use_autogptq_checkbox.setChecked(settings.get("autogptq", False)) self.use_autogptq_checkbox.setChecked(settings.get("autogptq", False))
self.use_triton_checkbox.setChecked(settings.get("triton", False)) self.use_triton_checkbox.setChecked(settings.get("triton", False))
self.Accelerate_settings_checkbox.setChecked(settings.get("acceleration", False))
self.accelerate4bit_checkbox.setChecked(settings.get("use_4bit", False))
self.accelerate4bit_compute_type_dropdown.setCurrentText(settings.get("compute_dtype", ""))
self.accelerate4bit_quant_type_dropdown.setCurrentText(settings.get("quant_type", ""))
self.accelerate4bit_double_quant_checkbox.setChecked(settings.get("use_x2_quant", False))
self.deepspeed_settings_checkbox.setChecked(settings.get("deepspeed", False)) self.deepspeed_settings_checkbox.setChecked(settings.get("deepspeed", False))
self.deepspeed_checkbox.setChecked(settings.get("deepspeed_enabled", False)) self.deepspeed_checkbox.setChecked(settings.get("deepspeed_enabled", False))
self.deepspeed_gpu_num_spinbox.setValue(int(settings.get("deepspeed_gpu_num", 0))) self.deepspeed_gpu_num_spinbox.setValue(int(settings.get("deepspeed_gpu_num", 0)))