diff --git a/lollms/binding.py b/lollms/binding.py index f1e8421..e459317 100644 --- a/lollms/binding.py +++ b/lollms/binding.py @@ -234,13 +234,19 @@ class LLMBinding: for mn in self.models_folders: if mn.name in model_name.lower(): if mn.name == "ggml": - idx = model_name.index("-GGML") - models=[m for m in mn.iterdir() if model_name[:idx].lower() in m.name.lower()] - model_path = mn/models[0].name + try: + idx = model_name.index("-GGML") + models=[m for m in mn.iterdir() if model_name[:idx].lower() in m.name.lower()] + model_path = mn/models[0].name + except: + model_path = mn/model_name elif mn.name == "gguf": - idx = model_name.index("-GGUF") - models=[m for m in mn.iterdir() if model_name[:idx].lower() in m.name.lower()] - model_path = mn/models[0].name + try: + idx = model_name.index("-GGUF") + models=[m for m in mn.iterdir() if model_name[:idx].lower() in m.name.lower()] + model_path = mn/models[0].name + except: + model_path = mn/model_name else: model_path = mn/model_name break diff --git a/scripts/linux/linux_conda_session.sh b/scripts/linux/linux_conda_session.sh new file mode 100644 index 0000000..7d5a6d0 --- /dev/null +++ b/scripts/linux/linux_conda_session.sh @@ -0,0 +1,37 @@ +#!/bin/bash +echo Starting LOLLMS Web UI... +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo " By ParisNeo" + + +cd "$(dirname "$0")" + +# better isolation for virtual environment +CONDA_SHLVL="" +PYTHONNOUSERSITE=1 +PYTHONPATH="" +PYTHONHOME="" +TEMP="./installer_files/temp" +TMP="./installer_files/temp" +INSTALL_ENV_DIR="./installer_files/lollms_env" +MINICONDA_DIR="./installer_files/miniconda3" + +if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then + echo "Miniconda not found." + exit 1 +fi + +source "$MINICONDA_DIR/bin/activate" "$INSTALL_ENV_DIR" + + +read -rp "Conda environment activated" diff --git a/scripts/linux/linux_install.sh b/scripts/linux/linux_install.sh new file mode 100644 index 0000000..f1c6cd5 --- /dev/null +++ b/scripts/linux/linux_install.sh @@ -0,0 +1,207 @@ +#!/bin/bash + +# This script will install miniconda and git with all dependencies for this project +# This enables a user to install this project without manually installing conda and git. + + +cd "$(dirname "$0")" + +if [[ "$PWD" == *" "* ]]; then + echo "This script relies on Miniconda which cannot be silently installed under a path with spaces." + exit 1 +fi + +echo "WARNING: This script relies on Miniconda which will fail to install if the path is too long." + +if [[ "$PWD" =~ [^#\$\%\&\(\)\*\+\] ]]; then + echo "WARNING: Special characters were detected in the installation path!" + echo " This can cause the installation to fail!" +fi + + + + +read -rp "Press Enter to continue..." + +clear + +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo " By ParisNeo" + +echo "Please specify if you want to use a GPU or CPU." +echo "*Note* that only NVidea GPUs (cuda) or AMD GPUs (rocm) are supported." +echo "A) Enable Cuda (for nvidia GPUS)" +echo "B) Enable ROCm (for AMD GPUs)" +echo "C) Run CPU mode" +echo +read -rp "Input> " gpuchoice +gpuchoice="${gpuchoice:0:1}" + +if [[ "${gpuchoice^^}" == "A" ]]; then + PACKAGES_TO_INSTALL="python=3.10 cuda-toolkit ninja git gcc" + CHANNEL="-c nvidia/label/cuda-11.8.0 -c nvidia -c conda-forge" +elif [[ "${gpuchoice^^}" == "B" ]]; then + PACKAGES_TO_INSTALL="python=3.10 rocm-comgr rocm-smi ninja git gcc" + CHANNEL=" -c conda-forge" +elif [[ "${gpuchoice^^}" == "C" ]]; then + PACKAGES_TO_INSTALL="python=3.10 ninja git gcc" + CHANNEL="-c conda-forge" +else + echo "Invalid choice. Exiting..." + exit 1 +fi + +# Better isolation for virtual environment +unset CONDA_SHLVL +export PYTHONNOUSERSITE=1 +unset PYTHONPATH +unset PYTHONHOME +export TEMP="$PWD/installer_files/temp" +export TMP="$PWD/installer_files/temp" + +MINICONDA_DIR="$PWD/installer_files/miniconda3" +INSTALL_ENV_DIR="$PWD/installer_files/lollms_env" +MINICONDA_DOWNLOAD_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" +REPO_URL="https://github.com/ParisNeo/lollms.git" + +if [ ! -f "$MINICONDA_DIR/Scripts/conda" ]; then + # Download miniconda + echo "Downloading Miniconda installer from $MINICONDA_DOWNLOAD_URL" + curl -LOk "$MINICONDA_DOWNLOAD_URL" + + # Install miniconda + echo + echo "Installing Miniconda to $MINICONDA_DIR" + echo "Please wait..." + echo + bash "Miniconda3-latest-Linux-x86_64.sh" -b -p "$MINICONDA_DIR" || ( echo && echo "Miniconda installer not found." && exit 1 ) + rm -f "Miniconda3-latest-Linux-x86_64.sh" + if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then + echo && echo "Miniconda install failed." && exit 1 + fi +fi + +# Activate miniconda +source "$MINICONDA_DIR/bin/activate" || ( echo "Miniconda hook not found." && exit 1 ) + +# Create the installer environment +if [ ! -d "$INSTALL_ENV_DIR" ]; then + echo "Packages to install: $PACKAGES_TO_INSTALL" + conda create -y -k -p "$INSTALL_ENV_DIR" $CHANNEL $PACKAGES_TO_INSTALL || ( echo && echo "Conda environment creation failed." && exit 1 ) + if [[ "${gpuchoice^^}" == "A" ]]; then + conda run --live-stream -p "$INSTALL_ENV_DIR" python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 || ( echo && echo "Pytorch installation failed." && exit 1 ) + elif [[ "${gpuchoice^^}" == "B" ]]; then + conda run --live-stream -p "$INSTALL_ENV_DIR" python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.4.2 || ( echo && echo "Pytorch installation failed." && exit 1 ) + elif [[ "${gpuchoice^^}" == "C" ]]; then + conda run --live-stream -p "$INSTALL_ENV_DIR" python -m pip install torch torchvision torchaudio || ( echo && echo "Pytorch installation failed." && exit 1 ) + fi +fi + +# Check if conda environment was actually created +if [ ! -x "$INSTALL_ENV_DIR/bin/python" ]; then + echo && echo "Conda environment is empty." && exit 1 +fi + +# Activate installer environment +source activate "$INSTALL_ENV_DIR" || ( echo && echo "Conda environment activation failed." && exit 1 ) + +# Set default cuda toolkit to the one in the environment +export CUDA_PATH="$INSTALL_ENV_DIR" + +# Clone the repository +if [ -d "lollms" ]; then + cd lollms || exit 1 + git pull +else + git clone "$REPO_URL" + cd lollms || exit 1 +fi + +# Initilize all submodules and set them to main branch +echo "Initializing submodules" +git submodule update --init +cd zoos/bindings_zoo +git checkout main +cd ../personalities_zoo +git checkout main +cd ../extensions_zoo +git checkout main +cd ../models_zoo +git checkout main + +cd ../.. + +# Loop through each "git+" requirement and uninstall it (workaround for inconsistent git package updating) +while IFS= read -r requirement; do + if echo "$requirement" | grep -q "git+"; then + package_name=$(echo "$requirement" | awk -F'/' '{ print $4 }' | awk -F'@' '{ print $1 }') + python -m pip uninstall -y "$package_name" + fi +done < requirements.txt + +# Install the pip requirements +python -m pip install -r requirements.txt --upgrade +python -m pip install -e lollms_core --upgrade +python -m pip install -e utilities/safe_store --upgrade + + +if [[ -e "../linux_lollms_server.sh" ]]; then + echo "Linux server found" +else + cp scripts/linux/linux_lollms_server.sh ../ +fi + +if [[ -e "../linux_lollms_settings.sh" ]]; then + echo "Linux server found" +else + cp scripts/linux/linux_lollms_settings.sh ../ +fi + +if [[ -e "../linux_update.sh" ]]; then + echo "Linux update found" +else + cp scripts/linux/linux_update.sh ../ +fi + +if [[ -e "../linux_conda_session.sh" ]]; then + echo "Linux update found" +else + cp scripts/linux/linux_conda_session.sh ../ +fi + +if [[ -e "../linux_update_models.sh" ]]; then + echo "Linux update found" +else + cp scripts/linux/linux_update_models.sh ../ +fi + +if [[ "${gpuchoice^^}" == "C" ]]; then + echo "This is a .no_gpu file." > .no_gpu + echo "You have chosen to use only CPU on this system." +else + echo "You have chosen to use GPU on this system." +fi + +PrintBigMessage() { + echo + echo "*******************************************************************" + for message in "$@"; do + echo "* $message" + done + echo "*******************************************************************" + echo +} + +PrintBigMessage "$@" + +exit 0 diff --git a/scripts/linux/linux_lollms_server.sh b/scripts/linux/linux_lollms_server.sh new file mode 100644 index 0000000..03a5bd2 --- /dev/null +++ b/scripts/linux/linux_lollms_server.sh @@ -0,0 +1,42 @@ +#!/bin/bash +echo Starting LOLLMS Web UI... +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo " By ParisNeo" + + +cd "$(dirname "$0")" + +# better isolation for virtual environment +CONDA_SHLVL="" +PYTHONNOUSERSITE=1 +PYTHONPATH="" +PYTHONHOME="" +TEMP="./installer_files/temp" +TMP="./installer_files/temp" +INSTALL_ENV_DIR="./installer_files/lollms_env" +MINICONDA_DIR="./installer_files/miniconda3" + +if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then + echo "Miniconda not found." + exit 1 +fi + +source "$MINICONDA_DIR/bin/activate" "$INSTALL_ENV_DIR" +cd lollms + +# set default cuda toolkit to the one in the environment +CUDA_PATH="$INSTALL_ENV_DIR" + +lollms-server "$@" + +read -rp "Press Enter to exit..." diff --git a/scripts/linux/linux_lollms_settings.sh b/scripts/linux/linux_lollms_settings.sh new file mode 100644 index 0000000..b0c1f66 --- /dev/null +++ b/scripts/linux/linux_lollms_settings.sh @@ -0,0 +1,42 @@ +#!/bin/bash +echo Starting LOLLMS Web UI... +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo " By ParisNeo" + + +cd "$(dirname "$0")" + +# better isolation for virtual environment +CONDA_SHLVL="" +PYTHONNOUSERSITE=1 +PYTHONPATH="" +PYTHONHOME="" +TEMP="./installer_files/temp" +TMP="./installer_files/temp" +INSTALL_ENV_DIR="./installer_files/lollms_env" +MINICONDA_DIR="./installer_files/miniconda3" + +if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then + echo "Miniconda not found." + exit 1 +fi + +source "$MINICONDA_DIR/bin/activate" "$INSTALL_ENV_DIR" +cd lollms + +# set default cuda toolkit to the one in the environment +CUDA_PATH="$INSTALL_ENV_DIR" + +lollms-settings "$@" + +read -rp "Press Enter to exit..." diff --git a/scripts/linux/linux_update.sh b/scripts/linux/linux_update.sh new file mode 100644 index 0000000..9f048b3 --- /dev/null +++ b/scripts/linux/linux_update.sh @@ -0,0 +1,43 @@ +#!/bin/bash +echo Starting LOLLMS Web UI... +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo " By ParisNeo" + + +cd "$(dirname "$0")" + +# better isolation for virtual environment +CONDA_SHLVL="" +PYTHONNOUSERSITE=1 +PYTHONPATH="" +PYTHONHOME="" +TEMP="./installer_files/temp" +TMP="./installer_files/temp" +INSTALL_ENV_DIR="./installer_files/lollms_env" +MINICONDA_DIR="./installer_files/miniconda3" + +if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then + echo "Miniconda not found." + exit 1 +fi + +source "$MINICONDA_DIR/bin/activate" "$INSTALL_ENV_DIR" +cd lollms + +echo Pulling latest changes +git pull + +echo Reinstalling requirements +pip install --upgrade -r requirements.txt + +pause diff --git a/scripts/linux/linux_update_models.sh b/scripts/linux/linux_update_models.sh new file mode 100644 index 0000000..a8f5757 --- /dev/null +++ b/scripts/linux/linux_update_models.sh @@ -0,0 +1,63 @@ +#!/bin/bash +echo Starting LOLLMS Web UI... +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo " By ParisNeo" +echo " Models list update script" + +cd "$(dirname "$0")" + +# better isolation for virtual environment +CONDA_SHLVL="" +PYTHONNOUSERSITE=1 +PYTHONPATH="" +PYTHONHOME="" +TEMP="./installer_files/temp" +TMP="./installer_files/temp" +INSTALL_ENV_DIR="./installer_files/lollms_env" +MINICONDA_DIR="./installer_files/miniconda3" + +if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then + echo "Miniconda not found." + exit 1 +fi + +source "$MINICONDA_DIR/bin/activate" "$INSTALL_ENV_DIR" + + +# Set your repository URL and file path +repository_url="https://github.com/ParisNeo/lollms_bindings_zoo.git" + +# Set the destination folder where the file will be downloaded +destination_folder="downloaded_files" + +# Create the destination folder if it doesn't exist +if [ ! -d "$destination_folder" ]; then + mkdir "$destination_folder" +fi + +# Clone the repository (if not already cloned) +if [ ! -d "$destination_folder/repository" ]; then + git clone "$repository_url" "$destination_folder/repository" +fi + +cd "$destination_folder/repository" + +echo "Updating models" +cp hugging_face/models.yaml ../../personal_data/bindings_zoo/hugging_face/models.yaml +cp c_transformers/models.yaml ../../personal_data/bindings_zoo/c_transformers/models.yaml +cp llama_cpp_official/models.yaml ../../personal_data/bindings_zoo/llama_cpp_official/models.yaml +cp gpt_4all/models.yaml ../../personal_data/bindings_zoo/gpt_4all/models.yaml +cp py_llama_cpp/models.yaml ../../personal_data/bindings_zoo/py_llama_cpp/models.yaml +cp gptq/models.yaml ../../personal_data/bindings_zoo/gptq/models.yaml +cp exllama/models.yaml ../../personal_data/bindings_zoo/exllama/models.yaml +echo "Updating models" diff --git a/scripts/linux/uninstall.sh b/scripts/linux/uninstall.sh new file mode 100644 index 0000000..2e5ef00 --- /dev/null +++ b/scripts/linux/uninstall.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +echo "This will uninstall the environment. Are you sure? [Y/N]" +read choice +if [[ "$choice" =~ [yY] ]]; then + # Download Python installer + printf "Removing virtual environment..." + rm -rf env + echo "OK" + read -p "Press [Enter] to continue..." +else + echo "Please install Python and try again." + read -p "Press [Enter] to continue..." + exit 1 +fi diff --git a/scripts/macos/macos_conda_session.sh b/scripts/macos/macos_conda_session.sh new file mode 100644 index 0000000..c6f8e13 --- /dev/null +++ b/scripts/macos/macos_conda_session.sh @@ -0,0 +1,41 @@ +#!/bin/bash +echo "Starting LOLLMS Web UI..." +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo " By ParisNeo" + +cd "$(dirname "$0")" + +# Better isolation for virtual environment +CONDA_SHLVL="" +PYTHONNOUSERSITE=1 +PYTHONPATH="" +PYTHONHOME="" +TEMP="./installer_files/temp" +TMP="./installer_files/temp" +ENV_NAME="lollms" +INSTALL_ENV_DIR="./installer_files/miniconda3/envs/lollms" +MINICONDA_DIR="./installer_files/miniconda3" + +if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then + echo "Miniconda not found." + exit 1 +fi + +source "$MINICONDA_DIR/bin/activate" "$ENV_NAME" +cd lollms + +# Set default CUDA toolkit to the one in the environment +CUDA_PATH="$INSTALL_ENV_DIR" + + +read -rp "Conda environment activated" diff --git a/scripts/macos/macos_install.sh b/scripts/macos/macos_install.sh new file mode 100644 index 0000000..f700288 --- /dev/null +++ b/scripts/macos/macos_install.sh @@ -0,0 +1,188 @@ +#!/bin/bash + +# This script will install Miniconda and git with all dependencies for this project. +# This enables a user to install this project without manually installing Conda and git. + +cd "$(dirname "$0")" + +if [[ "$PWD" == *" "* ]]; then + echo "This script relies on Miniconda, which cannot be silently installed under a path with spaces." + exit 1 +fi + +echo "WARNING: This script relies on Miniconda, which will fail to install if the path is too long." + +if [[ "$PWD" =~ [^#\$\%\&\(\)\*\+\] ]]; then + echo "WARNING: Special characters were detected in the installation path!" + echo " This can cause the installation to fail!" +fi + +read -rp "Press Enter to continue..." + +clear + +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo " By ParisNeo" + +echo "Please specify if you want to use a GPU or CPU." +echo "*Note* that only NVidea GPUs (cuda) or AMD GPUs (rocm) are supported." +echo "A) Enable GPU" +echo "B) Run CPU mode" +echo +read -rp "Input> " gpuchoice +gpuchoice="${gpuchoice:0:1}" +uppercase_gpuchoice=$(echo "$gpuchoice" | tr '[:lower:]' '[:upper:]') +if [[ "$uppercase_gpuchoice" == "A" ]]; then + PACKAGES_TO_INSTALL="python=3.10 cuda-toolkit ninja git" + CHANNEL="-c pytorch -c conda-forge" +elif [[ "$uppercase_gpuchoice" == "B" ]]; then + PACKAGES_TO_INSTALL="python=3.10 ninja git" + CHANNEL="-c conda-forge" +else + echo "Invalid choice. Exiting..." + exit 1 +fi + +echo "Installing gcc..." +brew install gcc + +# Better isolation for virtual environment +unset CONDA_SHLVL +export PYTHONNOUSERSITE=1 +unset PYTHONPATH +unset PYTHONHOME +export TEMP="$PWD/installer_files/temp" +export TMP="$PWD/installer_files/temp" + +MINICONDA_DIR="$PWD/installer_files/miniconda3" +INSTALL_ENV_DIR="$PWD/installer_files/lollms_env" +ENV_NAME="lollms" +MINICONDA_DOWNLOAD_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" +REPO_URL="https://github.com/ParisNeo/lollms.git" + +if [ ! -f "$MINICONDA_DIR/Scripts/conda" ]; then + # Download Miniconda + echo "Downloading Miniconda installer from $MINICONDA_DOWNLOAD_URL" + curl -LOk "$MINICONDA_DOWNLOAD_URL" + + # Install Miniconda + echo + echo "Installing Miniconda to $MINICONDA_DIR" + echo "Please wait..." + echo + bash "Miniconda3-latest-MacOSX-x86_64.sh" -b -p "$MINICONDA_DIR" || ( echo && echo "Miniconda installer not found." && exit 1 ) + rm -f "Miniconda3-latest-MacOSX-x86_64.sh" + if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then + echo && echo "Miniconda install failed." && exit 1 + fi +fi + +# Activate Miniconda +source "$MINICONDA_DIR/bin/activate" || ( echo "Miniconda hook not found." && exit 1 ) + +# Create the installer environment +if [ ! -d "$INSTALL_ENV_DIR" ]; then + echo "Packages to install: $PACKAGES_TO_INSTALL" + conda create -y -k -n "$ENV_NAME" $CHANNEL $PACKAGES_TO_INSTALL || ( echo && echo "Conda environment creation failed." && exit 1 ) + echo "Conda created and using packages: $PACKAGES_TO_INSTALL" + echo "Installing tools" + if [[ "$(echo $gpuchoice | tr '[:lower:]' '[:upper:]')" == "A" ]]; then + conda run --live-stream -n "$ENV_NAME" python -m pip install torch torchvision torchaudio --channel pytorch --channel conda-forge || ( echo && echo "Pytorch installation failed." && exit 1 ) + elif [[ "$(echo $gpuchoice | tr '[:lower:]' '[:upper:]')" == "B" ]]; then + conda run --live-stream -n "$ENV_NAME" python -m pip install torch torchvision torchaudio --channel pytorch --channel conda-forge || ( echo && echo "Pytorch installation failed." && exit 1 ) + fi +fi + +# Activate installer environment +source activate "$ENV_NAME" || ( echo && echo "Conda environment activation failed." && exit 1 ) + +echo "$ENV_NAME Activated" +# Set default CUDA toolkit to the one in the environment +export CUDA_PATH="$INSTALL_ENV_DIR" + +# Clone the repository +if [ -d "lollms" ]; then + cd lollms || exit 1 + git pull +else + git clone "$REPO_URL" + cd lollms || exit 1 +fi + +# Initilize all submodules and set them to main branch +echo "Initializing submodules" +git submodule update --init +cd zoos/bindings_zoo +git checkout main +cd ../personalities_zoo +git checkout main +cd ../extensions_zoo +git checkout main +cd ../models_zoo +git checkout main + +cd ../.. + +# Loop through each "git+" requirement and uninstall it (workaround for inconsistent git package updating) +while IFS= read -r requirement; do + if echo "$requirement" | grep -q "git+"; then + package_name=$(echo "$requirement" | awk -F'/' '{ print $4 }' | awk -F'@' '{ print $1 }') + python -m pip uninstall -y "$package_name" + fi +done < requirements.txt + +# Install the pip requirements +python -m pip install -r requirements.txt --upgrade + +python -m pip install -e lollms_core --upgrade + +python -m pip install -e utilities/safe_store --upgrade + +if [[ -e "../macos_lollms_server.sh" ]]; then + echo "Macos run found" +else + cp scripts/macos/macos_lollms_server.sh ../ +fi + +if [[ -e "../macos_lollms_settings.sh" ]]; then + echo "Macos run found" +else + cp scripts/macos/macos_lollms_settings.sh ../ +fi + +if [[ -e "../macos_update.sh" ]]; then + echo "Macos update found" +else + cp scripts/macos/macos_update.sh ../ +fi + +uppercase_gpuchoice=$(echo "$gpuchoice" | tr '[:lower:]' '[:upper:]') +if [[ "$uppercase_gpuchoice" == "B" ]]; then + echo "This is a .no_gpu file." > .no_gpu +else + echo "GPU is enabled, no .no_gpu file will be created." +fi + +PrintBigMessage() { + echo + echo "*******************************************************************" + for message in "$@"; do + echo "* $message" + done + echo "*******************************************************************" + echo +} + +PrintBigMessage "$@" + +exit 0 diff --git a/scripts/macos/macos_lollms_server.sh b/scripts/macos/macos_lollms_server.sh new file mode 100644 index 0000000..366c477 --- /dev/null +++ b/scripts/macos/macos_lollms_server.sh @@ -0,0 +1,48 @@ +#!/bin/bash +echo "Starting LOLLMS Web UI..." +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo " By ParisNeo" + +cd "$(dirname "$0")" + +# Better isolation for virtual environment +CONDA_SHLVL="" +PYTHONNOUSERSITE=1 +PYTHONPATH="" +PYTHONHOME="" +TEMP="./installer_files/temp" +TMP="./installer_files/temp" +ENV_NAME="lollms" +INSTALL_ENV_DIR="./installer_files/miniconda3/envs/lollms" +MINICONDA_DIR="./installer_files/miniconda3" + +if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then + echo "Miniconda not found." + exit 1 +fi + +source "$MINICONDA_DIR/bin/activate" "$ENV_NAME" +cd lollms + +# Set default CUDA toolkit to the one in the environment +CUDA_PATH="$INSTALL_ENV_DIR" + +# Launch the LOLLMS Web UI application +lollms-server "$@" + +# Pause at the end to keep the terminal window open +read -rp "Press Enter to exit..." + + + + diff --git a/scripts/macos/macos_lollms_settings.sh b/scripts/macos/macos_lollms_settings.sh new file mode 100644 index 0000000..9061a9a --- /dev/null +++ b/scripts/macos/macos_lollms_settings.sh @@ -0,0 +1,48 @@ +#!/bin/bash +echo "Starting LOLLMS Web UI..." +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo " By ParisNeo" + +cd "$(dirname "$0")" + +# Better isolation for virtual environment +CONDA_SHLVL="" +PYTHONNOUSERSITE=1 +PYTHONPATH="" +PYTHONHOME="" +TEMP="./installer_files/temp" +TMP="./installer_files/temp" +ENV_NAME="lollms" +INSTALL_ENV_DIR="./installer_files/miniconda3/envs/lollms" +MINICONDA_DIR="./installer_files/miniconda3" + +if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then + echo "Miniconda not found." + exit 1 +fi + +source "$MINICONDA_DIR/bin/activate" "$ENV_NAME" +cd lollms + +# Set default CUDA toolkit to the one in the environment +CUDA_PATH="$INSTALL_ENV_DIR" + +# Launch the LOLLMS Web UI application +lollms-settings "$@" + +# Pause at the end to keep the terminal window open +read -rp "Press Enter to exit..." + + + + diff --git a/scripts/macos/macos_update.sh b/scripts/macos/macos_update.sh new file mode 100644 index 0000000..75487d3 --- /dev/null +++ b/scripts/macos/macos_update.sh @@ -0,0 +1,44 @@ +#!/bin/bash +echo "Starting LOLLMS Web UI..." +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo " By ParisNeo" + +cd "$(dirname "$0")" + +# Better isolation for virtual environment +CONDA_SHLVL="" +PYTHONNOUSERSITE=1 +PYTHONPATH="" +PYTHONHOME="" +TEMP="./installer_files/temp" +TMP="./installer_files/temp" +ENV_NAME="lollms" +INSTALL_ENV_DIR="./installer_files/miniconda3/envs/lollms" +MINICONDA_DIR="./installer_files/miniconda3" + +if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then + echo "Miniconda not found." + exit 1 +fi + +source "$MINICONDA_DIR/bin/activate" "$ENV_NAME" +cd lollms-webui + +echo "Pulling latest changes" +git pull + +echo "Reinstalling requirements" +pip install --upgrade -r requirements.txt + +# Pause at the end to keep the terminal window open +read -rp "Press Enter to exit..." diff --git a/scripts/utilities/text2csv.py b/scripts/utilities/text2csv.py new file mode 100644 index 0000000..6babf1a --- /dev/null +++ b/scripts/utilities/text2csv.py @@ -0,0 +1,48 @@ +import argparse +import csv + +# Define a function to split text into blocks +def split_text_into_blocks(text): + return text.split('\n') + +# Define the main function +def process_text_file(input_file, output_file=None): + # If output_file is not provided, generate a default output file name based on the input file name + output_file = output_file or input_file.split('.')[0] + '.csv' + + # Read the text from the input file + with open(input_file, 'r', encoding='utf-8') as input_file: + text_content = input_file.read() + + # Split the text into blocks + blocks = split_text_into_blocks(text_content) + + # Create a list of dictionaries with id and text for each block + data = [{'id': i, 'text': block} for i, block in enumerate(blocks)] + + # Write the data to a CSV file + with open(output_file, 'w', newline='', encoding='utf-8') as output_file: + fieldnames = ['id', 'text'] + writer = csv.DictWriter(output_file, fieldnames=fieldnames) + + # Write the header row + writer.writeheader() + + # Write the data rows + writer.writerows(data) + + print(f'CSV file "{output_file}" has been created.') + +# Check if the script is being run as a standalone program +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Split text from a file into blocks and create a CSV file.') + + # Add arguments for input and output file names + parser.add_argument('input_file', help='Input text file name') + parser.add_argument('-o', '--output_file', help='Output CSV file name') + + # Parse the command-line arguments + args = parser.parse_args() + + # Call the main processing function + process_text_file(args.input_file, args.output_file) diff --git a/scripts/windows/uninstall.bat b/scripts/windows/uninstall.bat new file mode 100644 index 0000000..3a387b7 --- /dev/null +++ b/scripts/windows/uninstall.bat @@ -0,0 +1,16 @@ +@echo off + +echo This will uninstall the environment. Are you sure? [Y/N] +set /p choice= +if /i "%choice%" equ "Y" ( + REM Download Python installer + echo -n + set /p="Removing virtual environment..." nul && call :PrintBigMessage "This script relies on Miniconda which can not be silently installed under a path with spaces." && goto end +call :PrintBigMessage "WARNING: This script relies on Miniconda which will fail to install if the path is too long." +set "SPCHARMESSAGE="WARNING: Special characters were detected in the installation path!" " This can cause the installation to fail!"" +echo "%CD%"| findstr /R /C:"[!#\$%&()\*+,;<=>?@\[\]\^`{|}~]" >nul && ( + call :PrintBigMessage %SPCHARMESSAGE% +) +set SPCHARMESSAGE= + +pause +cls + +md + +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo By ParisNeo + +:retry +echo Please specify if you want to use a GPU or CPU. +echo *Note* that only NVidea GPUs (cuda) or AMD GPUs (rocm) are supported. +echo A) Enable cuda GPU +echo B) Enable ROCm compatible GPU (AMD and other GPUs) +echo C) Run CPU mode +set /p "gpuchoice=Input> " +set gpuchoice=%gpuchoice:~0,1% + +if /I "%gpuchoice%" == "A" ( + set "PACKAGES_TO_INSTALL=python=3.10 cuda-toolkit ninja git" + set "CHANNEL=-c nvidia/label/cuda-11.8.0 -c nvidia -c conda-forge" +) else if /I "%gpuchoice%" == "B" ( + set "PACKAGES_TO_INSTALL=python=3.10 rocm-comgr rocm-smi ninja git" + set "CHANNEL=-c conda-forge" +) else if /I "%gpuchoice%" == "C" ( + set "PACKAGES_TO_INSTALL=python=3.10 m2w64-toolchain ninja git" + set "CHANNEL=-c conda-forge" +) else ( + echo Invalid choice. Retry + goto retry +) + +@rem better isolation for virtual environment +SET "CONDA_SHLVL=" +SET PYTHONNOUSERSITE=1 +SET "PYTHONPATH=" +SET "PYTHONHOME=" +SET "TEMP=%cd%\installer_files\temp" +SET "TMP=%cd%\installer_files\temp" + +set MINICONDA_DIR=%cd%\installer_files\miniconda3 +set INSTALL_ENV_DIR=%cd%\installer_files\lollms_env +set MINICONDA_DOWNLOAD_URL=https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe +set REPO_URL=https://github.com/ParisNeo/lollms.git + +if not exist "%MINICONDA_DIR%\Scripts\conda.exe" ( + @rem download miniconda + echo Downloading Miniconda installer from %MINICONDA_DOWNLOAD_URL% + call curl -LOk "%MINICONDA_DOWNLOAD_URL%" + + @rem install miniconda + echo. && echo Installing Miniconda To "%MINICONDA_DIR%" && echo Please Wait... && echo. + start "" /W /D "%cd%" "Miniconda3-latest-Windows-x86_64.exe" /InstallationType=JustMe /NoShortcuts=1 /AddToPath=0 /RegisterPython=0 /NoRegistry=1 /S /D=%MINICONDA_DIR% || ( echo. && echo Miniconda installer not found. && goto end ) + del /q "Miniconda3-latest-Windows-x86_64.exe" + if not exist "%MINICONDA_DIR%\Scripts\activate.bat" ( echo. && echo Miniconda install failed. && goto end ) +) + +@rem activate miniconda +call "%MINICONDA_DIR%\Scripts\activate.bat" || ( echo Miniconda hook not found. && goto end ) + +if /I "%gpuchoice%" == "B" ( + echo Installing ROCM AMD tools... + rem Set variables for the installer URL and output file + set "installerUrl=https://www.amd.com/en/developer/rocm-hub/eula/licenses.html?filename=AMD-Software-PRO-Edition-23.Q3-Win10-Win11-For-HIP.exe" + set "outputFile=AMD-Software-PRO-Edition-23.Q3-Win10-Win11-For-HIP.exe" + + rem Download the installer using curl (make sure you have curl installed) + curl -o "%outputFile%" "%installerUrl%" + + rem Install RocM tools + "%outputFile%" + + rem Clean up the downloaded installer + del "%outputFile%" + + echo Installation complete. +) + +@rem create the installer env +if not exist "%INSTALL_ENV_DIR%" ( + echo Packages to install: %PACKAGES_TO_INSTALL% + call conda create --no-shortcuts -y -k -p "%INSTALL_ENV_DIR%" %CHANNEL% %PACKAGES_TO_INSTALL% || ( echo. && echo Conda environment creation failed. && goto end ) + if /I "%gpuchoice%" == "A" call conda run --live-stream -p "%INSTALL_ENV_DIR%" python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118|| ( echo. && echo Pytorch installation failed.&& goto end ) + if /I "%gpuchoice%" == "B" call conda run --live-stream -p "%INSTALL_ENV_DIR%" python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.4.2|| ( echo. && echo Pytorch installation failed.&& goto end ) + if /I "%gpuchoice%" == "C" call conda run --live-stream -p "%INSTALL_ENV_DIR%" python -m pip install torch torchvision torchaudio|| ( echo. && echo Pytorch installation failed.&& goto end ) +) + +@rem check if conda environment was actually created +if not exist "%INSTALL_ENV_DIR%\python.exe" ( echo. && echo Conda environment is empty. && goto end ) + +@rem activate installer env +call conda activate "%INSTALL_ENV_DIR%" || ( echo. && echo Conda environment activation failed. && goto end ) + +@rem set default cuda toolkit to the one in the environment +set "CUDA_PATH=%INSTALL_ENV_DIR%" + +@rem clone the repository +if exist lollms\ ( + cd lollms + git pull +) else ( + git clone https://github.com/ParisNeo/lollms.git + cd lollms +) +git submodule update --init +cd zoos/bindings_zoo +git checkout main +cd ../personalities_zoo +git checkout main +cd ../extensions_zoo +git checkout main +cd ../models_zoo +git checkout main + +cd ../.. + +@rem Loop through each "git+" requirement and uninstall it workaround for inconsistent git package updating +for /F "delims=" %%a in (requirements.txt) do echo "%%a"| findstr /C:"git+" >nul&& for /F "tokens=4 delims=/" %%b in ("%%a") do for /F "delims=@" %%c in ("%%b") do python -m pip uninstall -y %%c + +@rem install the pip requirements +call python -m pip install -r requirements.txt --upgrade + +@rem install the pip requirements +call python -m pip install -e lollms_core --upgrade + +@rem install the pip requirements +call python -m pip install -e utilities/safe_store --upgrade + + +@rem create launcher +if exist ..\win_lollms_server.bat ( + echo Win server found +) else ( + copy scripts\windows\win_lollms_server.bat ..\ +) + +@rem create launcher +if exist ..\win_lollms_settings.bat ( + echo Win settings found +) else ( + copy scripts\windows\win_lollms_settings.bat ..\ +) + +if exist ..\win_update.bat ( + echo Win update found +) else ( + copy scripts\windows\win_update.bat ..\ +) + + +if exist ..\win_conda_session.bat ( + echo win conda session script found +) else ( + copy scripts\windows\win_conda_session.bat ..\ +) + +if exist ..\win_update_models.bat ( + echo Win update models found +) else ( + copy scripts\windows\win_update_models.bat ..\ +) + +setlocal enabledelayedexpansion + + +if /I "%gpuchoice%"=="C" ( + echo This is a .no_gpu file. > .no_gpu +) else ( + echo GPU is enabled, no .no_gpu file will be created. +) + +endlocal + +goto end + +:PrintBigMessage +echo. && echo. +echo ******************************************************************* +for %%M in (%*) do echo * %%~M +echo ******************************************************************* +echo. && echo. +exit /b + +:end +cd .. +echo Creating bin folder (needed for ctransformers) +IF EXIST "installer_files\lollms_env\bin" ( + echo Folder already existing +) ELSE ( + MKDIR "installer_files\lollms_env\bin" + echo Folder created successfully! +) + + +echo Installation complete. +pause diff --git a/scripts/windows/win_lollms_server.bat b/scripts/windows/win_lollms_server.bat new file mode 100644 index 0000000..f10b247 --- /dev/null +++ b/scripts/windows/win_lollms_server.bat @@ -0,0 +1,42 @@ +@echo off +@echo Starting LOLLMS Web UI... +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo "/:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo "\:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo By ParisNeo + +cd /D "%~dp0" + +@rem better isolation for virtual environment +SET "CONDA_SHLVL=" +SET PYTHONNOUSERSITE=1 +SET "PYTHONPATH=" +SET "PYTHONHOME=" +SET "TEMP=%cd%\installer_files\temp" +SET "TMP=%cd%\installer_files\temp" + +@rem workaround for broken Windows installs +set PATH=%PATH%;%SystemRoot%\system32 + +set INSTALL_ENV_DIR=%cd%\installer_files\lollms_env +set MINICONDA_DIR=%cd%\installer_files\miniconda3 + +if not exist "%MINICONDA_DIR%\Scripts\activate.bat" ( echo Miniconda not found. Please reinstall lollms using win_install.bat. && goto end ) +call "%MINICONDA_DIR%\Scripts\activate.bat" activate "%INSTALL_ENV_DIR%" +cd lollms + +@rem set default cuda toolkit to the one in the environment +set "CUDA_PATH=%INSTALL_ENV_DIR%" + +lollms-server %* + +:end +pause diff --git a/scripts/windows/win_lollms_settings.bat b/scripts/windows/win_lollms_settings.bat new file mode 100644 index 0000000..c92e33f --- /dev/null +++ b/scripts/windows/win_lollms_settings.bat @@ -0,0 +1,42 @@ +@echo off +@echo Starting LOLLMS Web UI... +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo "/:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo "\:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo By ParisNeo + +cd /D "%~dp0" + +@rem better isolation for virtual environment +SET "CONDA_SHLVL=" +SET PYTHONNOUSERSITE=1 +SET "PYTHONPATH=" +SET "PYTHONHOME=" +SET "TEMP=%cd%\installer_files\temp" +SET "TMP=%cd%\installer_files\temp" + +@rem workaround for broken Windows installs +set PATH=%PATH%;%SystemRoot%\system32 + +set INSTALL_ENV_DIR=%cd%\installer_files\lollms_env +set MINICONDA_DIR=%cd%\installer_files\miniconda3 + +if not exist "%MINICONDA_DIR%\Scripts\activate.bat" ( echo Miniconda not found. Please reinstall lollms using win_install.bat. && goto end ) +call "%MINICONDA_DIR%\Scripts\activate.bat" activate "%INSTALL_ENV_DIR%" +cd lollms + +@rem set default cuda toolkit to the one in the environment +set "CUDA_PATH=%INSTALL_ENV_DIR%" + +lollms-settings %* + +:end +pause diff --git a/scripts/windows/win_update.bat b/scripts/windows/win_update.bat new file mode 100644 index 0000000..2133b1a --- /dev/null +++ b/scripts/windows/win_update.bat @@ -0,0 +1,43 @@ +@echo off +@echo Starting LOLLMS Web UI... +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo "/:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo "\:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo By ParisNeo + +cd /D "%~dp0" + +@rem better isolation for virtual environment +SET "CONDA_SHLVL=" +SET PYTHONNOUSERSITE=1 +SET "PYTHONPATH=" +SET "PYTHONHOME=" +SET "TEMP=%cd%\installer_files\temp" +SET "TMP=%cd%\installer_files\temp" + +@rem workaround for broken Windows installs +set PATH=%PATH%;%SystemRoot%\system32 + +set INSTALL_ENV_DIR=%cd%\installer_files\lollms_env +set MINICONDA_DIR=%cd%\installer_files\miniconda3 + +if not exist "%MINICONDA_DIR%\Scripts\activate.bat" ( echo Miniconda not found. Please reinstall lollms using win_install.bat. && goto end ) +call "%MINICONDA_DIR%\Scripts\activate.bat" activate "%INSTALL_ENV_DIR%" +cd lollms + +echo Pulling latest changes +call git pull + +echo Reinstalling requirements +pip install --upgrade -r requirements.txt + +:end +pause diff --git a/scripts/windows/win_update_models.bat b/scripts/windows/win_update_models.bat new file mode 100644 index 0000000..7442986 --- /dev/null +++ b/scripts/windows/win_update_models.bat @@ -0,0 +1,73 @@ +@echo off +@echo Starting LOLLMS Web UI... +echo " ___ ___ ___ ___ ___ ___ " +echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ " +echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ " +echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ " +echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ " +echo "/:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ " +echo "\:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ " +echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ " +echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / " +echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / " +echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ " +echo By ParisNeo + +cd /D "%~dp0" + +@rem better isolation for virtual environment +SET "CONDA_SHLVL=" +SET PYTHONNOUSERSITE=1 +SET "PYTHONPATH=" +SET "PYTHONHOME=" +SET "TEMP=%cd%\installer_files\temp" +SET "TMP=%cd%\installer_files\temp" + +@rem workaround for broken Windows installs +set PATH=%PATH%;%SystemRoot%\system32 + +set INSTALL_ENV_DIR=%cd%\installer_files\lollms_env +set MINICONDA_DIR=%cd%\installer_files\miniconda3 + +if not exist "%MINICONDA_DIR%\Scripts\activate.bat" ( echo Miniconda not found. Please reinstall lollms using win_install.bat. && goto end ) +call "%MINICONDA_DIR%\Scripts\activate.bat" activate "%INSTALL_ENV_DIR%" +cd lollms-webui + +@rem set default cuda toolkit to the one in the environment +set "CUDA_PATH=%INSTALL_ENV_DIR%" + +@echo off +setlocal + +REM Set your repository URL and file path +set repository_url=https://github.com/ParisNeo/lollms_bindings_zoo.git + +REM Set the destination folder where the file will be downloaded +set destination_folder=downloaded_files + +REM Create the destination folder if it doesn't exist +if not exist "%destination_folder%" mkdir "%destination_folder%" + +REM Clone the repository (if not already cloned) +if not exist "%destination_folder%\repository" ( + git clone "%repository_url%" "%destination_folder%\repository" +) + +REM Change directory to the repository folder +cd "%destination_folder%\repository" + +REM Fetch the latest changes from the remote repository +cp hugging_face/models.yaml ../../personal_data/bindings_zoo/hugging_face/models.yaml +cp c_transformers/models.yaml ../../personal_data/bindings_zoo/c_transformers/models.yaml +cp llama_cpp_official/models.yaml ../../personal_data/bindings_zoo/llama_cpp_official/models.yaml +cp gpt_4all/models.yaml ../../personal_data/bindings_zoo/gpt_4all/models.yaml +cp py_llama_cpp/models.yaml ../../personal_data/bindings_zoo/py_llama_cpp/models.yaml +cp gptq/models.yaml ../../personal_data/bindings_zoo/gptq/models.yaml +cp exllama/models.yaml ../../personal_data/bindings_zoo/exllama/models.yaml + +echo removing temporary files +cd ../.. +rmdir /s /q "%destination_folder%" +echo done +:end +pause