mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-11 15:15:18 +02:00
Merge branch 'fix/deployer_can_not_serialisze' into 'mgx_ops'
Fix/deployer can not serialisze See merge request pub/MetaGPT!395
This commit is contained in:
commit
6ae3317f25
3 changed files with 11 additions and 6 deletions
|
|
@ -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",
|
||||
|
|
@ -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:
|
||||
|
|
@ -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,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -140,6 +140,11 @@ 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 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)
|
||||
|
||||
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"]]):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue