mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-23 17:04:21 +01:00
Make y/n configurable (#3178)
Co-authored-by: Reinier van der Leer <github@pwuts.nl>
This commit is contained in:
@@ -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
|
||||
################################################################################
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -25,6 +25,8 @@ def mock_config_denylist_allowlist_check():
|
||||
|
||||
plugins_denylist = ["BadPlugin"]
|
||||
plugins_allowlist = ["GoodPlugin"]
|
||||
authorise_key = "y"
|
||||
exit_key = "n"
|
||||
|
||||
return MockConfig()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user