lollms-webui/scripts/c_webui.bat

160 lines
5.1 KiB
Batchfile
Raw Normal View History

2023-06-25 17:22:16 +00:00
@echo off
2023-06-25 19:31:24 +00:00
set environment_path=%cd%/lollms-webui/env
2023-07-12 15:02:55 +00:00
echo \u001b[34m
2023-07-12 15:02:35 +00:00
echo " ___ ___ ___ ___ ___ ___ "
echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ "
echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ "
echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ "
echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ "
echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ "
echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ "
echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ "
echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / "
echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / "
echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ "
2023-07-12 15:02:55 +00:00
echo By ParisNeo
2023-06-22 18:16:46 +00:00
echo \u001b[0m
2023-06-25 12:13:32 +00:00
2023-06-25 17:22:16 +00:00
echo Testing internet connection
2023-06-25 12:13:32 +00:00
ping -n 1 google.com >nul
if %errorlevel% equ 0 (
echo Internet Connection working fine
2023-07-03 23:33:32 +00:00
2023-06-25 12:13:32 +00:00
REM Install Git
echo Checking for Git...
where git >nul 2>nul
if %errorlevel% equ 0 (
echo Git is installed
) else (
set /p choice=Git is not installed. Would you like to install Git? [Y/N]
if /i "%choice%"=="Y" (
echo Installing Git...
REM Replace the following two lines with appropriate Git installation commands for Windows
echo Please install Git and try again.
exit /b 1
)
)
REM Check if repository exists
if exist .git (
echo Pulling latest changes
git pull
2023-06-25 12:13:32 +00:00
) else (
if exist lollms-webui (
2023-06-25 18:25:47 +00:00
cd ./lollms-webui
2023-06-25 12:13:32 +00:00
) else (
echo Cloning repository...
git clone https://github.com/ParisNeo/lollms-webui.git ./lollms-webui
2023-06-25 18:25:47 +00:00
cd ./lollms-webui
echo Cloned successfully
2023-06-25 12:13:32 +00:00
)
)
2023-06-25 18:25:47 +00:00
2023-06-25 12:13:32 +00:00
echo Pulling latest version...
2023-06-22 18:16:46 +00:00
git pull
2023-06-25 12:13:32 +00:00
REM Install Conda
echo Checking for Conda...
where conda >nul 2>nul
if %errorlevel% equ 0 (
echo Conda is installed
) else (
2023-06-25 17:22:16 +00:00
set /p choice="Conda is not installed. Would you like to install Conda? [Y/N]:"
2023-06-25 12:13:32 +00:00
if /i "%choice%"=="Y" (
echo Installing Conda...
2023-06-25 17:22:16 +00:00
set "miniconda_installer_url=https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe"
set "miniconda_installer=miniconda_installer_filename.exe"
rem Download the Miniconda installer using curl.
curl -o "%miniconda_installer%" "%miniconda_installer_url%"
if exist "%miniconda_installer%" (
echo Miniconda installer downloaded successfully.
echo Installing Miniconda...
echo.
rem Run the Miniconda installer.
"%miniconda_installer%" /InstallationType=JustMe /AddToPath=yes /RegisterPython=0 /S /D="%USERPROFILE%\Miniconda"
if %errorlevel% equ 0 (
echo Miniconda has been installed successfully in "%USERPROFILE%\Miniconda".
) else (
echo Failed to install Miniconda.
)
rem Clean up the Miniconda installer file.
del "%miniconda_installer%"
rem Activate Miniconda.
call "%USERPROFILE%\Miniconda\Scripts\activate"
) else (
echo Failed to download the Miniconda installer.
exit /b 1
)
2023-06-25 12:13:32 +00:00
)
)
2023-06-25 17:22:16 +00:00
echo Deactivating any activated environment
conda deactivate
2023-06-25 20:56:06 +00:00
2023-06-25 22:05:34 +00:00
echo checking %environment_path% existance
2023-06-25 17:22:16 +00:00
rem Check the error level to determine if the file exists
2023-06-25 22:05:34 +00:00
if not exist "%environment_path%" (
2023-06-25 17:22:16 +00:00
REM Create a new Conda environment
echo Creating Conda environment...
conda create --prefix ./env python=3.10
conda activate ./env
pip install --upgrade pip setuptools wheel
conda install -c conda-forge cudatoolkit-dev
) else (
echo Environment already exists. Skipping environment creation.
conda activate ./env
)
2023-06-25 18:33:00 +00:00
2023-06-25 17:22:16 +00:00
echo Activating environment
2023-06-25 12:13:32 +00:00
conda activate ./env
echo Conda environment is created
REM Install the required packages
2023-06-25 17:22:16 +00:00
echo Installing requirements using pip...
2023-06-25 12:13:32 +00:00
pip install -r requirements.txt
if %errorlevel% neq 0 (
echo Failed to install required packages. Please check your internet connection and try again.
exit /b 1
)
2023-06-25 19:31:24 +00:00
echo Cleanup
2023-06-25 12:13:32 +00:00
REM Cleanup
if exist "./tmp" (
echo Cleaning tmp folder
2023-06-25 19:31:24 +00:00
rmdir /s /q "./tmp"
echo Done
2023-06-25 12:13:32 +00:00
)
2023-06-25 19:31:24 +00:00
echo Ready
echo launching app
2023-06-25 17:22:16 +00:00
REM Launch the Python application
2023-06-25 19:31:24 +00:00
python app.py %*
set app_result=%errorlevel%
pause >nul
exit /b 0
2023-06-25 17:22:16 +00:00
) else (
REM Go to webui folder
cd lollms-webui
REM Activate environment
conda activate ./env
2023-06-22 18:16:46 +00:00
2023-06-25 19:31:24 +00:00
echo launching app
2023-06-25 17:22:16 +00:00
REM Launch the Python application
2023-06-25 19:31:24 +00:00
python app.py %*
set app_result=%errorlevel%
pause >nul
exit /b 0
2023-06-22 18:16:46 +00:00
)
2023-06-25 19:31:24 +00:00