diff --git a/.yolo-safety-off b/.yolo-safety-off deleted file mode 100644 index e69de29..0000000 diff --git a/README.md b/README.md index d23fdb5..9c4406a 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,11 @@ Another option is to run `source install.sh` after cloning the repo. That does t That's it. Now make sure you have an OpenAI API key set. +## Installation script (Windows) + +For windows you can run `.\install.bat` (or double-click) after cloning the repo. It will do the following: +1. Copies the necessary files to `~/yolo-ai-cmdbot/` +2. Creates a `yolo.bat` file in `~` that lets you run equivalent to `python.exe ~\yolo-ai-cmdbot\yolo.py` # macOS @@ -43,12 +48,18 @@ Windows is less tested, it does work though and will use PowerShell. `python.exe yolo.py what is my username` +If you use `install.bat` you should have a `yolo.bat` file in your `~` directory that lets you run the command like so: + +`.\yolo.bat what is my username` + +you can put the `yolo.bat` file into a $PATH directory (like `C:\Windows\System32`) to use in any directory + Have fun. # OpenAI API Key configuration There are two ways to configure the key: -- You can either `export OPENAI_API_KEY=` +- You can either `export OPENAI_API_KEY=`, or have a `.env` file in the same directory as `yolo.py` with `OPENAI_API_KEY=""` as a line - Create a file at `~/.openai.apikey` with the key in it # Using yolo diff --git a/install.bat b/install.bat index 23145e6..23d776c 100644 --- a/install.bat +++ b/install.bat @@ -1,20 +1,25 @@ @echo off :: Installs yolo in the user's home directory -::TARGET_DIR=~/yolo-ai-cmdbot -::TARGET_FULLPATH=$TARGET_DIR/yolo.py set TARGET_DIR= %HOME%yolo-ai-cmdbot set TARGET_FULLPATH= %TARGET_DIR%\yolo.py -::mkdir -p $TARGET_DIR -::cp yolo.py prompt.txt $TARGET_DIR -::chmod +x $TARGET_FULLPATH mkdir %TARGET_DIR% copy yolo.py %TARGET_DIR% copy prompt.txt %TARGET_DIR% -:: Windows: Copies .bat file to $HOME so it works similar to LINUX/MAC, avoiding having to type python.exe every time. -:: Note: Though that maybe making it an executable would make more sense but the +:: Windows: Creates a yolo.bat file into %HOME% directory which will let you run similar to Linux/MacOS +:: Example: Input: ".\yolo.bat print hello" to "yolo print hello" -::Copy to home directory -copy yolo.bat %HOME% \ No newline at end of file +:: yolo.bat can only be used in same directory; or, any directory if put in a $PATH directory (type $env:PATH in PowerShell and pick an appropriate path to paste in) +:: C:\Windows\System32 is the $PATH directory everyone is likely to have + +:: Create yolo.bat and if it isn't already there input its code. +find "@echo off" "%HOME%\yolo.bat" && ( + echo "yolo.bat" Already Exists +) || ( + copy /y nul %HOME% yolo.bat + echo @echo off>>"%HOME%yolo.bat" + echo python.exe %HOME%yolo-ai-cmdbot\yolo.py %%*>>"%HOME%\yolo.bat" + echo Created "yolo.bat" in %HOME% +) \ No newline at end of file diff --git a/install.sh b/install.sh index a019293..515666f 100644 --- a/install.sh +++ b/install.sh @@ -15,4 +15,4 @@ alias computer=$TARGET_FULLPATH # Add the aliases to the logon scripts echo "alias yolo=$TARGET_FULLPATH" >> ~/.bash_aliases -echo "alias computer=$TARGET_FULLPATH" >> ~/.bash_aliases +echo "alias computer=$TARGET_FULLPATH" >> ~/.bash_aliases \ No newline at end of file diff --git a/yolo.bat b/yolo.bat deleted file mode 100644 index d2cf92f..0000000 --- a/yolo.bat +++ /dev/null @@ -1,6 +0,0 @@ -@echo off - -REM Work around to not have to type in python.exe yolo.py every time. -REM Put in C:/Windows/System32 or another $PATH directory to allow command to work anywhere - -python.exe yolo-ai-cmdbot/yolo.py %* \ No newline at end of file diff --git a/yolo.py b/yolo.py index 360ae25..bc06396 100755 --- a/yolo.py +++ b/yolo.py @@ -12,7 +12,7 @@ import subprocess from termcolor import colored from colorama import init -import dotenv +import dotenv #Allow .env file to be used # Check if the user globally disabled the safety switch def get_yolo_safety_switch_config(): @@ -81,10 +81,15 @@ if __name__ == "__main__": yolo = "" # user's answer to safety switch (-a) question y/n - # Two options for the user to specify they openai api key. Windows: Comment out the one you are not using (Causes extra line to appear) + # Two options for the user to specify they openai api key. + #1. Place a ".env" file in same directory as this with the line: + # OPENAI_API_KEY="" + # or do `export OPENAI_API_KEY=` before use dotenv.load_dotenv() openai.api_key = os.getenv("OPENAI_API_KEY") - if not openai.api_key: + #2. Place a ".openai.apikey" in the home directory that holds the line: + # + if not openai.api_key: #If statement to avoid "invalid filepath" error home_path = os.path.expanduser("~") openai.api_key_path = os.path.join(home_path,".openai.apikey")