Skip to content

Commit

Permalink
Merge pull request Significant-Gravitas#574 from richbeales/master
Browse files Browse the repository at this point in the history
update print_to_console to log to a text file
  • Loading branch information
Torantulino authored Apr 10, 2023
2 parents 977d84b + f69e462 commit 5cd48d5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@
import traceback
import yaml
import argparse
import logging

cfg = Config()

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 check_openai_api_key():
"""Check if the OpenAI API key is set in config.py or as an environment variable."""
if not cfg.openai_api_key:
Expand All @@ -29,7 +38,6 @@ def check_openai_api_key():
print("You can get your key from https://beta.openai.com/account/api-keys")
exit(1)


def print_to_console(
title,
title_color,
Expand All @@ -39,10 +47,12 @@ def print_to_console(
max_typing_speed=0.01):
"""Prints text to the console with a typing effect"""
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()
Expand Down Expand Up @@ -295,6 +305,7 @@ def parse_arguments():
# TODO: fill in llm values here
check_openai_api_key()
cfg = Config()
logger = configure_logging()
parse_arguments()
ai_name = ""
prompt = construct_prompt()
Expand Down

0 comments on commit 5cd48d5

Please sign in to comment.