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 blackpull/1824/head
parent
aab79fdf6d
commit
6d2c0c4242
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue