Skip to content

Commit

Permalink
Merge pull request Significant-Gravitas#73 from 0xcha05/patch-1
Browse files Browse the repository at this point in the history
better arg parsing
  • Loading branch information
Torantulino authored Apr 3, 2023
2 parents 7649ca2 + c8149b0 commit df6c0f3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ python scripts/main.py
## 🗣️ Speech Mode
Use this to use TTS for Auto-GPT
```
python scripts/main.py speak-mode
python scripts/main.py --speak
```

## 💀 Continuous Mode ⚠️
Expand All @@ -107,7 +108,8 @@ Use at your own risk.

1. Run the `main.py` Python script in your terminal:
```
python scripts/main.py continuous-mode
python scripts/main.py --continuous
```
2. To exit the program, press Ctrl + C

Expand Down
34 changes: 19 additions & 15 deletions scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
from ai_config import AIConfig
import traceback
import yaml
import argparse

class Argument(Enum):
CONTINUOUS_MODE = "continuous-mode"
SPEAK_MODE = "speak-mode"

def print_to_console(
title,
Expand Down Expand Up @@ -251,21 +249,27 @@ def parse_arguments():
global cfg
cfg.set_continuous_mode(False)
cfg.set_speak_mode(False)
for arg in sys.argv[1:]:
if arg == Argument.CONTINUOUS_MODE.value:
print_to_console("Continuous Mode: ", Fore.RED, "ENABLED")
print_to_console(
"WARNING: ",
Fore.RED,
"Continuous mode is not recommended. It is potentially dangerous and may cause your AI to run forever or carry out actions you would not usually authorise. Use at your own risk.")
cfg.set_continuous_mode(True)
elif arg == Argument.SPEAK_MODE.value:
print_to_console("Speak Mode: ", Fore.GREEN, "ENABLED")
cfg.set_speak_mode(True)

parser = argparse.ArgumentParser(description='Process arguments.')
parser.add_argument('--continuous', action='store_true', help='Enable Continuous Mode')
parser.add_argument('--speak', action='store_true', help='Enable Speak Mode')
args = parser.parse_args()

if args.continuous:
print_to_console("Continuous Mode: ", Fore.RED, "ENABLED")
print_to_console(
"WARNING: ",
Fore.RED,
"Continuous mode is not recommended. It is potentially dangerous and may cause your AI to run forever or carry out actions you would not usually authorise. Use at your own risk.")
cfg.set_continuous_mode(True)

if args.speak:
print_to_console("Speak Mode: ", Fore.GREEN, "ENABLED")
cfg.set_speak_mode(True)




# TODO: Better argument parsing:
# TODO: fill in llm values here

cfg = Config()
Expand Down

0 comments on commit df6c0f3

Please sign in to comment.