From acee87d01b9e20ba56181f58d1c36ea264aceb55 Mon Sep 17 00:00:00 2001 From: lidanyang Date: Fri, 19 Jul 2024 11:05:02 +0800 Subject: [PATCH 1/2] move extra instruction to DA --- metagpt/prompts/di/data_analyst.py | 6 ++++-- metagpt/prompts/di/role_zero.py | 2 -- metagpt/roles/di/data_analyst.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/metagpt/prompts/di/data_analyst.py b/metagpt/prompts/di/data_analyst.py index 56ae0b68b..b1e2367c5 100644 --- a/metagpt/prompts/di/data_analyst.py +++ b/metagpt/prompts/di/data_analyst.py @@ -1,7 +1,9 @@ from metagpt.strategy.task_type import TaskType -BROWSER_INSTRUCTION = """ -4. Carefully choose to use or not use the browser tool to assist you in web tasks. +EXTRA_INSTRUCTION = """ +4. Don't forget to append task first when all existing tasks are finished and new tasks are required. +5. Avoid repeating tasks you have already completed. And end loop when all requirements are met. +6. Carefully choose to use or not use the browser tool to assist you in web tasks. - When no click action is required, no need to use the browser tool to navigate to the webpage before scraping. - If you need detail HTML content, write code to get it but not to use the browser tool. - Make sure the command_name are certainly in Available Commands when you use the browser tool. diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index 408bb838d..4423c0d22 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -7,8 +7,6 @@ Note: 1. If you keeping encountering errors, unexpected situation, or you are not sure of proceeding, use RoleZero.ask_human to ask for help. 2. Carefully review your progress at the current task, if your actions so far has not fulfilled the task instruction, you should continue with current task. Otherwise, finish current task by Plan.finish_current_task explicitly. 3. Each time you finish a task, use RoleZero.reply_to_human to report your progress. -4. Don't forget to append task first when all existing tasks are finished and new tasks are required. -5. Avoid repeating tasks you have already completed. And end loop when all requirements are met. """ # To ensure compatibility with hard-coded experience, do not add any other content between "# Example" and "# Available Commands". CMD_PROMPT = """ diff --git a/metagpt/roles/di/data_analyst.py b/metagpt/roles/di/data_analyst.py index c52127527..694e42de3 100644 --- a/metagpt/roles/di/data_analyst.py +++ b/metagpt/roles/di/data_analyst.py @@ -8,7 +8,7 @@ from pydantic import Field, model_validator from metagpt.actions.di.execute_nb_code import ExecuteNbCode from metagpt.actions.di.write_analysis_code import WriteAnalysisCode from metagpt.logs import logger -from metagpt.prompts.di.data_analyst import BROWSER_INSTRUCTION, TASK_TYPE_DESC, CODE_STATUS, BROWSER_INFO +from metagpt.prompts.di.data_analyst import EXTRA_INSTRUCTION, TASK_TYPE_DESC, CODE_STATUS, BROWSER_INFO from metagpt.prompts.di.role_zero import ROLE_INSTRUCTION from metagpt.roles.di.role_zero import RoleZero from metagpt.schema import TaskResult, Message @@ -22,7 +22,7 @@ class DataAnalyst(RoleZero): name: str = "David" profile: str = "DataAnalyst" goal: str = "Take on any data-related tasks, such as data analysis, machine learning, deep learning, web browsing, web scraping, web searching, web deployment, terminal operation, git and github operation, etc." - instruction: str = ROLE_INSTRUCTION + BROWSER_INSTRUCTION + instruction: str = ROLE_INSTRUCTION + EXTRA_INSTRUCTION task_type_desc: str = TASK_TYPE_DESC tools: list[str] = ["Plan", "DataAnalyst", "RoleZero", "Browser"] From 976df80074b362a5a315286a55f241199637cf65 Mon Sep 17 00:00:00 2001 From: lidanyang Date: Fri, 19 Jul 2024 11:45:48 +0800 Subject: [PATCH 2/2] refine prompt --- metagpt/prompts/di/data_analyst.py | 3 +-- metagpt/prompts/di/role_zero.py | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/metagpt/prompts/di/data_analyst.py b/metagpt/prompts/di/data_analyst.py index b1e2367c5..8a22a5d14 100644 --- a/metagpt/prompts/di/data_analyst.py +++ b/metagpt/prompts/di/data_analyst.py @@ -1,12 +1,11 @@ from metagpt.strategy.task_type import TaskType EXTRA_INSTRUCTION = """ -4. Don't forget to append task first when all existing tasks are finished and new tasks are required. -5. Avoid repeating tasks you have already completed. And end loop when all requirements are met. 6. Carefully choose to use or not use the browser tool to assist you in web tasks. - When no click action is required, no need to use the browser tool to navigate to the webpage before scraping. - If you need detail HTML content, write code to get it but not to use the browser tool. - Make sure the command_name are certainly in Available Commands when you use the browser tool. +7. When you are making plan. It is highly recommend to plan all the coding plan and reviews plan in first response. """ TASK_TYPE_DESC = "\n".join([f"- **{tt.type_name}**: {tt.value.desc}" for tt in TaskType]) diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index 4423c0d22..408bb838d 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -7,6 +7,8 @@ Note: 1. If you keeping encountering errors, unexpected situation, or you are not sure of proceeding, use RoleZero.ask_human to ask for help. 2. Carefully review your progress at the current task, if your actions so far has not fulfilled the task instruction, you should continue with current task. Otherwise, finish current task by Plan.finish_current_task explicitly. 3. Each time you finish a task, use RoleZero.reply_to_human to report your progress. +4. Don't forget to append task first when all existing tasks are finished and new tasks are required. +5. Avoid repeating tasks you have already completed. And end loop when all requirements are met. """ # To ensure compatibility with hard-coded experience, do not add any other content between "# Example" and "# Available Commands". CMD_PROMPT = """