The ability to jump in and steer a train off thought that is running off course is quite helpful.
To this end, adjust the interaction loop in main.py such that the user can jump in to talk.
`# Interaction Loop
while True:
# Send message to AI, get response
with Spinner("Thinking... "):
assistant_reply = chat.chat_with_ai(
prompt,
user_input,
full_message_history,
mem.permanent_memory,
token_limit)
# Print Assistant thoughts
print_assistant_thoughts(assistant_reply)
# Get command name and arguments
try:
command_name, arguments = cmd.get_command(assistant_reply)
except Exception as e:
print_to_console("Error: \n", Fore.RED, str(e))
if not cfg.continuous_mode:
### GET USER AUTHORIZATION TO EXECUTE COMMAND ###
# Get key press: Prompt the user to press enter to continue or escape
# to exit
user_input = ""
print("Enter 'y' to authorise command, 'n' to deny command, or any text to communicate with the AI. Type 'EXIT' to exit the program...", flush=True)
while True:
console_input = input(Fore.MAGENTA + "Input:" + Style.RESET_ALL)
if console_input.lower() == "y":
user_input = "NEXT COMMAND"
break
elif console_input.lower() == "n":
user_input = "DENY COMMAND"
break
elif console_input.lower() == "exit":
user_input = "EXIT"
break
else:
user_input = console_input
break
if user_input != "NEXT COMMAND":
if user_input == "DENY COMMAND":
print("Command denied.", flush=True)
elif user_input == "EXIT":
print("Exiting...", flush=True)
break
print_to_console(
"-=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-=",
Fore.MAGENTA,
"")
else:
# Print command
print_to_console(
"NEXT ACTION: ",
Fore.CYAN,
f"COMMAND = {Fore.CYAN}{command_name}{Style.RESET_ALL} ARGUMENTS = {Fore.CYAN}{arguments}{Style.RESET_ALL}")
# Exectute command
if command_name.lower() != "error":
result = f"Command {command_name} returned: {cmd.execute_command(command_name, arguments)}"
else:
result = f"Command {command_name} threw the following error: " + arguments
# Check if there's a result from the command append it to the message
# history
if result is not None:
full_message_history.append(chat.create_chat_message("system", result))
print_to_console("SYSTEM: ", Fore.YELLOW, result)
else:
full_message_history.append(
chat.create_chat_message(
"system", "Unable to execute command"))
print_to_console("SYSTEM: ", Fore.YELLOW, "Unable to execute command")`
That replacement works relatively well but of course, creates a few more issues in practice:
Name your AI: For example, 'Entrepreneur-GPT'
AI Name: RAVEN
RAVEN here! I am at your service.
Describe your AI's role: For example, 'an AI designed to autonomously develop and run businesses with the sole goal of increasing your net worth.'
RAVEN is: A Coding Assistant
Enter up to 5 goals for your AI: For example: Increase net worth Grow Twitter Account Develop and manage multiple businesses autonomously'
Enter nothing to load defaults, enter nothing when finished.
Goal 1: Add 4 + 4
Goal 2: Ask me how I'm doing.
Goal 3:
Error: Prompt file not found
Error: Invalid JSON
4 + 4 equals 8 How are you doing today?
Enter 'y' to authorize command, 'n' to deny command, or any text to communicate with the AI. Type 'EXIT' to exit the program...
Input:I'm good how are you?
-=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-=
SYSTEM: Command Error: returned: Unknown command Error:
Error: Invalid JSON
As an AI, I don't have feelings or emotions, but I'm here to help you with any questions or tasks you have. Let me know how I can assist you!
Enter 'y' to authorise command, 'n' to deny command, or any text to communicate with the AI. Type 'EXIT' to exit the program...
Input:
The issues emerging are: Invalid JSON, Prompt File Not Found.
Further, ideally jumping in here, the user can steer GPT in the right direction. "I see that you are searching for term X, by you would have more success searching for term Y, try that."
Then it would ask permission to do that search.