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
Adding a mechanism for self-improvement #353
base: main
Are you sure you want to change the base?
Conversation
Excellent! It seems that the HANDOVER_FILE is necessary. Could you kindly provide it as well? |
"QaEngineer": {"name": "Edward", "next": None, "prev": "Engineer"}, | ||
} | ||
|
||
def print_with_color(text, color="red"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
place it in utils
print(f"{color_codes[color]} {text} {color_codes['reset']}") | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8
""" | ||
|
||
async def run(self, handover_msg, *args, **kwargs) -> ActionOutput: | ||
import re |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import it in file header
import re | ||
#prev_role = handover_msg[0].to_dict()["role"] | ||
#prev_msg = handover_msg[0].to_dict()["content"] | ||
if isinstance(handover_msg, list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dup space
@@ -38,6 +38,22 @@ def invest(self, investment: float): | |||
CONFIG.max_budget = investment | |||
logger.info(f'Investment: ${investment}.') | |||
|
|||
def improvement(self, initial=False, roles=None): | |||
handover_file = CONFIG.handover_file | |||
if initial: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to do this in CONFIG?
msgs = self.environment.memory.get_by_action(Feedback) | ||
if isinstance(msgs, list): | ||
for msg in msgs: | ||
logger.info(f"{msg.role}'s feedback: {msg.content}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually prints the feedback result, which is different from the function name. Should we optimize the function name?
Now, rewrite your "{role}" constraints in 30 words: | ||
""" | ||
|
||
# def print_with_color(text, color="red"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove useless comments
# } | ||
# print(f"{color_codes[color]} {text} {color_codes['reset']}") | ||
|
||
class Reflect(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class Reflect
instead of class Reflect()
class Reflect(): | ||
def from_feedback(role, constraints): | ||
|
||
chat = OpenAIGPTAPI() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use LLM instead
|
||
if run_tests: | ||
# developing features: run tests on the spot and identify bugs | ||
# (bug fixing capability comes soon!) | ||
company.hire([QaEngineer()]) | ||
|
||
company.invest(investment) | ||
|
||
if self_improvement: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need add this first, before hire()
Summary of Updates
1️⃣ Internal Feedback Action:
Added the Feedback action in
metagpt/actions/internal_feedback.py
to allow internal evaluation among agents (currently supporting the handover process).2️⃣ Action Functions Enhancement:
Introduced two new methods,
_add_action_at_head()
and_add_action_at_tail()
, for improved clarity and ease of defining actions.3️⃣ Long-Term Memory Utilization:
Commenced utilization of the previously underutilized
longterm_memory
, currently supporting storage in a JSON file. Future improvements will involve leveraging existing FAISS support.4️⃣ Reflective Mechanism:
Incorporated the
reflect.py
module withinmetagpt/learn
.5️⃣ Initialization with Feedback:
Implemented feedback-driven constraints initialization during role setup, marking the initial phase of our journey towards self-improvement.
These updates address several urgent issues, including effective long-term memory utilization, internal evaluation mechanisms, and the integration of historical data into the self-improvement mechanism. And there is still ample room for improvement beyond these updates. 😄
Quick usage:
python startup.py "Write a cli snake game" --self_improvement True
Note: Unit tests are pending implementation due to time constraints and will be added in the near days.