From 9d6d01ad77d5e07dc557d71e02f131f0d9d667b6 Mon Sep 17 00:00:00 2001 From: Scott Schluer Date: Wed, 3 May 2023 21:29:47 -0700 Subject: [PATCH] Updated agent.py to utilize environment variables for all key binding references. Added a new configuration key for: SELF_FEEDBACK_KEY. --- .env.template | 2 ++ autogpt/agent/agent.py | 8 ++++---- autogpt/config/config.py | 1 + tests/unit/test_plugins.py | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.env.template b/.env.template index 33cabc967f4..8f687f53cdd 100644 --- a/.env.template +++ b/.env.template @@ -17,6 +17,8 @@ # AUTHORISE_COMMAND_KEY=y ## EXIT_KEY - Key to exit AUTO-GPT # EXIT_KEY=n +## SELF_FEEDBACK_KEY - Key to enable self-feedback +# SELF_FEEDBACK_KEY=s ## DISABLED_COMMAND_CATEGORIES - The list of categories of commands that are disabled. Each of the below are an option: ## autogpt.commands.analyze_code diff --git a/autogpt/agent/agent.py b/autogpt/agent/agent.py index e2c44792a99..5c599d6b12a 100644 --- a/autogpt/agent/agent.py +++ b/autogpt/agent/agent.py @@ -162,8 +162,8 @@ def start_interaction_loop(self): ) logger.info( - "Enter 'y' to authorise command, 'y -N' to run N continuous commands, 's' to run self-feedback commands or " - "'n' to exit program, or enter feedback for " + f"Enter '{cfg.authorise_key}' to authorise command, '{cfg.authorise_key} -N' to run N continuous commands, '{cfg.self_feedback_key}' to run self-feedback commands or " + f"'{cfg.exit_key}' to exit program, or enter feedback for " f"{self.ai_name}..." ) while True: @@ -176,7 +176,7 @@ def start_interaction_loop(self): if console_input.lower().strip() == cfg.authorise_key: user_input = "GENERATE NEXT COMMAND JSON" break - elif console_input.lower().strip() == "s": + elif console_input.lower().strip() == cfg.self_feedback_key: logger.typewriter_log( "-=-=-=-=-=-=-= THOUGHTS, REASONING, PLAN AND CRITICISM WILL NOW BE VERIFIED BY AGENT -=-=-=-=-=-=-=", Fore.GREEN, @@ -205,7 +205,7 @@ def start_interaction_loop(self): user_input = "GENERATE NEXT COMMAND JSON" except ValueError: logger.warn( - "Invalid input format. Please enter 'y -n' where n is" + f"Invalid input format. Please enter '{cfg.authorise_key} -n' where n is" " the number of continuous tasks." ) continue diff --git a/autogpt/config/config.py b/autogpt/config/config.py index 7ee0df8b953..a4164f206bc 100644 --- a/autogpt/config/config.py +++ b/autogpt/config/config.py @@ -30,6 +30,7 @@ def __init__(self) -> None: self.authorise_key = os.getenv("AUTHORISE_COMMAND_KEY", "y") self.exit_key = os.getenv("EXIT_KEY", "n") + self.self_feedback_key = os.getenv("SELF_FEEDBACK_KEY", "s") disabled_command_categories = os.getenv("DISABLED_COMMAND_CATEGORIES") if disabled_command_categories: diff --git a/tests/unit/test_plugins.py b/tests/unit/test_plugins.py index 08c9114c761..8d3fc8ed7b1 100644 --- a/tests/unit/test_plugins.py +++ b/tests/unit/test_plugins.py @@ -27,6 +27,7 @@ class MockConfig: plugins_allowlist = ["GoodPlugin"] authorise_key = "y" exit_key = "n" + self_feedback_key = "s" return MockConfig()