From b87d126e324059db3b47863dbe8e5d852234196b Mon Sep 17 00:00:00 2001 From: Richard Beales Date: Sun, 9 Apr 2023 10:06:30 +0100 Subject: [PATCH 1/3] update print_to_console to log to a text file Uses python logging module to output progress to a text file log.txt --- scripts/main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/main.py b/scripts/main.py index 10f9d0dca..d9b7204c2 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -16,7 +16,15 @@ from ai_config import AIConfig import traceback import yaml import argparse +import logging +def configure_logging(): + logging.basicConfig(filename='log.txt', + filemode='a', + format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s', + datefmt='%H:%M:%S', + level=logging.DEBUG) + return logging.getLogger('AutoGPT') def print_to_console( title, @@ -26,10 +34,12 @@ def print_to_console( min_typing_speed=0.05, max_typing_speed=0.01): global cfg + global logger if speak_text and cfg.speak_mode: speak.say_text(f"{title}. {content}") print(title_color + title + " " + Style.RESET_ALL, end="") if content: + logger.info(title + ': ' + content) if isinstance(content, list): content = " ".join(content) words = content.split() @@ -270,6 +280,7 @@ def parse_arguments(): # TODO: fill in llm values here cfg = Config() +logger = configure_logging() parse_arguments() ai_name = "" prompt = construct_prompt() @@ -355,7 +366,7 @@ while True: f"COMMAND = {Fore.CYAN}{command_name}{Style.RESET_ALL} ARGUMENTS = {Fore.CYAN}{arguments}{Style.RESET_ALL}") # Execute command - if command_name.lower() == "error": + if command_name.lower().startswith( "error" ): result = f"Command {command_name} threw the following error: " + arguments elif command_name == "human_feedback": result = f"Human feedback: {user_input}" @@ -381,3 +392,4 @@ while True: "system", "Unable to execute command")) print_to_console("SYSTEM: ", Fore.YELLOW, "Unable to execute command") + From 9cea7c0f61ce4ec6c5b7b087678f55012c249f45 Mon Sep 17 00:00:00 2001 From: Richard Beales Date: Mon, 10 Apr 2023 08:11:54 +0100 Subject: [PATCH 2/3] Update main.py --- scripts/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/main.py b/scripts/main.py index 6ec026d32..2f134e0cc 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -395,5 +395,5 @@ while True: chat.create_chat_message( "system", "Unable to execute command")) print_to_console("SYSTEM: ", Fore.YELLOW, "Unable to execute command") - - + + From 2fb06a3db5051808d5529f48ba074f62c1323c8f Mon Sep 17 00:00:00 2001 From: Richard Beales Date: Mon, 10 Apr 2023 08:14:48 +0100 Subject: [PATCH 3/3] trying to get the right amount of spacing / newlines at the end of main.py! --- scripts/main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/main.py b/scripts/main.py index 2f134e0cc..1bb708c42 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -395,5 +395,3 @@ while True: chat.create_chat_message( "system", "Unable to execute command")) print_to_console("SYSTEM: ", Fore.YELLOW, "Unable to execute command") - -