mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-02 12:22:39 +02:00
add Deployer tool
This commit is contained in:
parent
67e491d97a
commit
b81c00a44d
5 changed files with 73 additions and 13 deletions
|
|
@ -18,6 +18,7 @@ from metagpt.roles.di.role_zero import RoleZero
|
|||
from metagpt.schema import UserMessage
|
||||
from metagpt.strategy.experience_retriever import ENGINEER_EXAMPLE
|
||||
from metagpt.tools.libs.cr import CodeReview
|
||||
from metagpt.tools.libs.deployer import Deployer
|
||||
from metagpt.tools.libs.git import git_create_pull
|
||||
from metagpt.tools.libs.image_getter import ImageGetter
|
||||
from metagpt.tools.libs.terminal import Terminal
|
||||
|
|
@ -33,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)
|
||||
tools: list[str] = [
|
||||
"Plan",
|
||||
"Editor",
|
||||
|
|
@ -45,6 +46,7 @@ class Engineer2(RoleZero):
|
|||
"Engineer2",
|
||||
"CodeReview",
|
||||
"ImageGetter",
|
||||
"Deployer",
|
||||
]
|
||||
# SWE Agent parameter
|
||||
run_eval: bool = False
|
||||
|
|
@ -86,6 +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,
|
||||
}
|
||||
)
|
||||
else:
|
||||
|
|
@ -98,6 +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,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class RoleZero(Role):
|
|||
tools: list[str] = [] # Use special symbol ["<all>"] to indicate use of all registered tools
|
||||
tool_recommender: Optional[ToolRecommender] = None
|
||||
tool_execution_map: Annotated[dict[str, Callable], Field(exclude=True)] = {}
|
||||
special_tool_commands: list[str] = ["Plan.finish_current_task", "end", "Bash.run", "RoleZero.ask_human"]
|
||||
special_tool_commands: list[str] = ["Plan.finish_current_task", "end", "Terminal.run_command", "RoleZero.ask_human"]
|
||||
# List of exclusive tool commands.
|
||||
# If multiple instances of these commands appear, only the first occurrence will be retained.
|
||||
exclusive_tool_commands: list[str] = [
|
||||
|
|
@ -543,7 +543,10 @@ class RoleZero(Role):
|
|||
return end_output
|
||||
return human_response
|
||||
# output from bash.run may be empty, add decorations to the output to ensure visibility.
|
||||
elif cmd["command_name"] == "Bash.run":
|
||||
elif cmd["command_name"] == "Terminal.run_command":
|
||||
if "npm run dev" in cmd["args"]:
|
||||
command_output = "command run failed! Pleae use Delopyer to deploy your project after build."
|
||||
|
||||
tool_obj = self.tool_execution_map[cmd["command_name"]]
|
||||
tool_output = await tool_obj(**cmd["args"])
|
||||
if len(tool_output) <= 10:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue