Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Logging of Self-Feedback in logs/Debug Folder #3868

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
541ec5a
Adds SELF_FEEDBACK_FILE_NAME
AndresCdo May 5, 2023
6edb1db
Add self-feedback logging to logs/Debug folder
AndresCdo May 5, 2023
b2c7145
Reformatting
AndresCdo May 5, 2023
ca52927
Uses JSON file
AndresCdo May 5, 2023
4cfb0a2
Update agent.py
AndresCdo May 5, 2023
69739d6
Update agent.py
AndresCdo May 6, 2023
8f8443d
Merge remote-tracking branch 'upstream/master' into feature-log-self-…
AndresCdo May 6, 2023
ebcdc61
Adds PROMPT_FEEDBACK_FILE_NAME
AndresCdo May 6, 2023
952e1e8
Update agent.py
AndresCdo May 6, 2023
1cd078c
Update agent.py
AndresCdo May 6, 2023
89badd7
Reformatting
AndresCdo May 6, 2023
acebdef
Update agent.py
AndresCdo May 6, 2023
8e55fdf
Update agent.py
AndresCdo May 6, 2023
a6ccef4
Changes file names
AndresCdo May 6, 2023
14ac2a1
Update agent.py
AndresCdo May 6, 2023
7173251
Reformatting
AndresCdo May 6, 2023
702272b
Update agent.py
AndresCdo May 6, 2023
bb10a36
Merge branch 'master' into feature-log-self-feedback
AndresCdo May 6, 2023
1314058
Merge remote-tracking branch 'upstream/master' into feature-log-self-…
AndresCdo May 8, 2023
5f77e34
Changes conts names
AndresCdo May 8, 2023
9362d07
Merge branch 'master' into feature-log-self-feedback
AndresCdo May 8, 2023
e40be50
Merge remote-tracking branch 'upstream/master' into feature-log-self-…
AndresCdo May 8, 2023
7f59353
Update agent_manager.py
AndresCdo May 8, 2023
113cf46
Update agent_manager.py
AndresCdo May 8, 2023
197d46c
HARD reset
AndresCdo May 8, 2023
d534f60
Update test_get_self_feedback.py
AndresCdo May 8, 2023
11fb355
Update test_get_self_feedback.py
AndresCdo May 8, 2023
4213c69
Merge branch 'master' into feature-log-self-feedback
AndresCdo May 10, 2023
01820bc
Merge branch 'master' into feature-log-self-feedback
AndresCdo May 12, 2023
d033078
Merge remote-tracking branch 'upstream/master' into feature-log-self-…
AndresCdo May 12, 2023
0f4858d
Merge branch 'master' into feature-log-self-feedback
waynehamadi May 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions autogpt/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from autogpt.log_cycle.log_cycle import (
FULL_MESSAGE_HISTORY_FILE_NAME,
NEXT_ACTION_FILE_NAME,
PROMPT_SUPERVISOR_FEEDBACK_FILE_NAME,
SUPERVISOR_FEEDBACK_FILE_NAME,
AndresCdo marked this conversation as resolved.
Show resolved Hide resolved
USER_INPUT_FILE_NAME,
LogCycleHandler,
)
Expand Down Expand Up @@ -340,7 +342,24 @@ def get_self_feedback(self, thoughts: dict, llm_model: str) -> str:
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,
)
AndresCdo marked this conversation as resolved.
Show resolved Hide resolved

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 feedback
2 changes: 2 additions & 0 deletions autogpt/log_cycle/log_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
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"


Expand Down
12 changes: 12 additions & 0 deletions tests/unit/test_get_self_feedback.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from datetime import datetime

from autogpt.agent.agent import Agent
from autogpt.config import AIConfig
from autogpt.llm import create_chat_completion
from autogpt.log_cycle.log_cycle import LogCycleHandler


def test_get_self_feedback(mocker):
Expand Down Expand Up @@ -31,6 +34,15 @@ def test_get_self_feedback(mocker):
# Mock the config attribute of the Agent instance
agent_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 method
feedback = Agent.get_self_feedback(
agent_mock,
Expand Down