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.
Fix commands with same name overwriting (#4226)
k-boikovd06d8a609fd5
diff --git a/autogpt/commands/command.py b/autogpt/commands/command.pyindex 22ebace5a6..174a691c5f 100644--- a/autogpt/commands/command.py+++ b/autogpt/commands/command.py@@ -3,6 +3,8 @@ import importlibimport inspectfrom typing import Any, Callable, Optional+from autogpt.logs import logger+# Unique identifier for auto-gpt commandsAUTO_GPT_COMMAND_IDENTIFIER = "auto_gpt_command"@@ -59,6 +61,10 @@ class CommandRegistry:return importlib.reload(module)def register(self, cmd: Command) -> None:+ if cmd.name in self.commands:+ logger.warn(+ f"Command '{cmd.name}' already registered and will be overwritten!"+ )self.commands[cmd.name] = cmddef unregister(self, command_name: str):@@ -133,6 +139,11 @@ def command() -> Callable[..., Any]:"""The command decorator is used to create Command objects from ordinary functions."""+ if not enabled:+ if disabled_reason is not None:+ logger.debug(f"Command '{name}' is disabled: {disabled_reason}")+ return lambda func: func+def decorator(func: Callable[..., Any]) -> Command:cmd = Command(name=name,