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.
Adds spinner when AI is thinking
Torantulinob05422876915
diff --git a/AutonomousAI/main.py b/AutonomousAI/main.pyindex f2157042c0..7586c0348c 100644--- a/AutonomousAI/main.py+++ b/AutonomousAI/main.py@@ -4,6 +4,7 @@ import memory as memimport dataimport chatfrom colorama import Fore, Style+from spinner import Spinnerdef print_assistant_thoughts(assistant_reply):try:@@ -53,7 +54,8 @@ user_input = "NEXT COMMAND"# Interaction Loopwhile True:# Send message to AI, get response- assistant_reply = chat.chat_with_ai(prompt, user_input, full_message_history, mem.permanent_memory, token_limit)+ with Spinner("Thinking... "):+ assistant_reply = chat.chat_with_ai(prompt, user_input, full_message_history, mem.permanent_memory, token_limit)# Print Assistant thoughtsprint_assistant_thoughts(assistant_reply)diff --git a/AutonomousAI/spinner.py b/AutonomousAI/spinner.pynew file mode 100644index 0000000000..ebb5fb9862--- /dev/null+++ b/AutonomousAI/spinner.py@@ -0,0 +1,30 @@+import sys+import threading+import itertools+import time++class Spinner:+ def __init__(self, message="Loading...", delay=0.1):+ self.spinner = itertools.cycle(['-', '/', '|', '\\'])+ self.delay = delay+ self.message = message+ self.running = False+ self.spinner_thread = None++ def spin(self):+ while self.running:+ sys.stdout.write(next(self.spinner) + " " + self.message + "\r")+ sys.stdout.flush()+ time.sleep(self.delay)+ sys.stdout.write('\b' * (len(self.message) + 2))++ def __enter__(self):+ self.running = True+ self.spinner_thread = threading.Thread(target=self.spin)+ self.spinner_thread.start()++ def __exit__(self, exc_type, exc_value, exc_traceback):+ self.running = False+ self.spinner_thread.join()+ sys.stdout.write('\r' + ' ' * (len(self.message) + 2) + '\r')+ sys.stdout.flush()