add report method to typewriter_log & load report plugins into logger (#3582)

* add report method to typewriter_log & load report plugins into logger

* more clear log and comment

* isort and black
pull/1824/head
WladBlank 2023-04-30 18:43:01 +02:00 committed by GitHub
parent aab79fdf6d
commit 6d2c0c4242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -75,6 +75,7 @@ class Logger(metaclass=Singleton):
self.logger.setLevel(logging.DEBUG)
self.speak_mode = False
self.chat_plugins = []
def typewriter_log(
self, title="", title_color="", content="", speak_text=False, level=logging.INFO
@ -82,6 +83,9 @@ class Logger(metaclass=Singleton):
if speak_text and self.speak_mode:
say_text(f"{title}. {content}")
for plugin in self.chat_plugins:
plugin.report(f"{title}. {content}")
if content:
if isinstance(content, list):
content = " ".join(content)

View File

@ -125,6 +125,13 @@ def run_auto_gpt(
full_message_history = []
next_action_count = 0
# add chat plugins capable of report to logger
if cfg.chat_messages_enabled:
for plugin in cfg.plugins:
if hasattr(plugin, "can_handle_report") and plugin.can_handle_report():
logger.info(f"Loaded plugin into logger: {plugin.__class__.__name__}")
logger.chat_plugins.append(plugin)
# Initialize memory and make sure it is empty.
# this is particularly important for indexing and referencing pinecone memory
memory = get_memory(cfg, init=True)