mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 22:44:21 +01:00
add pre_command and post_command hooks.
This commit is contained in:
@@ -110,6 +110,7 @@ class Agent:
|
|||||||
console_input = clean_input(
|
console_input = clean_input(
|
||||||
Fore.MAGENTA + "Input:" + Style.RESET_ALL
|
Fore.MAGENTA + "Input:" + Style.RESET_ALL
|
||||||
)
|
)
|
||||||
|
|
||||||
if console_input.lower().rstrip() == "y":
|
if console_input.lower().rstrip() == "y":
|
||||||
self.user_input = "GENERATE NEXT COMMAND JSON"
|
self.user_input = "GENERATE NEXT COMMAND JSON"
|
||||||
break
|
break
|
||||||
@@ -160,10 +161,19 @@ class Agent:
|
|||||||
elif command_name == "human_feedback":
|
elif command_name == "human_feedback":
|
||||||
result = f"Human feedback: {self.user_input}"
|
result = f"Human feedback: {self.user_input}"
|
||||||
else:
|
else:
|
||||||
|
for plugin in cfg.plugins:
|
||||||
|
command_name, arguments = plugin.pre_command(
|
||||||
|
command_name, arguments
|
||||||
|
)
|
||||||
result = (
|
result = (
|
||||||
f"Command {command_name} returned: "
|
f"Command {command_name} returned: "
|
||||||
f"{execute_command(command_name, arguments)}"
|
f"{execute_command(command_name, arguments)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for plugin in cfg.plugins:
|
||||||
|
result = plugin.post_command(
|
||||||
|
command_name, result
|
||||||
|
)
|
||||||
if self.next_action_count > 0:
|
if self.next_action_count > 0:
|
||||||
self.next_action_count -= 1
|
self.next_action_count -= 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user