Edit README, tidy comments
This commit is contained in:
@@ -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=<yourkey>`
|
||||
- You can either `export OPENAI_API_KEY=<yourkey>`, or have a `.env` file in the same directory as `yolo.py` with `OPENAI_API_KEY="<yourkey>"` as a line
|
||||
- Create a file at `~/.openai.apikey` with the key in it
|
||||
|
||||
# Using yolo
|
||||
|
||||
+14
-9
@@ -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%
|
||||
:: 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%
|
||||
)
|
||||
@@ -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 %*
|
||||
@@ -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="<yourkey>"
|
||||
# or do `export OPENAI_API_KEY=<yourkey>` 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:
|
||||
# <yourkey>
|
||||
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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user