修改role_zero指令循环问题

This commit is contained in:
黄伟韬 2024-07-18 15:18:18 +08:00
parent 56efc6d155
commit 838892e17d
3 changed files with 2 additions and 8 deletions

View file

@ -91,7 +91,7 @@ class MGXEnv(Environment):
async def reply_to_human(self, content: str, sent_from: Role = None) -> str:
# NOTE: Can be overwritten in remote setting
return "Message send successfully."
return "The monitor has verified the message, confirmation acknowledged. Refrain from resending duplicate messages."
def message_within_software_sop(self, message: Message) -> bool:
# Engineer, QaEngineer can be end of the SOP. Their msg requires routing outside.

View file

@ -10,7 +10,6 @@ from pydantic import model_validator
from metagpt.actions import Action, UserRequirement
from metagpt.actions.di.run_command import RunCommand
from metagpt.const import DEFAULT_WORKSPACE_ROOT
from metagpt.logs import logger
from metagpt.prompts.di.role_zero import (
CMD_PROMPT,
@ -155,7 +154,6 @@ class RoleZero(Role):
)
memory = self.rc.memory.get(self.memory_k)
memory = await self.parse_browser_actions(memory)
memory = await self.add_editor_root_directory(memory)
context = self.llm.format_msg(memory + [UserMessage(content=prompt)])
# print(*context, sep="\n" + "*" * 5 + "\n")
async with ThoughtReporter(enable_llm_stream=True) as reporter:
@ -175,10 +173,6 @@ class RoleZero(Role):
self.rc.memory.add(AIMessage(content=self.command_rsp))
return True
async def add_editor_root_directory(self, memory) -> List[Message]:
memory.append(UserMessage(cause_by="editory", content=f"Root directory is {DEFAULT_WORKSPACE_ROOT}"))
return memory
async def parse_browser_actions(self, memory: List[Message]) -> List[Message]:
if not self.browser.is_empty_page:
pattern = re.compile(r"Command Browser\.(\w+) executed")

View file

@ -613,7 +613,7 @@ Explanation: The user is asking for a general update on the project status. Give
## example 4
OBSERVATION : current task is none and all task is finished.
Explanation: Last task is "Plan.finish_current_task" and now the current task is none, it means everything is done.Just coutput command "end".
Explanation: Last task is "Plan.finish_current_task" or 'RoleZero.reply_to_human' and now the current task is none, it means everything is done.Just coutput command "end".
```json
[
{