🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
hard rule to ask human
garylin209978462d519992
diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.pyindex 478f5c0d4..de1673e62 100644--- a/metagpt/prompts/di/role_zero.py+++ b/metagpt/prompts/di/role_zero.py@@ -80,6 +80,18 @@ Review and reflect on the history carefully, provide a different response.Describe if you should terminate using **end** command, or use **RoleZero.ask_human** to ask human for help, or try a different approach and output different commands. You are NOT allowed to provide the same commands again.Your reflection, then the commands in a json array:"""+ASK_HUMAN_COMMAND = """+```json+[+ {+ "command_name": "RoleZero.ask_human",+ "args": {+ "question": "I'm a little uncertain about the next step, could you provide me with some guidance?"+ }+ }+]+```+"""JSON_REPAIR_PROMPT = """## json data{json_data}diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.pyindex 6d6eb26ce..ad5c2d26a 100644--- a/metagpt/roles/di/role_zero.py+++ b/metagpt/roles/di/role_zero.py@@ -15,6 +15,7 @@ from metagpt.exp_pool.context_builders import RoleZeroContextBuilderfrom metagpt.exp_pool.serializers import RoleZeroSerializerfrom metagpt.logs import loggerfrom metagpt.prompts.di.role_zero import (+ ASK_HUMAN_COMMAND,CMD_PROMPT,JSON_REPAIR_PROMPT,QUICK_THINK_PROMPT,@@ -272,6 +273,11 @@ class RoleZero(Role):# If an identical response is detected, it is a bad response, mostly due to LLM repeating generated content# In this case, ask human for help and regenerate# TODO: switch to llm_cached_aask++ # Hard rule to ask human for help+ if past_rsp.count(command_rsp) >= 3:+ return ASK_HUMAN_COMMAND+ # Try correction by selflogger.warning(f"Duplicate response detected: {command_rsp}")regenerate_req = req + [UserMessage(content=REGENERATE_PROMPT)]regenerate_req = self.llm.format_msg(regenerate_req)