This commit is contained in:
黄伟韬 2024-09-27 10:59:20 +08:00
parent 955ec263c6
commit e343def831
3 changed files with 10 additions and 16 deletions

View file

@ -119,17 +119,11 @@ END_COMMAND = """
```
"""
SUMMARY_TROUBLE = """
You are repeating the same action.
Please summarize what is confusing or troubling you, and tell me directly.
Do not output any commands.
Your response must be in {language} and should be within 30 words.
"""
DUPULICATE_QUESTTION_FORMAT = """
I meet the following trouble:
{trouble}
Could you provide me with some guidance?
If want to stop, please contain \"<STOP>\" in your guidance.
SUMMARY_PROBLEM_WHEN_DUPLICATE = """Please directly tell me what is confusing or troubling you. Your response should be in {language} and within 30 words."""
ASK_HUMAN_GUIDANCE_FORMAT = """
I am facing the following problem:
{problem}
Could you please provide me with some guidance?If you want to stop, please include "<STOP>" in your guidance.
"""
ASK_HUMAN_COMMAND = [{"command_name": "RoleZero.ask_human", "args": {"question": ""}}]

View file

@ -119,7 +119,7 @@ class Engineer2(RoleZero):
Args:
path (str): The absolute path of the file to be created.
file_description (optional, str): Further hints or notice other than the current task description, must be very concise and can be empty. Defaults to "".
file_description (optional, str): "Brief description and important notes of the file content, must be very concise and can be empty. Defaults to "".
"""
plan_status, _ = self._get_plan_status()
prompt = WRITE_CODE_PROMPT.format(

View file

@ -19,9 +19,9 @@ from metagpt.exp_pool.serializers import RoleZeroSerializer
from metagpt.logs import logger
from metagpt.prompts.di.role_zero import (
ASK_HUMAN_COMMAND,
ASK_HUMAN_GUIDANCE_FORMAT,
CMD_PROMPT,
DETECT_LANGUAGE_PROMPT,
DUPULICATE_QUESTTION_FORMAT,
END_COMMAND,
JSON_REPAIR_PROMPT,
QUICK_RESPONSE_SYSTEM_PROMPT,
@ -31,8 +31,8 @@ from metagpt.prompts.di.role_zero import (
REGENERATE_PROMPT,
REPORT_TO_HUMAN_PROMPT,
ROLE_INSTRUCTION,
SUMMARY_PROBLEM_WHEN_DUPLICATE,
SUMMARY_PROMPT,
SUMMARY_TROUBLE,
SYSTEM_PROMPT,
)
from metagpt.roles import Role
@ -401,9 +401,9 @@ class RoleZero(Role):
logger.warning(f"Duplicate response detected: {command_rsp}")
return END_COMMAND
trouble_content = await self.llm.aask(
req + [UserMessage(content=SUMMARY_TROUBLE.format(language=self.respond_language))]
req + [UserMessage(content=SUMMARY_PROBLEM_WHEN_DUPLICATE.format(language=self.respond_language))]
)
ASK_HUMAN_COMMAND[0]["args"]["question"] = DUPULICATE_QUESTTION_FORMAT.format(trouble=trouble_content)
ASK_HUMAN_COMMAND[0]["args"]["question"] = ASK_HUMAN_GUIDANCE_FORMAT.format(trouble=trouble_content)
ask_human_command = "```json\n" + json.dumps(ASK_HUMAN_COMMAND, indent=4, ensure_ascii=False) + "\n```"
return ask_human_command
# Try correction by self