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

Conversation

AndresCdo
Copy link
Contributor

@AndresCdo AndresCdo commented May 5, 2023

Background

To improve the performance of our application and understand how it functions in different scenarios, we decided to implement self-feedback logging. This feature will enable the application to log its own feedback regarding its performance and decisions, providing valuable insights for future optimization and development.

Changes

Developed a self-feedback logging mechanism that captures application feedback and appends it to the log file within the logs/DEBUG folder.

Documentation

Descriptions were added in new lines on tests.

Test Plan

I did test it, and it seems to work fine.

PR Quality Checklist

  • My pull request is atomic and focuses on a single change.
  • I have thoroughly tested my changes with multiple different prompts.
  • I have considered potential risks and mitigations for my changes.
  • I have documented my changes clearly and comprehensively.
  • I have not snuck in any "extra" small tweaks changes

@vercel
Copy link

vercel bot commented May 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 17, 2023 11:27am

@github-actions github-actions bot added the size/m label May 5, 2023
@AndresCdo
Copy link
Contributor Author

#3842

@github-actions github-actions bot added size/s and removed size/m labels May 5, 2023
@codecov
Copy link

codecov bot commented May 5, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.06 🎉

Comparison is base (7c71b43) 62.75% compared to head (0f4858d) 62.82%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3868      +/-   ##
==========================================
+ Coverage   62.75%   62.82%   +0.06%     
==========================================
  Files          73       73              
  Lines        3367     3373       +6     
  Branches      487      487              
==========================================
+ Hits         2113     2119       +6     
  Misses       1107     1107              
  Partials      147      147              
Impacted Files Coverage Δ
autogpt/agent/agent.py 58.49% <100.00%> (+1.07%) ⬆️
autogpt/log_cycle/log_cycle.py 95.45% <100.00%> (+0.21%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions github-actions bot added size/m and removed size/s labels May 5, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2023

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label May 6, 2023
@github-actions github-actions bot added size/s and removed size/m labels May 6, 2023
@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label May 6, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2023

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

@AndresCdo AndresCdo marked this pull request as ready for review May 6, 2023 11:13
@waynehamadi
Copy link
Contributor

waynehamadi commented May 6, 2023

@AndresCdo do it like that:

def get_self_feedback(self, thoughts: dict, llm_model: str) -> str:
        """Generates a feedback response based on the provided thoughts dictionary.
        This method takes in a dictionary of thoughts containing keys such as 'reasoning',
        'plan', 'thoughts', and 'criticism'. It combines these elements into a single
        feedback message and uses the create_chat_completion() function to generate a
        response based on the input message.
        Args:
            thoughts (dict): A dictionary containing thought elements like reasoning,
            plan, thoughts, and criticism.
        Returns:
            str: A feedback response generated using the provided thoughts dictionary.
        """
        ai_role = self.config.ai_role

        feedback_prompt = f"Below is a message from me, an AI Agent, assuming the role of {ai_role}. whilst keeping knowledge of my slight limitations as an AI Agent Please evaluate my thought process, reasoning, and plan, and provide a concise paragraph outlining potential improvements. Consider adding or removing ideas that do not align with my role and explaining why, prioritizing thoughts based on their significance, or simply refining my overall thought process."
        reasoning = thoughts.get("reasoning", "")
        plan = thoughts.get("plan", "")
        thought = thoughts.get("thoughts", "")
        feedback_thoughts = thought + reasoning + plan
        
        messages = {"role": "user", "content": feedback_prompt + feedback_thoughts}
        #log messages
        feedback = create_chat_completion(
            [{"role": "user", "content": feedback_prompt + feedback_thoughts}],
            llm_model,
        )
        #log feedback
        return  feedback

in autogpt/agent/agent.py

1st log call it prompt_self_feedback.json

and the second log call it self_feedback.txt

@github-actions github-actions bot added size/m and removed size/s labels May 6, 2023
@AndresCdo
Copy link
Contributor Author

1st log call it prompt_self_feedback.json

and the second log call it self_feedback.txt
image

@github-actions github-actions bot added size/xl and removed size/m labels May 8, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2023

This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size

@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2023

This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size

@github-actions github-actions bot added size/m and removed size/xl labels May 8, 2023
@AndresCdo AndresCdo requested a review from waynehamadi May 8, 2023 22:18
@Boostrix
Copy link
Contributor

Boostrix commented May 9, 2023

This feature will enable the application to log its own feedback regarding its performance and decisions, providing valuable insights for future optimization and development. [...] Some of the work here may serve as a good basis for #3916 and #15

Indeed, improving self feedback (#3934) could be used as "reward" inside a fitness function (just be sure to provide a "maximize score" objective to the LLM, and pass current score to it as part of the current context).
Especially in combination with user input (human feedback):

@vercel vercel bot temporarily deployed to Preview May 10, 2023 15:23 Inactive
@vercel vercel bot temporarily deployed to Preview May 17, 2023 11:27 Inactive
@waynehamadi waynehamadi merged commit 7508e99 into Significant-Gravitas:master May 17, 2023
ppetermann pushed a commit to ppetermann/Auto-GPT that referenced this pull request May 22, 2023
…Gravitas#3868)

* Adds SELF_FEEDBACK_FILE_NAME

* Add self-feedback logging to logs/Debug folder

* Reformatting

* Uses JSON file

* Update agent.py

Changes position

* Update agent.py

* Adds PROMPT_FEEDBACK_FILE_NAME

* Update agent.py

* Update agent.py

* Reformatting

* Update agent.py

* Update agent.py

* Changes file names

* Update agent.py

* Reformatting

* Update agent.py

* Changes conts names

* Update agent_manager.py

* Update agent_manager.py

* HARD reset

* Update test_get_self_feedback.py

* Update test_get_self_feedback.py

---------

Co-authored-by: merwanehamadi <[email protected]>
@ntindle ntindle added this to the v0.4.0 Release milestone May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants