Skip to content

Commit

Permalink
Merge pull request Significant-Gravitas#233 from russellocean/master
Browse files Browse the repository at this point in the history
Implement custom continuous task count with 'y -n' command
  • Loading branch information
Torantulino authored Apr 6, 2023
2 parents 5987d62 + c8a927d commit 672bb5e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def parse_arguments():
# Initialize variables
full_message_history = []
result = None
next_action_count = 0
# Make a constant:
user_input = "Determine which next command to use, and respond using the format specified above:"

Expand All @@ -298,7 +299,6 @@ def parse_arguments():
memory,
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(assistant_reply)

Expand All @@ -308,7 +308,7 @@ def parse_arguments():
except Exception as e:
print_to_console("Error: \n", Fore.RED, str(e))

if not cfg.continuous_mode:
if not cfg.continuous_mode and next_action_count == 0:
### GET USER AUTHORIZATION TO EXECUTE COMMAND ###
# Get key press: Prompt the user to press enter to continue or escape
# to exit
Expand All @@ -318,13 +318,21 @@ def parse_arguments():
Fore.CYAN,
f"COMMAND = {Fore.CYAN}{command_name}{Style.RESET_ALL} ARGUMENTS = {Fore.CYAN}{arguments}{Style.RESET_ALL}")
print(
f"Enter 'y' to authorise command or 'n' to exit program, or enter feedback for {ai_name}...",
f"Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for {ai_name}...",
flush=True)
while True:
console_input = input(Fore.MAGENTA + "Input:" + Style.RESET_ALL)
if console_input.lower() == "y":
user_input = "GENERATE NEXT COMMAND JSON"
break
elif console_input.lower().startswith("y -"):
try:
next_action_count = abs(int(console_input.split(" ")[1]))
user_input = "GENERATE NEXT COMMAND JSON"
except ValueError:
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
Expand Down Expand Up @@ -355,6 +363,8 @@ def parse_arguments():
result = f"Human feedback: {user_input}"
else:
result = f"Command {command_name} returned: {cmd.execute_command(command_name, arguments)}"
if next_action_count > 0:
next_action_count -= 1

memory_to_add = f"Assistant Reply: {assistant_reply} " \
f"\nResult: {result} " \
Expand Down

0 comments on commit 672bb5e

Please sign in to comment.