From 4ce547027abbbbd999ab04d3f17dc88f1489cc80 Mon Sep 17 00:00:00 2001 From: Arpit Pathak <119810812+Thepathakarpit@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:04:40 +0530 Subject: [PATCH 1/3] Create setup.bat Batch file to automate setup for Agent-zero on Windows --- setup.bat | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 setup.bat diff --git a/setup.bat b/setup.bat new file mode 100644 index 000000000..bc9ae2562 --- /dev/null +++ b/setup.bat @@ -0,0 +1,110 @@ +@echo off +REM Clear the screen for a fresh start +cls + +REM Display welcome message +echo ============================================= +echo Agent Zero Setup and Execution +echo ============================================= + +:: Check if Python is installed +python --version >nul 2>&1 +if %errorlevel% neq 0 ( + echo Python is not installed. Downloading Python... + curl -o python-installer.exe https://www.python.org/ftp/python/3.10.0/python-3.10.0-amd64.exe + start /wait python-installer.exe /quiet InstallAllUsers=1 PrependPath=1 + if %errorlevel% neq 0 ( + echo Python installation failed. Exiting. + exit /b 1 + ) +) + +:: Docker Installation + +docker --version >nul 2>&1 +IF %ERRORLEVEL% NEQ 0 ( + :: Define variables +set "DOCKER_INSTALLER_URL=https://desktop.docker.com/win/stable/Docker%20Desktop%20Installer.exe" +set "DOCKER_INSTALLER=DockerDesktopInstaller.exe" + +:: Function to check if Docker is installed +:check_docker_installed +where docker >nul 2>&1 +if %errorlevel%==0 ( + echo Docker is already installed. + goto end +) + +:: Download Docker Desktop Installer +echo Downloading Docker Desktop Installer... +curl -L -o "%DOCKER_INSTALLER%" "%DOCKER_INSTALLER_URL%" + +:: Check if download was successful +if errorlevel 1 ( + echo Failed to download Docker Desktop Installer. Exiting. + goto end +) + +:: Run the installer +echo Installing Docker Desktop... +start /wait "" "%DOCKER_INSTALLER%" install --quiet + +:: Cleanup +del "%DOCKER_INSTALLER%" +echo Docker installation complete! + +:end +echo Done! +) + + +REM Install required Python packages +echo Installing required Python packages... +pip install -r requirements.txt +IF %ERRORLEVEL% NEQ 0 ( + echo Failed to install Python packages. Please check your setup. + exit /b +) + +REM Navigate to bundle directory +echo Setting up bundle environment... +cd bundle + +REM Check for platform and run respective bundle script +IF "%OS%"=="Windows_NT" ( + echo Running Windows bundle script... + call windows_bundle.bat +) ELSE ( + echo Running MacOS bundle script... + sh macos_bundle.sh +) + +REM Return to main directory +cd.. + +REM Display success message for setup +echo Setup complete. + +REM Provide user options to run either CLI or UI mode +echo. +echo ============================================= +echo Choose an option to run Agent Zero: +echo 1. Run CLI +echo 2. Run UI +echo ============================================= +set /p option="Enter 1 or 2: " + +IF "%option%"=="1" ( + echo Running Agent Zero in CLI mode... + echo Configure API Keys by: Duplicating example.env, rename it to .env, and add your API keys and then run by running the setup.bat again or by python run_cli.py command. + python run_cli.py + exit /b +) ELSE IF "%option%"=="2" ( + echo Running Agent Zero in UI mode... + python run_ui.py + exit /b +) ELSE ( + echo Invalid option selected. Exiting... + exit /b +) + From 4a462de546970a49eded2862d7e62d93e45944d2 Mon Sep 17 00:00:00 2001 From: Arpit Pathak <119810812+Thepathakarpit@users.noreply.github.com> Date: Thu, 24 Oct 2024 22:57:14 +0530 Subject: [PATCH 2/3] Added virtual environment support --- setup.bat | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/setup.bat b/setup.bat index bc9ae2562..252373438 100644 --- a/setup.bat +++ b/setup.bat @@ -57,7 +57,20 @@ echo Docker installation complete! echo Done! ) - +REM Set up Python virtual environment +echo Creating Python virtual environment... +python -m venv .venv +IF %ERRORLEVEL% NEQ 0 ( + echo Failed to create virtual environment. Exiting... + exit /b +) +REM Activate Python virtual environment +echo Activating Python virtual environment... +call .venv\Scripts\activate +IF %ERRORLEVEL% NEQ 0 ( + echo Failed to activate virtual environment. Exiting... + exit /b +) REM Install required Python packages echo Installing required Python packages... pip install -r requirements.txt @@ -65,11 +78,9 @@ IF %ERRORLEVEL% NEQ 0 ( echo Failed to install Python packages. Please check your setup. exit /b ) - REM Navigate to bundle directory echo Setting up bundle environment... cd bundle - REM Check for platform and run respective bundle script IF "%OS%"=="Windows_NT" ( echo Running Windows bundle script... @@ -78,13 +89,10 @@ IF "%OS%"=="Windows_NT" ( echo Running MacOS bundle script... sh macos_bundle.sh ) - REM Return to main directory cd.. - REM Display success message for setup echo Setup complete. - REM Provide user options to run either CLI or UI mode echo. echo ============================================= @@ -93,7 +101,6 @@ echo 1. Run CLI echo 2. Run UI echo ============================================= set /p option="Enter 1 or 2: " - IF "%option%"=="1" ( echo Running Agent Zero in CLI mode... echo Configure API Keys by: Duplicating example.env, rename it to .env, and add your API keys and then run by running the setup.bat again or by python run_cli.py command. @@ -107,4 +114,3 @@ IF "%option%"=="1" ( echo Invalid option selected. Exiting... exit /b ) - From fb65ab5da348a0827c46a265ea020b902523fda3 Mon Sep 17 00:00:00 2001 From: Arpit Pathak <119810812+Thepathakarpit@users.noreply.github.com> Date: Thu, 24 Oct 2024 23:32:25 +0530 Subject: [PATCH 3/3] Fixed docker installation --- setup.bat | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/setup.bat b/setup.bat index 252373438..4f2498a03 100644 --- a/setup.bat +++ b/setup.bat @@ -20,42 +20,27 @@ if %errorlevel% neq 0 ( ) :: Docker Installation - -docker --version >nul 2>&1 -IF %ERRORLEVEL% NEQ 0 ( - :: Define variables -set "DOCKER_INSTALLER_URL=https://desktop.docker.com/win/stable/Docker%20Desktop%20Installer.exe" -set "DOCKER_INSTALLER=DockerDesktopInstaller.exe" - -:: Function to check if Docker is installed :check_docker_installed where docker >nul 2>&1 if %errorlevel%==0 ( echo Docker is already installed. goto end +) else ( + where choco >nul 2>&1 + if %errorlevel%==0 ( + echo Installing Docker using Chocolatey... + choco install docker-desktop -y + ) else ( + echo Installing Chocolatey... + @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" + echo Installing Docker using Chocolatey... + choco install docker-desktop -y + ) + echo Docker installed ) -:: Download Docker Desktop Installer -echo Downloading Docker Desktop Installer... -curl -L -o "%DOCKER_INSTALLER%" "%DOCKER_INSTALLER_URL%" - -:: Check if download was successful -if errorlevel 1 ( - echo Failed to download Docker Desktop Installer. Exiting. - goto end -) - -:: Run the installer -echo Installing Docker Desktop... -start /wait "" "%DOCKER_INSTALLER%" install --quiet - -:: Cleanup -del "%DOCKER_INSTALLER%" -echo Docker installation complete! - :end echo Done! -) REM Set up Python virtual environment echo Creating Python virtual environment... @@ -64,6 +49,7 @@ IF %ERRORLEVEL% NEQ 0 ( echo Failed to create virtual environment. Exiting... exit /b ) + REM Activate Python virtual environment echo Activating Python virtual environment... call .venv\Scripts\activate @@ -71,6 +57,7 @@ IF %ERRORLEVEL% NEQ 0 ( echo Failed to activate virtual environment. Exiting... exit /b ) + REM Install required Python packages echo Installing required Python packages... pip install -r requirements.txt @@ -78,6 +65,7 @@ IF %ERRORLEVEL% NEQ 0 ( echo Failed to install Python packages. Please check your setup. exit /b ) + REM Navigate to bundle directory echo Setting up bundle environment... cd bundle @@ -89,8 +77,10 @@ IF "%OS%"=="Windows_NT" ( echo Running MacOS bundle script... sh macos_bundle.sh ) + REM Return to main directory cd.. + REM Display success message for setup echo Setup complete. REM Provide user options to run either CLI or UI mode @@ -103,7 +93,7 @@ echo ============================================= set /p option="Enter 1 or 2: " IF "%option%"=="1" ( echo Running Agent Zero in CLI mode... - echo Configure API Keys by: Duplicating example.env, rename it to .env, and add your API keys and then run by running the setup.bat again or by python run_cli.py command. + echo Configure API Keys by: Duplicating example.env, renaming it to .env, and adding your API keys. Then run again by executing setup.bat or by using the command: python run_cli.py. python run_cli.py exit /b ) ELSE IF "%option%"=="2" (