From b43ec689093cd7a24eddcc91d700e678fb62e022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BC=9F=E9=9F=AC?= Date: Sat, 12 Oct 2024 16:09:27 +0800 Subject: [PATCH 1/5] fix deploer can not serialize --- metagpt/roles/di/engineer2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metagpt/roles/di/engineer2.py b/metagpt/roles/di/engineer2.py index 2fb9d05ee..6776fdf3a 100644 --- a/metagpt/roles/di/engineer2.py +++ b/metagpt/roles/di/engineer2.py @@ -34,7 +34,7 @@ class Engineer2(RoleZero): goal: str = "Take on game, app, and web development." instruction: str = ENGINEER2_INSTRUCTION terminal: Terminal = Field(default_factory=Terminal, exclude=True) - deployer: Deployer = Field(default_factory=Deployer) + deployer: Deployer = Field(default_factory=Deployer, exclude=True) tools: list[str] = [ "Plan", "Editor", From c280fcd885cde8e4ffa45b64bc9ff6f0cf5e7fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BC=9F=E9=9F=AC?= Date: Sat, 12 Oct 2024 16:24:26 +0800 Subject: [PATCH 2/5] fix delopy path --- metagpt/memory/role_zero_memory.py | 2 +- metagpt/roles/di/engineer2.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/metagpt/memory/role_zero_memory.py b/metagpt/memory/role_zero_memory.py index 6e59af3ec..5c7fb94a2 100644 --- a/metagpt/memory/role_zero_memory.py +++ b/metagpt/memory/role_zero_memory.py @@ -129,7 +129,7 @@ class RoleZeroLongTermMemory(Memory): If adding long-term memory fails, it will only log the error without interrupting program execution. """ - if not item or not item.message.content: + if not item: return self.rag_engine.add_objs([item]) diff --git a/metagpt/roles/di/engineer2.py b/metagpt/roles/di/engineer2.py index 6776fdf3a..d218dd666 100644 --- a/metagpt/roles/di/engineer2.py +++ b/metagpt/roles/di/engineer2.py @@ -88,7 +88,7 @@ class Engineer2(RoleZero): "Terminal.run_command": self._eval_terminal_run, "RoleZero.ask_human": self._end, "RoleZero.reply_to_human": self._end, - "Deployer.deploy_to_public": self.deployer.deploy_to_public, + "Deployer.deploy_to_public": self.deploy_to_public, } ) else: @@ -140,6 +140,12 @@ class Engineer2(RoleZero): # TODO: Consider adding line no to be ready for editing. return f"The file {path} has been successfully created, with content:\n{code}" + def deploy_to_public(self, dist_dir): + """fix the path to absolute path""" + # fix the path according to the editor's working directory + dist_dir = self.editor._try_fix_path(dist_dir) + return self.deployer.deploy_to_public(dist_dir) + async def _eval_terminal_run(self, cmd): """change command pull/push/commit to end.""" if any([cmd_key_word in cmd for cmd_key_word in ["pull", "push", "commit"]]): From 253853ef8ef932660dfd485ed13c5ae4ba9906ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BC=9F=E9=9F=AC?= Date: Sat, 12 Oct 2024 16:28:37 +0800 Subject: [PATCH 3/5] add --- metagpt/roles/di/engineer2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metagpt/roles/di/engineer2.py b/metagpt/roles/di/engineer2.py index d218dd666..6f3dcd149 100644 --- a/metagpt/roles/di/engineer2.py +++ b/metagpt/roles/di/engineer2.py @@ -101,7 +101,7 @@ class Engineer2(RoleZero): "CodeReview.review": cr.review, "CodeReview.fix": cr.fix, "Terminal.run_command": self.terminal.run_command, - "Deployer.deploy_to_public": self.deployer.deploy_to_public, + "Deployer.deploy_to_public": self.deploy_to_public, } ) From b9cfc29e3134f5692cd185ee8388a244e52ce7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BC=9F=E9=9F=AC?= Date: Sat, 12 Oct 2024 16:33:40 +0800 Subject: [PATCH 4/5] fix typo --- metagpt/roles/di/engineer2.py | 3 +-- metagpt/tools/libs/deployer.py | 2 +- metagpt/tools/libs/terminal.py | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/metagpt/roles/di/engineer2.py b/metagpt/roles/di/engineer2.py index 6f3dcd149..beb240a66 100644 --- a/metagpt/roles/di/engineer2.py +++ b/metagpt/roles/di/engineer2.py @@ -141,8 +141,7 @@ class Engineer2(RoleZero): return f"The file {path} has been successfully created, with content:\n{code}" def deploy_to_public(self, dist_dir): - """fix the path to absolute path""" - # fix the path according to the editor's working directory + """fix the dist_dir path to absolute path before deploying""" dist_dir = self.editor._try_fix_path(dist_dir) return self.deployer.deploy_to_public(dist_dir) diff --git a/metagpt/tools/libs/deployer.py b/metagpt/tools/libs/deployer.py index 4f1ac0ecf..2b4d996d1 100644 --- a/metagpt/tools/libs/deployer.py +++ b/metagpt/tools/libs/deployer.py @@ -12,7 +12,7 @@ class Deployer: async def static_server(self, src_path: str) -> str: """This function will be implemented in the remote service.""" - return f"http://127.0.0.1:{8000}/index.html" + return "http://127.0.0.1:8000/index.html" async def deploy_to_public(self, dist_dir: str): """ diff --git a/metagpt/tools/libs/terminal.py b/metagpt/tools/libs/terminal.py index 0150e26e6..e8eeb363c 100644 --- a/metagpt/tools/libs/terminal.py +++ b/metagpt/tools/libs/terminal.py @@ -68,10 +68,10 @@ class Terminal: output = "" # Remove forbidden commands for cmd_name, reason in self.forbidden_commands.items(): - # 'true' is a pass command in linux terminal. + # "true" is a pass command in linux terminal. if cmd_name in cmd: cmd = cmd.replace(cmd_name, "true") - output += f"{cmd_name} is failed to executed. {reason}\n" + output += f"Failed to execut {cmd_name}. {reason}\n" # Send the command self.process.stdin.write((cmd + self.command_terminator).encode()) From 155da2df4010afdb625f5647bdfd1f205762fab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BC=9F=E9=9F=AC?= Date: Sat, 12 Oct 2024 16:36:43 +0800 Subject: [PATCH 5/5] fix typo --- metagpt/memory/role_zero_memory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metagpt/memory/role_zero_memory.py b/metagpt/memory/role_zero_memory.py index 5c7fb94a2..6e59af3ec 100644 --- a/metagpt/memory/role_zero_memory.py +++ b/metagpt/memory/role_zero_memory.py @@ -129,7 +129,7 @@ class RoleZeroLongTermMemory(Memory): If adding long-term memory fails, it will only log the error without interrupting program execution. """ - if not item: + if not item or not item.message.content: return self.rag_engine.add_objs([item])