Starting better version
(And not whatever hacky version I first though of)
This commit is contained in:
+25
-6
@@ -1,12 +1,31 @@
|
||||
# Installs yolo in the user's CMD directory ( change $CMD to desired file path )
|
||||
# Installs yolo in the user's home directory
|
||||
|
||||
TARGET_DIR=$CMD
|
||||
TARGET_DIR=~/yolo-ai-cmdbot
|
||||
TARGET_FULLPATH=$TARGET_DIR/yolo.py
|
||||
|
||||
mkdir -p $TARGET_DIR
|
||||
cp yolo.py $TARGET_DIR
|
||||
cp prompt.txt $TARGET_DIR/yolo_prompt.txt #changed this so it doesnt conflict with possible future prompts
|
||||
cp yolo.py prompt.txt $TARGET_DIR
|
||||
chmod +x $TARGET_FULLPATH
|
||||
|
||||
# Adds batch file to System32 so you can call it in powershell
|
||||
cp yolo.bat C:/Windows/System32
|
||||
#Linux/Mac
|
||||
|
||||
# Creates two aliases for use
|
||||
alias yolo=$TARGET_FULLPATH
|
||||
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
|
||||
|
||||
# Windows
|
||||
# Copy yolo.bat to System32 or :
|
||||
|
||||
# (This doesn't work, havent figured it out)
|
||||
|
||||
# Creates two aliases for use
|
||||
alias yolo=$TARGET_FULLPATH
|
||||
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
|
||||
@@ -1,3 +1,7 @@
|
||||
@echo off
|
||||
|
||||
REM Work around to not have to type in python.exe yolo.py every time.
|
||||
REM Put in C:/Windows/System32 to allow command to work anywhere
|
||||
|
||||
set /P "prompt=Enter Prompt: "
|
||||
python.exe C:\Users\kause\Downloads\Commands\yolo.py %prompt%
|
||||
python.exe ~/yolo-ai-cmdbot/yolo.py %prompt%
|
||||
|
||||
@@ -12,8 +12,6 @@ import subprocess
|
||||
from termcolor import colored
|
||||
from colorama import init
|
||||
|
||||
import dotenv
|
||||
|
||||
# Check if the user globally disabled the safety switch
|
||||
def get_yolo_safety_switch_config():
|
||||
|
||||
@@ -34,7 +32,7 @@ def get_full_prompt(user_prompt, shell):
|
||||
prompt_path = os.path.dirname(yolo_path)
|
||||
|
||||
## Load the prompt and prep it
|
||||
prompt_file = os.path.join(prompt_path, "yolo_prompt.txt")
|
||||
prompt_file = os.path.join(prompt_path, "prompt.txt")
|
||||
pre_prompt = open(prompt_file,"r").read()
|
||||
pre_prompt = pre_prompt.replace("{shell}", shell)
|
||||
pre_prompt = pre_prompt.replace("{os}", get_os_friendly_name())
|
||||
@@ -80,9 +78,10 @@ if __name__ == "__main__":
|
||||
ask_flag = False # safety switch -a command line argument
|
||||
yolo = "" # user's answer to safety switch (-a) question y/n
|
||||
|
||||
# Presumes the folder yolo.py is copied to has a .env
|
||||
dotenv.load_dotenv(".env")
|
||||
# Two options for the user to specify they openai api key
|
||||
home_path = os.path.expanduser("~")
|
||||
openai.api_key = os.getenv("OPENAI_API_KEY")
|
||||
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:
|
||||
@@ -154,4 +153,4 @@ if yolo == "Y" or yolo == "":
|
||||
subprocess.run([shell, "/c", res_command], shell=False)
|
||||
else:
|
||||
# Unix: /bin/bash /bin/zsh: uses -c both Ubuntu and macOS should work, others might not
|
||||
subprocess.run([shell, "-c", res_command], shell=False)
|
||||
subprocess.run([shell, "-c", res_command], shell=False)
|
||||
|
||||
Reference in New Issue
Block a user