Merge pull request #4 from KAuser2094/main
Windows Installer Script and 'executable' and minor fix to api_key code
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
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
@echo off
|
||||
:: Installs yolo in the user's home directory
|
||||
|
||||
set TARGET_DIR= %HOME%yolo-ai-cmdbot
|
||||
set TARGET_FULLPATH= %TARGET_DIR%\yolo.py
|
||||
|
||||
mkdir %TARGET_DIR%
|
||||
copy yolo.py %TARGET_DIR%
|
||||
copy prompt.txt %TARGET_DIR%
|
||||
|
||||
:: 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"
|
||||
|
||||
:: 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%
|
||||
)
|
||||
@@ -7,6 +7,8 @@ mkdir -p $TARGET_DIR
|
||||
cp yolo.py prompt.txt $TARGET_DIR
|
||||
chmod +x $TARGET_FULLPATH
|
||||
|
||||
#Linux/Mac
|
||||
|
||||
# Creates two aliases for use
|
||||
alias yolo=$TARGET_FULLPATH
|
||||
alias computer=$TARGET_FULLPATH
|
||||
|
||||
@@ -12,6 +12,8 @@ import subprocess
|
||||
from termcolor import colored
|
||||
from colorama import init
|
||||
|
||||
import dotenv #Allow .env file to be used
|
||||
|
||||
# Check if the user globally disabled the safety switch
|
||||
def get_yolo_safety_switch_config():
|
||||
|
||||
@@ -78,10 +80,18 @@ if __name__ == "__main__":
|
||||
ask_flag = False # safety switch -a command line argument
|
||||
yolo = "" # user's answer to safety switch (-a) question y/n
|
||||
|
||||
# Two options for the user to specify they openai api key
|
||||
home_path = os.path.expanduser("~")
|
||||
|
||||
# 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")
|
||||
openai.api_key_path = os.path.join(home_path,".openai.apikey")
|
||||
#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")
|
||||
|
||||
# Parse arguments and make sure we have at least a single word
|
||||
if len(sys.argv) < 2:
|
||||
|
||||
Reference in New Issue
Block a user