From 428caa9bef83e93a6f97a1341a03a0f41b71dec0 Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Thu, 13 Apr 2023 12:57:57 +0300 Subject: [PATCH 1/9] Added flags, and implemented skip-reprompt --- scripts/config.py | 1 + scripts/main.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/config.py b/scripts/config.py index ebf1b08b22f7..fd370a72bee3 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -37,6 +37,7 @@ def __init__(self): self.debug_mode = False self.continuous_mode = False self.speak_mode = False + self.skip_reprompt = False self.fast_llm_model = os.getenv("FAST_LLM_MODEL", "gpt-3.5-turbo") self.smart_llm_model = os.getenv("SMART_LLM_MODEL", "gpt-4") diff --git a/scripts/main.py b/scripts/main.py index 81f560b21664..f81b09a76aa5 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -183,7 +183,11 @@ def load_variables(config_file="config.yaml"): def construct_prompt(): """Construct the prompt for the AI to respond to""" config = AIConfig.load() - if config.ai_name: + if cfg.skip_reprompt and config.ai_name: + logger.typewriter_log("Name :", Fore.GREEN, config.ai_name) + logger.typewriter_log("Role :", Fore.GREEN, config.ai_role) + logger.typewriter_log("Goals:", Fore.GREEN, config.ai_goals) + elif config.ai_name: logger.typewriter_log( f"Welcome back! ", Fore.GREEN, @@ -270,12 +274,14 @@ def parse_arguments(): cfg.set_speak_mode(False) parser = argparse.ArgumentParser(description='Process arguments.') - parser.add_argument('--continuous', action='store_true', help='Enable Continuous Mode') + parser.add_argument('--continuous', '-c', action='store_true', help='Enable Continuous Mode') parser.add_argument('--speak', action='store_true', help='Enable Speak Mode') parser.add_argument('--debug', action='store_true', help='Enable Debug Mode') parser.add_argument('--gpt3only', action='store_true', help='Enable GPT3.5 Only Mode') parser.add_argument('--gpt4only', action='store_true', help='Enable GPT4 Only Mode') parser.add_argument('--use-memory', '-m', dest="memory_type", help='Defines which Memory backend to use') + parser.add_argument('--skip-reprompt', '-y', dest='skip_reprompt', action='store_true', help='Skips the re-prompting messages at the beginning of the script') + parser.add_argument('--ai-settings', '-C', dest='ai_settings_file', help="Specifies which ai_settings.yaml file to use, will also automatically skip the re-prompt.") args = parser.parse_args() if args.debug: @@ -315,6 +321,10 @@ def parse_arguments(): else: cfg.memory_backend = chosen + if args.skip_reprompt: + logger.typewriter_log("Skip Re-prompt: ", Fore.GREEN, "ENABLED") + cfg.skip_reprompt = True + # TODO: fill in llm values here check_openai_api_key() From 0f6fba7d65302591f2c77a41483953df43d12d2b Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Thu, 13 Apr 2023 14:02:42 +0300 Subject: [PATCH 2/9] Implemented the '--ai-settings' flag --- scripts/config.py | 1 + scripts/main.py | 16 +++++++++++++++- scripts/utils.py | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/scripts/config.py b/scripts/config.py index fd370a72bee3..ad968fb24728 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -39,6 +39,7 @@ def __init__(self): self.speak_mode = False self.skip_reprompt = False + self.ai_settings_file = os.getenv("AI_SETTINGS_FILE", "ai_settings.yaml") self.fast_llm_model = os.getenv("FAST_LLM_MODEL", "gpt-3.5-turbo") self.smart_llm_model = os.getenv("SMART_LLM_MODEL", "gpt-4") self.fast_token_limit = int(os.getenv("FAST_TOKEN_LIMIT", 4000)) diff --git a/scripts/main.py b/scripts/main.py index f81b09a76aa5..07d2bbd2922f 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -182,7 +182,7 @@ def load_variables(config_file="config.yaml"): def construct_prompt(): """Construct the prompt for the AI to respond to""" - config = AIConfig.load() + config = AIConfig.load(cfg.ai_settings_file) if cfg.skip_reprompt and config.ai_name: logger.typewriter_log("Name :", Fore.GREEN, config.ai_name) logger.typewriter_log("Role :", Fore.GREEN, config.ai_role) @@ -324,7 +324,21 @@ def parse_arguments(): if args.skip_reprompt: logger.typewriter_log("Skip Re-prompt: ", Fore.GREEN, "ENABLED") cfg.skip_reprompt = True + + if args.ai_settings_file: + file = args.ai_settings_file + + # Validate file + (validated, message) = utils.validate_yaml_file(file) + if not validated: + logger.typewriter_log("FAILED FILE VALIDATION", Fore.RED, message) + exit(1) + logger.typewriter_log("Using AI Settings File:", Fore.GREEN, file) + cfg.ai_settings_file = file + cfg.skip_reprompt = True + + # TODO: fill in llm values here check_openai_api_key() diff --git a/scripts/utils.py b/scripts/utils.py index 5039796fbd18..bca8d4a89811 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -1,3 +1,6 @@ +import yaml +from colorama import Fore + def clean_input(prompt: str=''): try: return input(prompt) @@ -6,3 +9,14 @@ def clean_input(prompt: str=''): print("Quitting...") exit(0) + +def validate_yaml_file(file: str): + try: + with open(file) as file: + yaml.load(file, Loader=yaml.FullLoader) + except FileNotFoundError: + return (False, f"The file {Fore.CYAN}`{file}`{Fore.RESET} wasn't found") + except yaml.YAMLError as e: + return (False, f"There was an issue while trying to read with your AI Settings file: {e}") + + return (True, f"Successfully validated {Fore.CYAN}`{file}`{Fore.RESET}!") \ No newline at end of file From a10ffc1dbed88ce74f7ebb1dae0c90fb18bae9f6 Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Thu, 13 Apr 2023 14:26:16 +0300 Subject: [PATCH 3/9] Fixed error logging when choosing non-supported memory backend with '--use-memory' --- scripts/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/main.py b/scripts/main.py index 07d2bbd2922f..59cb565e9554 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -316,8 +316,8 @@ def parse_arguments(): supported_memory = get_supported_memory_backends() chosen = args.memory_type if not chosen in supported_memory: - print_to_console("ONLY THE FOLLOWING MEMORY BACKENDS ARE SUPPORTED: ", Fore.RED, f'{supported_memory}') - print_to_console(f"Defaulting to: ", Fore.YELLOW, cfg.memory_backend) + logger.typewriter_log("ONLY THE FOLLOWING MEMORY BACKENDS ARE SUPPORTED: ", Fore.RED, f'{supported_memory}') + logger.typewriter_log(f"Defaulting to: ", Fore.YELLOW, cfg.memory_backend) else: cfg.memory_backend = chosen From ff094c7ecc58fad572dccbc8a376a75045d91733 Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Thu, 13 Apr 2023 15:09:24 +0300 Subject: [PATCH 4/9] Resolve Linter Issues --- scripts/main.py | 5 ++--- scripts/utils.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/main.py b/scripts/main.py index 59cb565e9554..0674db47b610 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -327,19 +327,18 @@ def parse_arguments(): if args.ai_settings_file: file = args.ai_settings_file - + # Validate file (validated, message) = utils.validate_yaml_file(file) if not validated: logger.typewriter_log("FAILED FILE VALIDATION", Fore.RED, message) exit(1) - + logger.typewriter_log("Using AI Settings File:", Fore.GREEN, file) cfg.ai_settings_file = file cfg.skip_reprompt = True - # TODO: fill in llm values here check_openai_api_key() parse_arguments() diff --git a/scripts/utils.py b/scripts/utils.py index bca8d4a89811..2b51c1fce34f 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -18,5 +18,5 @@ def validate_yaml_file(file: str): return (False, f"The file {Fore.CYAN}`{file}`{Fore.RESET} wasn't found") except yaml.YAMLError as e: return (False, f"There was an issue while trying to read with your AI Settings file: {e}") - - return (True, f"Successfully validated {Fore.CYAN}`{file}`{Fore.RESET}!") \ No newline at end of file + + return (True, f"Successfully validated {Fore.CYAN}`{file}`{Fore.RESET}!") From 47b72df262b894752b7fd0324f42f71ffc70e38c Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Fri, 14 Apr 2023 01:20:43 +0300 Subject: [PATCH 5/9] Added 'AI_SETTINGS_FILE' to .env --- .env.template | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.env.template b/.env.template index 474b2727619e..c5cb54fdd249 100644 --- a/.env.template +++ b/.env.template @@ -3,6 +3,8 @@ ################################################################################ # EXECUTE_LOCAL_COMMANDS - Allow local command execution (Example: False) EXECUTE_LOCAL_COMMANDS=False +# AI_SETTINGS_FILE - Specifies which AI Settings file to use (defaults to ai_settings.yaml) +AI_SETTINGS_FILE=ai_settings.yaml ################################################################################ ### LLM PROVIDER From 05f6e9673f285ac40cf982a544dfa14750cf6af1 Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Fri, 14 Apr 2023 01:23:23 +0300 Subject: [PATCH 6/9] Resolve Linter Issues --- scripts/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/utils.py b/scripts/utils.py index 2b51c1fce34f..7521df298e39 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -1,6 +1,7 @@ import yaml from colorama import Fore + def clean_input(prompt: str=''): try: return input(prompt) From 8472bbd4556999cdd62e4930ae3723f18b746ef4 Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Fri, 14 Apr 2023 01:34:30 +0300 Subject: [PATCH 7/9] Added 'Command Line Arguments' section to README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index d11219769ce3..8d402e7d6900 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,14 @@ To output debug logs: ``` python scripts/main.py --debug ``` +### Command Line Arguments +Here are some common arguments you can use when running Auto-GPT: +> Replace anything in angled brackets (<>) to a value you want to specify +* `python scripts/main.py --help` to see a list of all available command line arguments +* `python scripts/main.py --ai-settings ` to run Auto-GPT with a different AI Settings file. +* `python scripts/main.py --use-memory ` to specify one of 3 memory backends: `local`, `redis` or `pinecone` + +> **NOTE**: There are shorthands for some of these flags, for example `-m` for `--use-memory`. Use `python scripts/main.py --help` for more information ## 🗣️ Speech Mode From 6702a04f767702d1e57ddcec81f2481def19f8a7 Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Fri, 14 Apr 2023 01:50:13 +0300 Subject: [PATCH 8/9] Add 'no_memory' support for memory flag --- scripts/memory/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/memory/__init__.py b/scripts/memory/__init__.py index a0afc874e2d6..9b53d8d29abe 100644 --- a/scripts/memory/__init__.py +++ b/scripts/memory/__init__.py @@ -3,7 +3,7 @@ # List of supported memory backends # Add a backend to this list if the import attempt is successful -supported_memory = ['local'] +supported_memory = ['local', 'no_memory'] try: from memory.redismem import RedisMemory From 4f923ece60baee2c086c29610a05c4f130e43aa9 Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Fri, 14 Apr 2023 01:56:45 +0300 Subject: [PATCH 9/9] Added double_check logging to AI Settings validator, and updated README for 'no_memory' --- README.md | 4 ++-- scripts/main.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d402e7d6900..b55a80c56243 100644 --- a/README.md +++ b/README.md @@ -137,9 +137,9 @@ python scripts/main.py --debug ### Command Line Arguments Here are some common arguments you can use when running Auto-GPT: > Replace anything in angled brackets (<>) to a value you want to specify -* `python scripts/main.py --help` to see a list of all available command line arguments +* `python scripts/main.py --help` to see a list of all available command line arguments. * `python scripts/main.py --ai-settings ` to run Auto-GPT with a different AI Settings file. -* `python scripts/main.py --use-memory ` to specify one of 3 memory backends: `local`, `redis` or `pinecone` +* `python scripts/main.py --use-memory ` to specify one of 3 memory backends: `local`, `redis`, `pinecone` or 'no_memory'. > **NOTE**: There are shorthands for some of these flags, for example `-m` for `--use-memory`. Use `python scripts/main.py --help` for more information diff --git a/scripts/main.py b/scripts/main.py index 400eb1f63800..78ffe2430a01 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -348,6 +348,7 @@ def parse_arguments(): (validated, message) = utils.validate_yaml_file(file) if not validated: logger.typewriter_log("FAILED FILE VALIDATION", Fore.RED, message) + logger.double_check() exit(1) logger.typewriter_log("Using AI Settings File:", Fore.GREEN, file)