Skip to content

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.

Changes user input from typed input to keypress.

Torantulino2cca2e78ef6b
diff --git a/AutonomousAI/main.py b/AutonomousAI/main.py
index 7aa62f7f90..e3220ecc2f 100644
--- a/AutonomousAI/main.py
+++ b/AutonomousAI/main.py
@@ -4,6 +4,7 @@ import json
import keys
import commands as cmd
import memory as mem
+import keyboard
# Initialize the OpenAI API client
openai.api_key = keys.OPENAI_API_KEY
@@ -55,6 +56,8 @@ def chat_with_ai(prompt, user_input, full_message_history, permanent_memory, tok
model="gpt-4",
messages=current_context,
)
+ print("---------------------------")
+
assistant_reply = response.choices[0].message["content"]
return assistant_reply
@@ -173,25 +176,41 @@ ACCOUNTS:
4. Substack: [email protected]"""
token_limit = 6000 # The maximum number of tokens allowed in the API call
result = None
-# Example loop for interaction
-# Example loop for interaction
+
+# Interaction Loop
while True:
- user_input = input("User: ")
+ # Get key press: Prompt the user to press enter to continue or escape to exit
+ print("Press 'Enter' to continue or 'Escape' to exit...")
+ user_input = ""
+
+ while True:
+ if keyboard.is_pressed('enter'):
+ user_input = "NEXT COMMAND"
+ break
+ elif keyboard.is_pressed('escape'):
+ user_input = "EXIT"
+ break
+ else:
+ continue
- if user_input.lower() == "exit":
+ if user_input != "NEXT COMMAND":
+ print("Exiting...")
break
- # Check if there's a result from the previous iteration and append it to the message history
- if result != None:
- full_message_history.append(create_chat_message("system", result))
- print("system: " + result)
+ print("-=-=-=-=-=-=-= NEXT COMMAND AUTHORISED -=-=-=-=-=-=-=")
+ # Send command to AI, get response
assistant_reply = chat_with_ai(prompt, user_input, full_message_history, mem.permanent_memory, token_limit)
print(f"Assistant: {assistant_reply}")
- print("-------------------------")
- # Add user message and assistant reply to message history
+ # Update full message history
full_message_history.append(create_chat_message("user", user_input))
full_message_history.append(create_chat_message("assistant", assistant_reply))
result = execute_command(assistant_reply)
+
+ # Check if there's a result append it to the message history
+ if result != None:
+ full_message_history.append(create_chat_message("system", result))
+ print("system: " + result)
+