fixed macos code

This commit is contained in:
Saifeddine ALOUI 2023-04-14 00:22:40 +02:00
parent cf593c7c52
commit a6c19e8e79

View File

@ -138,6 +138,7 @@ else
* ) echo "Skipping download of model file...";; * ) echo "Skipping download of model file...";;
esac esac
fi fi
#!/bin/bash
echo "" echo ""
echo "Downloading latest model..." echo "Downloading latest model..."
@ -168,13 +169,13 @@ case $yn in
echo "[$count] $f" echo "[$count] $f"
done done
Prompt user to choose a model to convert # Prompt user to choose a model to convert
read -p "Enter the number of the model you want to convert: " modelNumber read -p "Enter the number of the model you want to convert: " modelNumber
if [ -z "${file[modelNumber]}" ]; then if [ -z "${file[modelNumber]}" ]; then
echo "" echo ""
echo "Invalid option. Restarting..." echo "Invalid option. Restarting..."
exit 1 exit 1
fi fi
modelPath="${file[modelNumber]}" modelPath="${file[modelNumber]}"
@ -182,44 +183,37 @@ case $yn in
echo "" echo ""
echo "You selected $modelPath" echo "You selected $modelPath"
Ask user if they want to convert the model # Ask user if they want to convert the model
echo "" echo ""
read -p "Do you want to convert the selected model to the new format? (Y/N)" choice read -p "Do you want to convert the selected model to the new format? (Y/N)" choice
if [ "$choice" == "N" ]; then if [ "$choice" == "N" ]; then
echo "" echo ""
echo "Model conversion cancelled. Skipping..." echo "Model conversion cancelled. Skipping..."
exit 0 else
# Convert the model
echo "Converting the model to the new format..."
if [ ! -d "tmp/llama.cpp" ]; then
git clone https://github.com/ggerganov/llama.cpp.git tmp/llama.cpp
fi
mv -f "${modelPath}" "${modelPath}.original"
python tmp/llama.cpp/migrate-ggml-2023-03-30-pr613.py "${modelPath}.original" "${modelPath}"
if [ $? -ne 0 ]; then
echo ""
echo "Error during model conversion. Restarting..."
mv -f "${modelPath}.original" "${modelPath}"
exit 1
else
echo ""
echo "The model file (${modelPath}) has been converted to the new format."
fi
fi fi
;;
The output inside a code tag * ) echo ""
echo "The code has been converted successfully." echo "Conversion cancelled. Skipping..."
;;
esac esac
# Convert the model
echo ""
echo "Converting the model to the new format..."
if [ ! -d "tmp/llama.cpp" ]; then
git clone https://github.com/ggerganov/llama.cpp.git tmp/llama.cpp
fi
mv -f "${modelPath}" "${modelPath}.original"
python tmp/llama.cpp/migrate-ggml-2023-03-30-pr613.py "${modelPath}.original" "${modelPath}"
if [ $? -ne 0 ]; then
echo ""
echo "Error during model conversion. Restarting..."
mv -f "${modelPath}.original" "${modelPath}"
goto CONVERT_RESTART
else
echo ""
echo "The model file (${modelPath}) has been converted to the new format."
goto END
fi
:CANCEL_CONVERSION
echo ""
echo "Conversion cancelled. Skipping..."
goto END
:END
echo "" echo ""
echo "Cleaning tmp folder" echo "Cleaning tmp folder"
rm -rf "./tmp" rm -rf "./tmp"