From 1d97d1ea13cd923d9221eaf3d7c504a208c6cce8 Mon Sep 17 00:00:00 2001 From: Torantulino Date: Wed, 29 Mar 2023 02:36:40 +0100 Subject: [PATCH] Changes from keypress detection to letter input Reason: keypresses where being detected when tabbed out. --- AutonomousAI/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AutonomousAI/main.py b/AutonomousAI/main.py index 758e685de2..a486126b16 100644 --- a/AutonomousAI/main.py +++ b/AutonomousAI/main.py @@ -4,7 +4,6 @@ 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 @@ -150,7 +149,7 @@ def print_assistant_thoughts(assistant_reply): for line in lines: print(f"- {line.strip()}", flush=True) print(f"CRITICISM: " + assistant_thoughts_criticism, flush=True) - + except json.decoder.JSONDecodeError: print("Error: Invalid JSON", flush=True) print(assistant_reply, flush=True) @@ -181,12 +180,13 @@ while True: # Get key press: Prompt the user to press enter to continue or escape to exit user_input = "" print(f"""NEXT ACTION: COMMAND = {command_name} ARGUMENTS = {arguments}""", flush=True) - print("Press 'Enter' to authorise command or 'Escape' to exit program...", flush=True) + print("Enter 'y' to authorise command or 'n' to exit program...", flush=True) while True: - if keyboard.is_pressed('enter'): + console_input = input() + if console_input == "y": user_input = "NEXT COMMAND" break - elif keyboard.is_pressed('escape'): + elif console_input == "n": user_input = "EXIT" break else: