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.

Do not load disabled commands (faster exec & benchmark runs) (#5078)

Lukec1567c22f5cf
diff --git a/agbenchmark/benchmarks.py b/agbenchmark/benchmarks.py
index b7fc8d3f62..6a646f3704 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 2f19d62446..7a5ae9a74f 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 9cf93acaef..62f89662e5 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