mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 22:14:28 +01:00
put loop in in if main
This commit is contained in:
@@ -316,27 +316,27 @@ def parse_arguments():
|
|||||||
cfg.memory_backend = chosen
|
cfg.memory_backend = chosen
|
||||||
|
|
||||||
|
|
||||||
# TODO: fill in llm values here
|
def main():
|
||||||
check_openai_api_key()
|
global ai_name, memory
|
||||||
parse_arguments()
|
# TODO: fill in llm values here
|
||||||
logger.set_level(logging.DEBUG if cfg.debug_mode else logging.INFO)
|
check_openai_api_key()
|
||||||
ai_name = ""
|
parse_arguments()
|
||||||
prompt = construct_prompt()
|
logger.set_level(logging.DEBUG if cfg.debug_mode else logging.INFO)
|
||||||
# print(prompt)
|
ai_name = ""
|
||||||
# Initialize variables
|
prompt = construct_prompt()
|
||||||
full_message_history = []
|
# print(prompt)
|
||||||
result = None
|
# Initialize variables
|
||||||
next_action_count = 0
|
full_message_history = []
|
||||||
# Make a constant:
|
result = None
|
||||||
user_input = "Determine which next command to use, and respond using the format specified above:"
|
next_action_count = 0
|
||||||
|
# Make a constant:
|
||||||
# Initialize memory and make sure it is empty.
|
user_input = "Determine which next command to use, and respond using the format specified above:"
|
||||||
# this is particularly important for indexing and referencing pinecone memory
|
# Initialize memory and make sure it is empty.
|
||||||
memory = get_memory(cfg, init=True)
|
# this is particularly important for indexing and referencing pinecone memory
|
||||||
print('Using memory of type: ' + memory.__class__.__name__)
|
memory = get_memory(cfg, init=True)
|
||||||
|
print('Using memory of type: ' + memory.__class__.__name__)
|
||||||
# Interaction Loop
|
# Interaction Loop
|
||||||
while True:
|
while True:
|
||||||
# Send message to AI, get response
|
# Send message to AI, get response
|
||||||
with Spinner("Thinking... "):
|
with Spinner("Thinking... "):
|
||||||
assistant_reply = chat.chat_with_ai(
|
assistant_reply = chat.chat_with_ai(
|
||||||
@@ -351,7 +351,8 @@ while True:
|
|||||||
|
|
||||||
# Get command name and arguments
|
# Get command name and arguments
|
||||||
try:
|
try:
|
||||||
command_name, arguments = cmd.get_command(attempt_to_fix_json_by_finding_outermost_brackets(assistant_reply))
|
command_name, arguments = cmd.get_command(
|
||||||
|
attempt_to_fix_json_by_finding_outermost_brackets(assistant_reply))
|
||||||
if cfg.speak_mode:
|
if cfg.speak_mode:
|
||||||
speak.say_text(f"I want to execute {command_name}")
|
speak.say_text(f"I want to execute {command_name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -406,7 +407,7 @@ while True:
|
|||||||
f"COMMAND = {Fore.CYAN}{command_name}{Style.RESET_ALL} ARGUMENTS = {Fore.CYAN}{arguments}{Style.RESET_ALL}")
|
f"COMMAND = {Fore.CYAN}{command_name}{Style.RESET_ALL} ARGUMENTS = {Fore.CYAN}{arguments}{Style.RESET_ALL}")
|
||||||
|
|
||||||
# Execute command
|
# Execute command
|
||||||
if command_name is not None and command_name.lower().startswith( "error" ):
|
if command_name is not None and command_name.lower().startswith("error"):
|
||||||
result = f"Command {command_name} threw the following error: " + arguments
|
result = f"Command {command_name} threw the following error: " + arguments
|
||||||
elif command_name == "human_feedback":
|
elif command_name == "human_feedback":
|
||||||
result = f"Human feedback: {user_input}"
|
result = f"Human feedback: {user_input}"
|
||||||
@@ -431,3 +432,7 @@ while True:
|
|||||||
chat.create_chat_message(
|
chat.create_chat_message(
|
||||||
"system", "Unable to execute command"))
|
"system", "Unable to execute command"))
|
||||||
logger.typewriter_log("SYSTEM: ", Fore.YELLOW, "Unable to execute command")
|
logger.typewriter_log("SYSTEM: ", Fore.YELLOW, "Unable to execute command")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user