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.
Add early abort functions.
BillSchumacherfbd4e06df5d1
diff --git a/autogpt/agent/agent.py b/autogpt/agent/agent.pyindex e65c7e6177..7b1b5e1520 100644--- a/autogpt/agent/agent.py+++ b/autogpt/agent/agent.py@@ -180,6 +180,8 @@ class Agent:result = f"Human feedback: {user_input}"else:for plugin in cfg.plugins:+ if not plugin.can_handle_pre_command():+ continuecommand_name, arguments = plugin.pre_command(command_name, arguments)@@ -192,6 +194,8 @@ class Agent:result = f"Command {command_name} returned: " f"{command_result}"for plugin in cfg.plugins:+ if not plugin.can_handle_post_command():+ continueresult = plugin.post_command(command_name, result)if self.next_action_count > 0:self.next_action_count -= 1diff --git a/autogpt/agent/agent_manager.py b/autogpt/agent/agent_manager.pyindex e1353e03a5..d264815084 100644--- a/autogpt/agent/agent_manager.py+++ b/autogpt/agent/agent_manager.py@@ -31,6 +31,8 @@ class AgentManager(metaclass=Singleton):{"role": "user", "content": prompt},]for plugin in self.cfg.plugins:+ if not plugin.can_handle_pre_instruction():+ continueplugin_messages = plugin.pre_instruction(messages)if plugin_messages:for plugin_message in plugin_messages:@@ -46,6 +48,8 @@ class AgentManager(metaclass=Singleton):plugins_reply = ""for i, plugin in enumerate(self.cfg.plugins):+ if not plugin.can_handle_on_instruction():+ continueplugin_result = plugin.on_instruction(messages)if plugin_result:sep = "" if not i else "\n"@@ -61,6 +65,8 @@ class AgentManager(metaclass=Singleton):self.agents[key] = (task, messages, model)for plugin in self.cfg.plugins:+ if not plugin.can_handle_post_instruction():+ continueagent_reply = plugin.post_instruction(agent_reply)return key, agent_reply@@ -81,6 +87,8 @@ class AgentManager(metaclass=Singleton):messages.append({"role": "user", "content": message})for plugin in self.cfg.plugins:+ if not plugin.can_handle_pre_instruction():+ continueplugin_messages = plugin.pre_instruction(messages)if plugin_messages:for plugin_message in plugin_messages:@@ -96,6 +104,8 @@ class AgentManager(metaclass=Singleton):plugins_reply = agent_replyfor i, plugin in enumerate(self.cfg.plugins):+ if not plugin.can_handle_on_instruction():+ continueplugin_result = plugin.on_instruction(messages)if plugin_result:sep = "" if not i else "\n"@@ -105,6 +115,8 @@ class AgentManager(metaclass=Singleton):messages.append({"role": "assistant", "content": plugins_reply})for plugin in self.cfg.plugins:+ if not plugin.can_handle_post_instruction():+ continueagent_reply = plugin.post_instruction(agent_reply)return agent_replydiff --git a/autogpt/chat.py b/autogpt/chat.pyindex 16693040a9..22fe636cb7 100644--- a/autogpt/chat.py+++ b/autogpt/chat.py@@ -137,6 +137,8 @@ def chat_with_ai(plugin_count = len(cfg.plugins)for i, plugin in enumerate(cfg.plugins):+ if not plugin.can_handle_on_planning():+ continueplugin_response = plugin.on_planning(agent.prompt_generator, current_context)diff --git a/autogpt/llm_utils.py b/autogpt/llm_utils.pyindex 7aac703c02..4fb0e1f537 100644--- a/autogpt/llm_utils.py+++ b/autogpt/llm_utils.py@@ -131,6 +131,8 @@ def create_chat_completion(raise RuntimeError(f"Failed to get response after {num_retries} retries")resp = response.choices[0].message["content"]for plugin in CFG.plugins:+ if not plugin.can_handle_on_response():+ continueresp = plugin.on_response(resp)return resp