From c1567c22f5cf7f715b025293adc92acab1adabdd Mon Sep 17 00:00:00 2001 From: Luke <2609441+lc0rp@users.noreply.github.com> Date: Sun, 30 Jul 2023 14:51:50 -0400 Subject: [PATCH] Do not load disabled commands (faster exec & benchmark runs) (#5078) * Use modern material theme for docs * Do not load disabled commands * black . --------- Co-authored-by: lc0rp <2609411+lc0rp@users.noreply.github.com> --- agbenchmark/benchmarks.py | 12 +----------- autogpt/core/runner/cli_web_app/server/api.py | 14 ++------------ benchmarks.py | 12 +----------- 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/agbenchmark/benchmarks.py b/agbenchmark/benchmarks.py index b7fc8d3f..6a646f37 100644 --- a/agbenchmark/benchmarks.py +++ b/agbenchmark/benchmarks.py @@ -26,7 +26,7 @@ def bootstrap_agent(task, continuous_mode) -> Agent: config.continuous_mode = continuous_mode config.temperature = 0 config.plain_output = True - command_registry = get_command_registry(config) + command_registry = CommandRegistry.with_command_modules(COMMAND_CATEGORIES, config) config.memory_backend = "no_memory" config.workspace_path = Workspace.init_workspace_directory(config) config.file_logger_path = Workspace.build_file_logger_path(config.workspace_path) @@ -45,16 +45,6 @@ def bootstrap_agent(task, continuous_mode) -> Agent: ) -def get_command_registry(config: Config): - command_registry = CommandRegistry() - enabled_command_categories = [ - x for x in COMMAND_CATEGORIES if x not in config.disabled_command_categories - ] - for command_module in enabled_command_categories: - command_registry.import_command_module(command_module) - return command_registry - - if __name__ == "__main__": # The first argument is the script name itself, second is the task if len(sys.argv) != 2: diff --git a/autogpt/core/runner/cli_web_app/server/api.py b/autogpt/core/runner/cli_web_app/server/api.py index 2f19d624..7a5ae9a7 100644 --- a/autogpt/core/runner/cli_web_app/server/api.py +++ b/autogpt/core/runner/cli_web_app/server/api.py @@ -6,7 +6,7 @@ from colorama import Fore from autogpt.agents import Agent from autogpt.app.main import UserFeedback from autogpt.commands import COMMAND_CATEGORIES -from autogpt.config import AIConfig, Config, ConfigBuilder +from autogpt.config import AIConfig, ConfigBuilder from autogpt.logs import logger from autogpt.memory.vector import get_memory from autogpt.models.command_registry import CommandRegistry @@ -85,7 +85,7 @@ def bootstrap_agent(task, continuous_mode) -> Agent: config.continuous_mode = continuous_mode config.temperature = 0 config.plain_output = True - command_registry = get_command_registry(config) + command_registry = CommandRegistry.with_command_modules(COMMAND_CATEGORIES, config) config.memory_backend = "no_memory" config.workspace_path = Workspace.init_workspace_directory(config) config.file_logger_path = Workspace.build_file_logger_path(config.workspace_path) @@ -102,13 +102,3 @@ def bootstrap_agent(task, continuous_mode) -> Agent: config=config, triggering_prompt=DEFAULT_TRIGGERING_PROMPT, ) - - -def get_command_registry(config: Config): - command_registry = CommandRegistry() - enabled_command_categories = [ - x for x in COMMAND_CATEGORIES if x not in config.disabled_command_categories - ] - for command_module in enabled_command_categories: - command_registry.import_command_module(command_module) - return command_registry diff --git a/benchmarks.py b/benchmarks.py index 9cf93aca..62f89662 100644 --- a/benchmarks.py +++ b/benchmarks.py @@ -22,7 +22,7 @@ def bootstrap_agent(task): config.continuous_mode = False config.temperature = 0 config.plain_output = True - command_registry = get_command_registry(config) + command_registry = CommandRegistry.with_command_modules(COMMAND_CATEGORIES, config) config.memory_backend = "no_memory" config.workspace_path = Workspace.init_workspace_directory(config) config.file_logger_path = Workspace.build_file_logger_path(config.workspace_path) @@ -39,13 +39,3 @@ def bootstrap_agent(task): config=config, triggering_prompt=DEFAULT_TRIGGERING_PROMPT, ) - - -def get_command_registry(config: Config): - command_registry = CommandRegistry() - enabled_command_categories = [ - x for x in COMMAND_CATEGORIES if x not in config.disabled_command_categories - ] - for command_category in enabled_command_categories: - command_registry.import_commands(command_category) - return command_registry