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.
Added feature to interrupt y -N continuous commands. (#4230)
gravelBridgec04f2210cc3a
diff --git a/autogpt/agent/agent.py b/autogpt/agent/agent.pyindex 4db9e2eea6..6888840191 100644--- a/autogpt/agent/agent.py+++ b/autogpt/agent/agent.py@@ -1,3 +1,5 @@+import signal+import sysfrom datetime import datetimefrom colorama import Fore, Style@@ -88,6 +90,20 @@ class Agent:arguments = Noneuser_input = ""+ # Signal handler for interrupting y -N+ def signal_handler(signum, frame):+ if self.next_action_count == 0:+ sys.exit()+ else:+ print(+ Fore.RED+ + "Interrupt signal received. Stopping continuous command execution."+ + Style.RESET_ALL+ )+ self.next_action_count = 0++ signal.signal(signal.SIGINT, signal_handler)+while True:# Discontinue if continuous limit is reachedself.cycle_count += 1