From 5c758facc509b400525dc50163433e8293301c14 Mon Sep 17 00:00:00 2001 From: lidanyang Date: Thu, 18 Jul 2024 17:22:18 +0800 Subject: [PATCH] refine prompt --- metagpt/prompts/di/role_zero.py | 4 ++-- metagpt/prompts/task_type.py | 2 +- metagpt/strategy/experience_retriever.py | 10 ++-------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index 5f5178aee..0037d9384 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -8,7 +8,7 @@ Note: 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. Don't repeat the same command if it has been executed successfully. +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 = """ @@ -44,7 +44,7 @@ You may use any of the available commands to create a plan or update the plan. Y If you finish current task, you will automatically take the next task in the existing plan, use Plan.finish_task, DON'T append a new task. # Your commands in a json array, in the following output format with correct command_name and args. If there is nothing to do, use the pass or end command: -Some text indicating your thoughts, such as how you should update the plan status, respond to inquiry, or seek for help. Then a json array of commands. You must output ONE and ONLY ONE json array. DON'T output multiple json arrays with thoughts between them. +Some text indicating your thoughts before JSON is required, such as what tasks have been completed, what tasks are next, how you should update the plan status, respond to inquiry, or seek for help. Then a json array of commands. You must output ONE and ONLY ONE json array. DON'T output multiple json arrays with thoughts between them. ```json [ {{ diff --git a/metagpt/prompts/task_type.py b/metagpt/prompts/task_type.py index 312421c21..2e4af4c1d 100644 --- a/metagpt/prompts/task_type.py +++ b/metagpt/prompts/task_type.py @@ -56,6 +56,6 @@ The current task is about converting image into webpage code. please note the fo # Prompt for taking on "web_scraping" tasks WEB_SCRAPING_PROMPT = """ -- Remember to view and print the necessary HTML content in a separate task to understand the structure first before scraping data. +- Remember to view and print the necessary HTML content in a separate task to understand the structure first before scraping data. Such as `html_content = await view_page_element_to_scrape(...)\nprint(html_content)`. - Since the data required by user may not correspond directly to the actual HTML element names, you should thoroughly analyze the HTML structure and meanings of all elements in the executing result first. Ensure the `class_` in your code should derived from the actual HTML structure directly, not based on your knowledge. To ensure it, analyse the most suitable location of the 'class_' in the actual HTML content before code. """ diff --git a/metagpt/strategy/experience_retriever.py b/metagpt/strategy/experience_retriever.py index f667f03a5..e9adb6f10 100644 --- a/metagpt/strategy/experience_retriever.py +++ b/metagpt/strategy/experience_retriever.py @@ -944,7 +944,6 @@ Explanation: The requirement is to scrape data from a website and extract inform ## action 2 Explanation: To search for restaurants, I will now go to the website https://www.yelp.com/ first. -Here is the command to navigate to the website: ```json [ @@ -959,7 +958,6 @@ Here is the command to navigate to the website: ## action 3 Explanation: Since the Browser has successfully navigated to the website, and I find that the element id of the search box is 53. I will finish the current task and then use the Browser tool to type the keyword `beef` in the search box and press enter. -Here is the command to finish the current task and type the keyword: ```json [ @@ -980,7 +978,6 @@ Here is the command to finish the current task and type the keyword: ## action 4 Explanation: Since the Browser has successfully search the keyword `beef`, I will finish the current task and then write code to view the html content of the page. -Here is the command to finish the current task and view the html content: ```json [ @@ -996,8 +993,7 @@ Here is the command to finish the current task and view the html content: ``` ## action 5 -Explanation: Since the DataAnalyst has successfully viewed the html content of the page, I will finish the current task and then write code to parse the html content and extract the restaurant names. -Here is the command to finish the current task and parse the html content: +Explanation: Since I has successfully viewed the html content in the context, I will first finish the current task and then write code to parse the html content and extract the restaurant names. ```json [ @@ -1045,7 +1041,6 @@ Explanation: The requirement is to scrape data from a website and extract inform ## action 2 Explanation: To scrap data from the website, I will first view the html content of the page. -Here is the command to view the html content: ```json [ @@ -1057,8 +1052,7 @@ Here is the command to view the html content: ``` ## action 3 -Explanation: Since the DataAnalyst has successfully viewed the html content of the page, I will finish the current task and then write code to parse the html content and extract the restaurant names. -Here is the command to finish the current task and parse the html content: +Explanation: Since I has successfully viewed the html content in the context, I will first finish the current task and then write code to parse the html content and extract the restaurant names. ```json [