Implement custom continuous task count with 'y -n'
parent
62dfd84599
commit
c1be8a7403
|
@ -277,6 +277,7 @@ prompt = construct_prompt()
|
||||||
# Initialize variables
|
# Initialize variables
|
||||||
full_message_history = []
|
full_message_history = []
|
||||||
result = None
|
result = None
|
||||||
|
next_action_count = 0
|
||||||
# Make a constant:
|
# Make a constant:
|
||||||
user_input = "Determine which next command to use, and respond using the format specified above:"
|
user_input = "Determine which next command to use, and respond using the format specified above:"
|
||||||
|
|
||||||
|
@ -291,7 +292,6 @@ while True:
|
||||||
mem.permanent_memory,
|
mem.permanent_memory,
|
||||||
cfg.fast_token_limit) # TODO: This hardcodes the model to use GPT3.5. Make this an argument
|
cfg.fast_token_limit) # TODO: This hardcodes the model to use GPT3.5. Make this an argument
|
||||||
|
|
||||||
# print("assistant reply: "+assistant_reply)
|
|
||||||
# Print Assistant thoughts
|
# Print Assistant thoughts
|
||||||
print_assistant_thoughts(assistant_reply)
|
print_assistant_thoughts(assistant_reply)
|
||||||
|
|
||||||
|
@ -301,36 +301,45 @@ while True:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print_to_console("Error: \n", Fore.RED, str(e))
|
print_to_console("Error: \n", Fore.RED, str(e))
|
||||||
|
|
||||||
if not cfg.continuous_mode:
|
if not cfg.continuous_mode or next_action_count > 0:
|
||||||
### GET USER AUTHORIZATION TO EXECUTE COMMAND ###
|
### GET USER AUTHORIZATION TO EXECUTE COMMAND ###
|
||||||
# Get key press: Prompt the user to press enter to continue or escape
|
# Get key press: Prompt the user to press enter to continue or escape
|
||||||
# to exit
|
# to exit
|
||||||
user_input = ""
|
if next_action_count == 0:
|
||||||
print_to_console(
|
user_input = ""
|
||||||
"NEXT ACTION: ",
|
print_to_console(
|
||||||
Fore.CYAN,
|
"NEXT ACTION: ",
|
||||||
f"COMMAND = {Fore.CYAN}{command_name}{Style.RESET_ALL} ARGUMENTS = {Fore.CYAN}{arguments}{Style.RESET_ALL}")
|
Fore.CYAN,
|
||||||
print(
|
f"COMMAND = {Fore.CYAN}{command_name}{Style.RESET_ALL} ARGUMENTS = {Fore.CYAN}{arguments}{Style.RESET_ALL}")
|
||||||
f"Enter 'y' to authorise command or 'n' to exit program, or enter feedback for {ai_name}...",
|
print(
|
||||||
flush=True)
|
f"Enter 'y' to authorise command, 'y -n' to run n continuous commands, 'n' to exit program, or enter feedback for {ai_name}...",
|
||||||
while True:
|
flush=True)
|
||||||
console_input = input(Fore.MAGENTA + "Input:" + Style.RESET_ALL)
|
while True:
|
||||||
if console_input.lower() == "y":
|
console_input = input(Fore.MAGENTA + "Input:" + Style.RESET_ALL)
|
||||||
user_input = "GENERATE NEXT COMMAND JSON"
|
if console_input.lower() == "y":
|
||||||
break
|
user_input = "GENERATE NEXT COMMAND JSON"
|
||||||
elif console_input.lower() == "n":
|
break
|
||||||
user_input = "EXIT"
|
elif console_input.lower().startswith("y -"):
|
||||||
break
|
try:
|
||||||
else:
|
next_action_count = abs(int(console_input.split(" ")[1]))
|
||||||
user_input = console_input
|
user_input = "GENERATE NEXT COMMAND JSON"
|
||||||
command_name = "human_feedback"
|
except ValueError:
|
||||||
break
|
print("Invalid input format. Please enter 'y -n' where n is the number of continuous tasks.")
|
||||||
|
continue
|
||||||
|
break
|
||||||
|
elif console_input.lower() == "n":
|
||||||
|
user_input = "EXIT"
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
user_input = console_input
|
||||||
|
command_name = "human_feedback"
|
||||||
|
break
|
||||||
|
|
||||||
if user_input == "GENERATE NEXT COMMAND JSON":
|
if user_input == "GENERATE NEXT COMMAND JSON":
|
||||||
print_to_console(
|
print_to_console(
|
||||||
"-=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-=",
|
"-=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-=",
|
||||||
Fore.MAGENTA,
|
Fore.MAGENTA,
|
||||||
"")
|
"")
|
||||||
elif user_input == "EXIT":
|
elif user_input == "EXIT":
|
||||||
print("Exiting...", flush=True)
|
print("Exiting...", flush=True)
|
||||||
break
|
break
|
||||||
|
@ -348,6 +357,8 @@ while True:
|
||||||
result = f"Human feedback: {user_input}"
|
result = f"Human feedback: {user_input}"
|
||||||
else:
|
else:
|
||||||
result = f"Command {command_name} returned: {cmd.execute_command(command_name, arguments)}"
|
result = f"Command {command_name} returned: {cmd.execute_command(command_name, arguments)}"
|
||||||
|
if next_action_count > 0:
|
||||||
|
next_action_count -= 1
|
||||||
|
|
||||||
# Check if there's a result from the command append it to the message
|
# Check if there's a result from the command append it to the message
|
||||||
# history
|
# history
|
||||||
|
|
Loading…
Reference in New Issue