add pre_command and post_command hooks.

pull/2531/head
BillSchumacher 2023-04-16 00:20:00 -05:00
parent 17478d6a05
commit 83403ad3ab
No known key found for this signature in database
GPG Key ID: 1133789BDD03E12A
1 changed files with 10 additions and 0 deletions

View File

@ -110,6 +110,7 @@ class Agent:
console_input = clean_input(
Fore.MAGENTA + "Input:" + Style.RESET_ALL
)
if console_input.lower().rstrip() == "y":
self.user_input = "GENERATE NEXT COMMAND JSON"
break
@ -160,10 +161,19 @@ class Agent:
elif command_name == "human_feedback":
result = f"Human feedback: {self.user_input}"
else:
for plugin in cfg.plugins:
command_name, arguments = plugin.pre_command(
command_name, arguments
)
result = (
f"Command {command_name} returned: "
f"{execute_command(command_name, arguments)}"
)
for plugin in cfg.plugins:
result = plugin.post_command(
command_name, result
)
if self.next_action_count > 0:
self.next_action_count -= 1