Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

Make y/n configurable (#3178)

Eddie Cohen5ce6da95fcd0
diff --git a/.env.template b/.env.template
index 3d2746c45c..4d65c0b5ac 100644
--- a/.env.template
+++ b/.env.template
@@ -13,6 +13,11 @@
## AI_SETTINGS_FILE - Specifies which AI Settings file to use (defaults to ai_settings.yaml)
# AI_SETTINGS_FILE=ai_settings.yaml
+## AUTHORISE COMMAND KEY - Key to authorise commands
+# AUTHORISE_COMMAND_KEY=y
+## EXIT_KEY - Key to exit AUTO-GPT
+# EXIT_KEY=n
+
################################################################################
### LLM PROVIDER
################################################################################
diff --git a/autogpt/agent/agent.py b/autogpt/agent/agent.py
index 9b48d540dc..fd6a7cb6e1 100644
--- a/autogpt/agent/agent.py
+++ b/autogpt/agent/agent.py
@@ -153,7 +153,7 @@ class Agent:
console_input = clean_input(
Fore.MAGENTA + "Input:" + Style.RESET_ALL
)
- if console_input.lower().strip() == "y":
+ if console_input.lower().strip() == cfg.authorise_key:
user_input = "GENERATE NEXT COMMAND JSON"
break
elif console_input.lower().strip() == "s":
@@ -171,7 +171,7 @@ class Agent:
Fore.YELLOW,
"",
)
- if self_feedback_resp[0].lower().strip() == "y":
+ if self_feedback_resp[0].lower().strip() == cfg.authorise_key:
user_input = "GENERATE NEXT COMMAND JSON"
else:
user_input = self_feedback_resp
@@ -179,7 +179,7 @@ class Agent:
elif console_input.lower().strip() == "":
print("Invalid input format.")
continue
- elif console_input.lower().startswith("y -"):
+ elif console_input.lower().startswith(f"{cfg.authorise_key} -"):
try:
self.next_action_count = abs(
int(console_input.split(" ")[1])
@@ -187,12 +187,12 @@ class Agent:
user_input = "GENERATE NEXT COMMAND JSON"
except ValueError:
print(
- "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
break
- elif console_input.lower() == "n":
+ elif console_input.lower() == cfg.exit_key:
user_input = "EXIT"
break
else:
diff --git a/autogpt/config/config.py b/autogpt/config/config.py
index c0afaeb158..67e735c9b6 100644
--- a/autogpt/config/config.py
+++ b/autogpt/config/config.py
@@ -28,6 +28,8 @@ class Config(metaclass=Singleton):
self.allow_downloads = False
self.skip_news = False
+ self.authorise_key = os.getenv("AUTHORISE_COMMAND_KEY", "y")
+ self.exit_key = os.getenv("EXIT_KEY", "n")
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")
diff --git a/autogpt/plugins.py b/autogpt/plugins.py
index 57045bb89d..d03f0037a8 100644
--- a/autogpt/plugins.py
+++ b/autogpt/plugins.py
@@ -262,6 +262,6 @@ def denylist_allowlist_check(plugin_name: str, cfg: Config) -> bool:
return True
ack = input(
f"WARNING: Plugin {plugin_name} found. But not in the"
- " allowlist... Load? (y/n): "
+ f" allowlist... Load? ({cfg.authorise_key}/{cfg.exit_key}): "
)
- return ack.lower() == "y"
+ return ack.lower() == cfg.authorise_key
diff --git a/autogpt/prompts/prompt.py b/autogpt/prompts/prompt.py
index c1240157e2..cbfcfca93d 100644
--- a/autogpt/prompts/prompt.py
+++ b/autogpt/prompts/prompt.py
@@ -108,9 +108,9 @@ Name: {config.ai_name}
Role: {config.ai_role}
Goals: {config.ai_goals}
API Budget: {"infinite" if config.api_budget <= 0 else f"${config.api_budget}"}
-Continue (y/n): """
+Continue ({CFG.authorise_key}/{CFG.exit_key}): """
)
- if should_continue.lower() == "n":
+ if should_continue.lower() == CFG.exit_key:
config = AIConfig()
if not config.ai_name:
diff --git a/autogpt/utils.py b/autogpt/utils.py
index 17be611aad..6efaceec0d 100644
--- a/autogpt/utils.py
+++ b/autogpt/utils.py
@@ -47,14 +47,14 @@ def clean_input(prompt: str = "", talk=False):
"sure",
"alright",
]:
- return "y"
+ return cfg.authorise_key
elif plugin_response.lower() in [
"no",
"nope",
"n",
"negative",
]:
- return "n"
+ return cfg.exit_key
return plugin_response
# ask for input, default when just pressing Enter is y
diff --git a/tests/unit/test_plugins.py b/tests/unit/test_plugins.py
index de1653e445..08c9114c76 100644
--- a/tests/unit/test_plugins.py
+++ b/tests/unit/test_plugins.py
@@ -25,6 +25,8 @@ def mock_config_denylist_allowlist_check():
plugins_denylist = ["BadPlugin"]
plugins_allowlist = ["GoodPlugin"]
+ authorise_key = "y"
+ exit_key = "n"
return MockConfig()