Skip to content

Commit

Permalink
Allow users to Disable Commands via the .env (Significant-Gravitas#3667)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntindle authored May 4, 2023
1 parent d744280 commit d2a9e54
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 13 deletions.
17 changes: 17 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@
## EXIT_KEY - Key to exit AUTO-GPT
# EXIT_KEY=n

## DISABLED_COMMAND_CATEGORIES - The list of categories of commands that are disabled. Each of the below are an option:
## autogpt.commands.analyze_code
## autogpt.commands.audio_text
## autogpt.commands.execute_code
## autogpt.commands.file_operations
## autogpt.commands.git_operations
## autogpt.commands.google_search
## autogpt.commands.image_gen
## autogpt.commands.improve_code
## autogpt.commands.twitter
## autogpt.commands.web_selenium
## autogpt.commands.write_tests
## autogpt.app
## autogpt.commands.task_statuses
## For example, to disable coding related features, uncomment the next line
# DISABLED_COMMAND_CATEGORIES=autogpt.commands.analyze_code,autogpt.commands.execute_code,autogpt.commands.git_operations,autogpt.commands.improve_code,autogpt.commands.write_tests

################################################################################
### LLM PROVIDER
################################################################################
Expand Down
7 changes: 7 additions & 0 deletions autogpt/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ def __init__(self) -> None:

self.authorise_key = os.getenv("AUTHORISE_COMMAND_KEY", "y")
self.exit_key = os.getenv("EXIT_KEY", "n")

disabled_command_categories = os.getenv("DISABLED_COMMAND_CATEGORIES")
if disabled_command_categories:
self.disabled_command_categories = disabled_command_categories.split(",")
else:
self.disabled_command_categories = []

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")
Expand Down
40 changes: 27 additions & 13 deletions autogpt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,33 @@ def run_auto_gpt(
cfg.set_plugins(scan_plugins(cfg, cfg.debug_mode))
# Create a CommandRegistry instance and scan default folder
command_registry = CommandRegistry()
command_registry.import_commands("autogpt.commands.analyze_code")
command_registry.import_commands("autogpt.commands.audio_text")
command_registry.import_commands("autogpt.commands.execute_code")
command_registry.import_commands("autogpt.commands.file_operations")
command_registry.import_commands("autogpt.commands.git_operations")
command_registry.import_commands("autogpt.commands.google_search")
command_registry.import_commands("autogpt.commands.image_gen")
command_registry.import_commands("autogpt.commands.improve_code")
command_registry.import_commands("autogpt.commands.twitter")
command_registry.import_commands("autogpt.commands.web_selenium")
command_registry.import_commands("autogpt.commands.write_tests")
command_registry.import_commands("autogpt.app")
command_registry.import_commands("autogpt.commands.task_statuses")

command_categories = [
"autogpt.commands.analyze_code",
"autogpt.commands.audio_text",
"autogpt.commands.execute_code",
"autogpt.commands.file_operations",
"autogpt.commands.git_operations",
"autogpt.commands.google_search",
"autogpt.commands.image_gen",
"autogpt.commands.improve_code",
"autogpt.commands.twitter",
"autogpt.commands.web_selenium",
"autogpt.commands.write_tests",
"autogpt.app",
"autogpt.commands.task_statuses",
]
logger.debug(
f"The following command categories are disabled: {cfg.disabled_command_categories}"
)
command_categories = [
x for x in command_categories if x not in cfg.disabled_command_categories
]

logger.debug(f"The following command categories are enabled: {command_categories}")

for command_category in command_categories:
command_registry.import_commands(command_category)

ai_name = ""
ai_config = construct_main_ai_config()
Expand Down

0 comments on commit d2a9e54

Please sign in to comment.