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.
Implement Logging of Self-Feedback in logs/Debug Folder (#3868)
Andres Caicedo7508e9941f6f
diff --git a/autogpt/agent/agent.py b/autogpt/agent/agent.pyindex 6888840191..e68bf98954 100644--- a/autogpt/agent/agent.py+++ b/autogpt/agent/agent.py@@ -13,6 +13,8 @@ from autogpt.llm.token_counter import count_string_tokensfrom autogpt.log_cycle.log_cycle import (FULL_MESSAGE_HISTORY_FILE_NAME,NEXT_ACTION_FILE_NAME,+ PROMPT_SUPERVISOR_FEEDBACK_FILE_NAME,+ SUPERVISOR_FEEDBACK_FILE_NAME,USER_INPUT_FILE_NAME,LogCycleHandler,)@@ -340,7 +342,24 @@ class Agent:plan = thoughts.get("plan", "")thought = thoughts.get("thoughts", "")feedback_thoughts = thought + reasoning + plan- return create_chat_completion(- [{"role": "user", "content": feedback_prompt + feedback_thoughts}],- llm_model,++ messages = {"role": "user", "content": feedback_prompt + feedback_thoughts}++ self.log_cycle_handler.log_cycle(+ self.config.ai_name,+ self.created_at,+ self.cycle_count,+ messages,+ PROMPT_SUPERVISOR_FEEDBACK_FILE_NAME,+ )++ feedback = create_chat_completion(messages)++ self.log_cycle_handler.log_cycle(+ self.config.ai_name,+ self.created_at,+ self.cycle_count,+ feedback,+ SUPERVISOR_FEEDBACK_FILE_NAME,)+ return feedbackdiff --git a/autogpt/log_cycle/log_cycle.py b/autogpt/log_cycle/log_cycle.pyindex cff3ac1a57..8daed25c46 100644--- a/autogpt/log_cycle/log_cycle.py+++ b/autogpt/log_cycle/log_cycle.py@@ -10,6 +10,8 @@ CURRENT_CONTEXT_FILE_NAME = "current_context.json"NEXT_ACTION_FILE_NAME = "next_action.json"PROMPT_SUMMARY_FILE_NAME = "prompt_summary.json"SUMMARY_FILE_NAME = "summary.txt"+SUPERVISOR_FEEDBACK_FILE_NAME = "supervisor_feedback.txt"+PROMPT_SUPERVISOR_FEEDBACK_FILE_NAME = "prompt_supervisor_feedback.json"USER_INPUT_FILE_NAME = "user_input.txt"diff --git a/tests/unit/test_get_self_feedback.py b/tests/unit/test_get_self_feedback.pyindex e1e9bd4ad4..5e59757e16 100644--- a/tests/unit/test_get_self_feedback.py+++ b/tests/unit/test_get_self_feedback.py@@ -1,6 +1,9 @@+from datetime import datetime+from autogpt.agent.agent import Agentfrom autogpt.config import AIConfigfrom autogpt.llm import create_chat_completion+from autogpt.log_cycle.log_cycle import LogCycleHandlerdef test_get_self_feedback(mocker):@@ -31,6 +34,15 @@ def test_get_self_feedback(mocker):# Mock the config attribute of the Agent instanceagent_mock.config = AIConfig()+ # Mock the log_cycle_handler attribute of the Agent instance+ agent_mock.log_cycle_handler = LogCycleHandler()++ # Mock the create_nested_directory method of the LogCycleHandler instance+ agent_mock.created_at = datetime.now().strftime("%Y%m%d_%H%M%S")++ # Mock the cycle_count attribute of the Agent instance+ agent_mock.cycle_count = 0+# Call the get_self_feedback methodfeedback = Agent.get_self_feedback(agent_mock,