AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Update logs.py with new print_assistant_thoughts function
Merwane Hamadib2b31dbc8f58
diff --git a/autogpt/logs.py b/autogpt/logs.pyindex 22ce23f4aa..5365302366 100644--- a/autogpt/logs.py+++ b/autogpt/logs.py@@ -288,3 +288,42 @@ def print_assistant_thoughts(ai_name, assistant_reply):except Exception:call_stack = traceback.format_exc()logger.error("Error: \n", call_stack)++def print_assistant_thoughts(ai_name: object, assistant_reply_json_valid: object) -> None:+ assistant_thoughts_reasoning = None+ assistant_thoughts_plan = None+ assistant_thoughts_speak = None+ assistant_thoughts_criticism = None++ assistant_thoughts = assistant_reply_json_valid.get("thoughts", {})+ assistant_thoughts_text = assistant_thoughts.get("text")+ if assistant_thoughts:+ assistant_thoughts_reasoning = assistant_thoughts.get("reasoning")+ assistant_thoughts_plan = assistant_thoughts.get("plan")+ assistant_thoughts_criticism = assistant_thoughts.get("criticism")+ assistant_thoughts_speak = assistant_thoughts.get("speak")+ logger.typewriter_log(+ f"{ai_name.upper()} THOUGHTS:", Fore.YELLOW, f"{assistant_thoughts_text}"+ )+ logger.typewriter_log(+ "REASONING:", Fore.YELLOW, f"{assistant_thoughts_reasoning}"+ )+ if assistant_thoughts_plan:+ logger.typewriter_log("PLAN:", Fore.YELLOW, "")+ # If it's a list, join it into a string+ if isinstance(assistant_thoughts_plan, list):+ assistant_thoughts_plan = "\n".join(assistant_thoughts_plan)+ elif isinstance(assistant_thoughts_plan, dict):+ assistant_thoughts_plan = str(assistant_thoughts_plan)++ # Split the input_string using the newline character and dashes+ lines = assistant_thoughts_plan.split("\n")+ for line in lines:+ line = line.lstrip("- ")+ logger.typewriter_log("- ", Fore.GREEN, line.strip())+ logger.typewriter_log(+ "CRITICISM:", Fore.YELLOW, f"{assistant_thoughts_criticism}"+ )+ # Speak the assistant's thoughts+ if CFG.speak_mode and assistant_thoughts_speak:+ say_text(assistant_thoughts_speak)