Skip to content

Commit

Permalink
add report method to typewriter_log & load report plugins into logger (
Browse files Browse the repository at this point in the history
…Significant-Gravitas#3582)

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

* more clear log and comment

* isort and black
  • Loading branch information
Wladastic authored Apr 30, 2023
1 parent aab79fd commit 6d2c0c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions autogpt/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ def __init__(self):
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
):
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)
Expand Down
7 changes: 7 additions & 0 deletions autogpt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6d2c0c4

Please sign in to comment.