debugging

This commit is contained in:
Yazan Agha-Schrader 2023-12-05 07:34:24 +01:00
parent b564660042
commit 87fda0dd86

View file

@ -84,6 +84,62 @@ model_selection_warning() {
# model_selection() {
# # User selects a file or folder
# exec 3>&1
# # Set initial directory for the file selection dialog
# INITIAL_DIR="$SCRIPT_DIR/../models/"
# model_path=$(dialog --backtitle "Model Selection" \
# --title "Select Model File or Folder" \
# --fselect "$INITIAL_DIR" $DIALOG_HEIGHT $DIALOG_WIDTH \
# 2>&1 1>&3)
# exit_status=$?
# exec 3>&-
# # Check whether user has selected 'Cancel'
# if [ $exit_status = 1 ]; then
# return
# fi
# # If a folder has been selected, search for *.gguf files
# if [ -d "$model_path" ]; then
# model_files=($(find "$model_path" -name "*.gguf" 2>/dev/null))
# # Check whether files have been found
# if [ ${#model_files[@]} -eq 0 ]; then
# dialog --backtitle "Model Selection" \
# --title "No Models Found" \
# --msgbox "\n\n\nNo model files (*.gguf) were found in the selected directory." $DIALOG_HEIGHT $DIALOG_WIDTH
# return
# fi
# elif [ -f "$model_path" ]; then
# model_files=("$model_path")
# else
# dialog --backtitle "Model Selection" \
# --title "Invalid Selection" \
# --msgbox "\n\n\nThe selected path is not valid." $DIALOG_HEIGHT $DIALOG_WIDTH
# return
# fi
# # Selection menu for models found
# exec 3>&1
# model_choice=$(dialog --backtitle "Model Selection" \
# --title "Select a Model File" \
# --menu "Choose one of the found models:" $DIALOG_HEIGHT $DIALOG_WIDTH \
# $(for i in "${!model_files[@]}"; do echo "$((i+1))" "$(basename "${model_files[$i]}")"; done) \
# 2>&1 1>&3)
# exit_status=$?
# exec 3>&-
# # Check whether user has selected 'Cancel'
# if [ $exit_status = 1 ]; then
# return
# fi
# # Set path to the selected model
# model_path=${model_files[$((model_choice-1))]}
# }
model_selection() { model_selection() {
# User selects a file or folder # User selects a file or folder
exec 3>&1 exec 3>&1
@ -93,7 +149,7 @@ model_selection() {
model_path=$(dialog --backtitle "Model Selection" \ model_path=$(dialog --backtitle "Model Selection" \
--title "Select Model File or Folder" \ --title "Select Model File or Folder" \
--fselect "$INITIAL_DIR" $DIALOG_HEIGHT $DIALOG_WIDTH \ --fselect "$INITIAL_DIR" 23 65 \
2>&1 1>&3) 2>&1 1>&3)
exit_status=$? exit_status=$?
exec 3>&- exec 3>&-
@ -106,41 +162,33 @@ model_selection() {
# If a folder has been selected, search for *.gguf files # If a folder has been selected, search for *.gguf files
if [ -d "$model_path" ]; then if [ -d "$model_path" ]; then
model_files=($(find "$model_path" -name "*.gguf" 2>/dev/null)) model_files=($(find "$model_path" -name "*.gguf" 2>/dev/null))
# Check whether files have been found
if [ ${#model_files[@]} -eq 0 ]; then
dialog --backtitle "Model Selection" \
--title "No Models Found" \
--msgbox "\n\n\nNo model files (*.gguf) were found in the selected directory." $DIALOG_HEIGHT $DIALOG_WIDTH
return
fi
elif [ -f "$model_path" ]; then elif [ -f "$model_path" ]; then
model_files=("$model_path") model_files=("$model_path")
else else
dialog --backtitle "Model Selection" \ dialog --backtitle "Model Selection" \
--title "Invalid Selection" \ --title "Invalid Selection" \
--msgbox "\n\n\nThe selected path is not valid." $DIALOG_HEIGHT $DIALOG_WIDTH --msgbox "The selected path is not valid." 23 65
return return
fi fi
# Selection menu for models found # Selection menu for models found
exec 3>&1 exec 3>&1
model_choice=$(dialog --backtitle "Model Selection" \ model_choice=$(dialog --backtitle "Model Selection" \
--title "Select a Model File" \ --title "Select a Model File" \
--menu "Choose one of the found models:" $DIALOG_HEIGHT $DIALOG_WIDTH \ --menu "Choose one of the found models:" 23 65 4 \
$(for i in "${!model_files[@]}"; do echo "$((i+1))" "$(basename "${model_files[$i]}")"; done) \ $(for i in "${!model_files[@]}"; do echo "$((i+1))" "$(basename "${model_files[$i]}")"; done) \
2>&1 1>&3) 2>&1 1>&3)
exit_status=$? exit_status=$?
exec 3>&- exec 3>&-
# Check whether user has selected 'Cancel' # Check whether user has selected 'Cancel'
if [ $exit_status = 1 ]; then if [ $exit_status = 1 ]; then
return return
fi fi
# Set path to the selected model
model_path=${model_files[$((model_choice-1))]}
}
# Set path to the selected model
model_path=${model_files[$((model_choice-1))]}
}
multimodal_model_selection() { multimodal_model_selection() {