From 2479f75bcb7b170aa54fd36911e5fba89596ce64 Mon Sep 17 00:00:00 2001 From: yzlin Date: Fri, 26 Apr 2024 00:53:06 +0800 Subject: [PATCH] add args for ask_human and reply_to_human --- metagpt/environment/mgx/mgx_env.py | 5 +++-- metagpt/roles/di/team_leader.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/metagpt/environment/mgx/mgx_env.py b/metagpt/environment/mgx/mgx_env.py index 17b479679..ae97d72f6 100644 --- a/metagpt/environment/mgx/mgx_env.py +++ b/metagpt/environment/mgx/mgx_env.py @@ -14,6 +14,7 @@ from metagpt.roles import ( ProductManager, ProjectManager, QaEngineer, + Role, ) from metagpt.schema import Message from metagpt.utils.common import any_to_str, any_to_str_set @@ -58,11 +59,11 @@ class MGXEnv(Environment): return True - async def ask_human(self, question: str) -> str: + async def ask_human(self, question: str, sent_from: Role = None) -> str: # NOTE: Can be overwritten in remote setting return get_human_input(question) - async def reply_to_human(self, content: str) -> str: + async def reply_to_human(self, content: str, sent_from: Role = None) -> str: # NOTE: Can be overwritten in remote setting return content diff --git a/metagpt/roles/di/team_leader.py b/metagpt/roles/di/team_leader.py index 0034a9eef..346535308 100644 --- a/metagpt/roles/di/team_leader.py +++ b/metagpt/roles/di/team_leader.py @@ -44,9 +44,9 @@ class TeamLeader(Role): if cmd["command_name"] == Command.PUBLISH_MESSAGE.cmd_name: self.publish_message(Message(**cmd["args"])) elif cmd["command_name"] == Command.ASK_HUMAN.cmd_name: - self.rc.env.ask_human(**cmd["args"]) + self.rc.env.ask_human(sent_from=self, **cmd["args"]) elif cmd["command_name"] == Command.REPLY_TO_HUMAN.cmd_name: - self.rc.env.reply_to_human(**cmd["args"]) + self.rc.env.reply_to_human(sent_from=self, **cmd["args"]) def _run_internal_command(self, cmd): if cmd["command_name"] == Command.APPEND_TASK.cmd_name: