diff options
author | Reinier van der Leer <pwuts@agpt.co> | 2024-03-20 17:24:11 +0100 |
---|---|---|
committer | Reinier van der Leer <pwuts@agpt.co> | 2024-03-20 17:24:11 +0100 |
commit | 1262b72f5cab890907db00df9b4752d31d123f12 (patch) | |
tree | 86b90ab247a059ef831566be49eb06f5990c1f4d | |
parent | test(agent): Add skip statements to test_execute_code.py for when Docker is n... (diff) | |
download | Auto-GPT-1262b72f5cab890907db00df9b4752d31d123f12.tar.gz Auto-GPT-1262b72f5cab890907db00df9b4752d31d123f12.tar.bz2 Auto-GPT-1262b72f5cab890907db00df9b4752d31d123f12.zip |
feat(agent): Allow boolean values for `available` param on `@command`
-rw-r--r-- | autogpts/autogpt/autogpt/command_decorator.py | 2 | ||||
-rw-r--r-- | autogpts/autogpt/autogpt/models/command.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/autogpts/autogpt/autogpt/command_decorator.py b/autogpts/autogpt/autogpt/command_decorator.py index 70a519a42..f53c1ad85 100644 --- a/autogpts/autogpt/autogpt/command_decorator.py +++ b/autogpts/autogpt/autogpt/command_decorator.py @@ -25,7 +25,7 @@ def command( enabled: Literal[True] | Callable[[Config], bool] = True, disabled_reason: Optional[str] = None, aliases: list[str] = [], - available: Literal[True] | Callable[[BaseAgent], bool] = True, + available: bool | Callable[[BaseAgent], bool] = True, ) -> Callable[[Callable[P, CO]], Callable[P, CO]]: """ The command decorator is used to create Command objects from ordinary functions. diff --git a/autogpts/autogpt/autogpt/models/command.py b/autogpts/autogpt/autogpt/models/command.py index 90aa266cc..5472dc4aa 100644 --- a/autogpts/autogpt/autogpt/models/command.py +++ b/autogpts/autogpt/autogpt/models/command.py @@ -32,7 +32,7 @@ class Command: enabled: Literal[True] | Callable[[Config], bool] = True, disabled_reason: Optional[str] = None, aliases: list[str] = [], - available: Literal[True] | Callable[[BaseAgent], bool] = True, + available: bool | Callable[[BaseAgent], bool] = True, ): self.name = name self.description = description @@ -55,7 +55,7 @@ class Command: ) raise RuntimeError(f"Command '{self.name}' is disabled") - if callable(self.available) and not self.available(agent): + if not self.available or callable(self.available) and not self.available(agent): raise RuntimeError(f"Command '{self.name}' is not available") return self.method(*args, **kwargs, agent=agent) |