mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-21 14:05:17 +02:00
feat: merge RFC 135
This commit is contained in:
commit
59d97c77e8
3 changed files with 3 additions and 92 deletions
|
|
@ -70,96 +70,6 @@ class Engineer(Role):
|
|||
m = json.loads(task_msg.content)
|
||||
return m.get("Task list")
|
||||
|
||||
# @classmethod
|
||||
# def parse_tasks(cls, task_msg: Message) -> list[str]:
|
||||
# if task_msg.instruct_content:
|
||||
# return task_msg.instruct_content.dict().get("Task list")
|
||||
# return CodeParser.parse_file_list(block="Task list", text=task_msg.content)
|
||||
#
|
||||
# @classmethod
|
||||
# def parse_code(cls, code_text: str) -> str:
|
||||
# return CodeParser.parse_code(block="", text=code_text)
|
||||
#
|
||||
# @classmethod
|
||||
# def parse_workspace(cls, system_design_msg: Message) -> str:
|
||||
# if system_design_msg.instruct_content:
|
||||
# return system_design_msg.instruct_content.dict().get("project_name").strip().strip("'").strip('"')
|
||||
# return CodeParser.parse_str(block="project_name", text=system_design_msg.content)
|
||||
#
|
||||
# def get_workspace(self) -> Path:
|
||||
# msg = self._rc.memory.get_by_action(WriteDesign)[-1]
|
||||
# if not msg:
|
||||
# return CONFIG.workspace_path / "src"
|
||||
# workspace = self.parse_workspace(msg)
|
||||
# # Codes are written in workspace/{package_name}/{package_name}
|
||||
# return CONFIG.workspace_path / workspace / workspace
|
||||
#
|
||||
# def recreate_workspace(self):
|
||||
# workspace = self.get_workspace()
|
||||
# try:
|
||||
# shutil.rmtree(workspace)
|
||||
# except FileNotFoundError:
|
||||
# pass # The folder does not exist, but we don't care
|
||||
# workspace.mkdir(parents=True, exist_ok=True)
|
||||
#
|
||||
# def write_file(self, filename: str, code: str):
|
||||
# workspace = self.get_workspace()
|
||||
# filename = filename.replace('"', "").replace("\n", "")
|
||||
# file = workspace / filename
|
||||
# file.parent.mkdir(parents=True, exist_ok=True)
|
||||
# file.write_text(code)
|
||||
# return file
|
||||
#
|
||||
# def recv(self, message: Message) -> None:
|
||||
# self._rc.memory.add(message)
|
||||
# if message in self._rc.important_memory:
|
||||
# self.todos = self.parse_tasks(message)
|
||||
#
|
||||
# async def _act_mp(self) -> Message:
|
||||
# # self.recreate_workspace()
|
||||
# todo_coros = []
|
||||
# for todo in self.todos:
|
||||
# todo_coro = WriteCode().run(
|
||||
# context=self._rc.memory.get_by_actions([WriteTasks, WriteDesign]), filename=todo
|
||||
# )
|
||||
# todo_coros.append(todo_coro)
|
||||
#
|
||||
# rsps = await gather_ordered_k(todo_coros, self.n_borg)
|
||||
# for todo, code_rsp in zip(self.todos, rsps):
|
||||
# _ = self.parse_code(code_rsp)
|
||||
# logger.info(todo)
|
||||
# logger.info(code_rsp)
|
||||
# # self.write_file(todo, code)
|
||||
# msg = Message(content=code_rsp, role=self.profile, cause_by=type(self._rc.todo))
|
||||
# self._rc.memory.add(msg)
|
||||
# del self.todos[0]
|
||||
#
|
||||
# logger.info(f"Done {self.get_workspace()} generating.")
|
||||
# msg = Message(content="all done.", role=self.profile, cause_by=type(self._rc.todo))
|
||||
# return msg
|
||||
#
|
||||
# async def _act_sp(self) -> Message:
|
||||
# code_msg_all = [] # gather all code info, will pass to qa_engineer for tests later
|
||||
# for todo in self.todos:
|
||||
# code = await WriteCode().run(context=self._rc.history, filename=todo)
|
||||
# # logger.info(todo)
|
||||
# # logger.info(code_rsp)
|
||||
# # code = self.parse_code(code_rsp)
|
||||
# file_path = self.write_file(todo, code)
|
||||
# msg = Message(content=code, role=self.profile, cause_by=type(self._rc.todo))
|
||||
# self._rc.memory.add(msg)
|
||||
#
|
||||
# code_msg = todo + FILENAME_CODE_SEP + str(file_path)
|
||||
# code_msg_all.append(code_msg)
|
||||
#
|
||||
# logger.info(f"Done {self.get_workspace()} generating.")
|
||||
# msg = Message(
|
||||
# content=MSG_SEP.join(code_msg_all), role=self.profile, cause_by=type(self._rc.todo), send_to="QaEngineer"
|
||||
# )
|
||||
# return msg
|
||||
|
||||
# async def _act_sp_with_cr(self) -> Message:
|
||||
# code_msg_all = [] # gather all code info, will pass to qa_engineer for tests later
|
||||
async def _act_sp_with_cr(self, review=False) -> Set[str]:
|
||||
changed_files = set()
|
||||
src_file_repo = CONFIG.git_repo.new_file_repository(CONFIG.src_workspace)
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ class Role:
|
|||
)
|
||||
else:
|
||||
msg = Message(content=response, role=self.profile, cause_by=self._rc.todo)
|
||||
self._rc.memory.add(msg)
|
||||
|
||||
return msg
|
||||
|
||||
|
|
@ -295,9 +296,10 @@ class Role:
|
|||
# Read unprocessed messages from the msg buffer.
|
||||
news = self._rc.msg_buffer.pop_all()
|
||||
# Store the read messages in your own memory to prevent duplicate processing.
|
||||
old_messages = self._rc.memory.get()
|
||||
self._rc.memory.add_batch(news)
|
||||
# Filter out messages of interest.
|
||||
self._rc.news = [n for n in news if n.cause_by in self._rc.watch]
|
||||
self._rc.news = [n for n in news if n.cause_by in self._rc.watch and n not in old_messages]
|
||||
|
||||
# Design Rules:
|
||||
# If you need to further categorize Message objects, you can do so using the Message.set_meta function.
|
||||
|
|
|
|||
|
|
@ -74,5 +74,4 @@ class SkAgent(Role):
|
|||
|
||||
msg = Message(content=result, role=self.profile, cause_by=self._rc.todo)
|
||||
self._rc.memory.add(msg)
|
||||
self.publish_message(msg)
|
||||
return msg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue