From c4bd06dcb8c062fca4c8be1948c6fdaa0eff47d3 Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Mon, 12 Aug 2024 18:16:16 +0800 Subject: [PATCH 01/13] limit outputs to be only thought and response category --- metagpt/prompts/di/role_zero.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index 765825198..ef71f5f85 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -133,7 +133,9 @@ For requests that are unclear, lack sufficient detail, or are outside the system {examples} -Respond with a concise thought, then provide the appropriate response category: QUICK, SEARCH, TASK, or AMBIGUOUS. Your response: +Respond with a concise thought, then provide the appropriate response category: QUICK, SEARCH, TASK, or AMBIGUOUS. +You should **only** provide the thought, response category, and nothing else. +Your response: """ From 7b49e4db381d179568401fc18213bc4a035f6bcf Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Mon, 12 Aug 2024 19:00:50 +0800 Subject: [PATCH 02/13] limit quickthink output --- metagpt/prompts/di/role_zero.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index cc593b434..895424e07 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -149,7 +149,7 @@ For requests that are unclear, lack sufficient detail, or are outside the system {examples} Respond with a concise thought, then provide the appropriate response category: QUICK, SEARCH, TASK, or AMBIGUOUS. -You should **only** provide the thought, response category, and nothing else. +Important: You should **only** provide the thought, response category, and nothing else. Your response: """ From b8f05f582762264361cea2cedc21a92bdf03ba62 Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Tue, 13 Aug 2024 16:17:12 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E5=B0=86quick=20think=20prompt=E6=94=B9?= =?UTF-8?q?=E4=B8=BAsystem=20prompt=EF=BC=8C=E5=87=8F=E5=B0=91request?= =?UTF-8?q?=E7=A6=BB=E7=BB=93=E5=B0=BE=E7=9A=84=E8=B7=9D=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/prompts/di/role_zero.py | 47 ++++++++++++++++++++------------ metagpt/roles/di/data_analyst.py | 2 +- metagpt/roles/di/role_zero.py | 8 +++++- metagpt/roles/di/team_leader.py | 10 ++++--- 4 files changed, 43 insertions(+), 24 deletions(-) diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index 895424e07..1a340cdef 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -125,32 +125,45 @@ If no issues are detected, the original json data should be returned unchanged. Output the JSON data in a format that can be loaded by the json.loads() function. """ -QUICK_THINK_PROMPT = """ +QUICK_THINK_SYSTEM_PROMPT = """ +Your role is to determine the appropriate response category for the given request. + # Response Categories ## QUICK: -For straightforward questions or requests that can be answered directly. This includes common-sense inquiries, legal or logical questions, basic math, short coding tasks, multiple-choice questions, greetings, casual chat, and inquiries about you or your team. +For straightforward questions or requests that can be answered directly. This includes common-sense inquiries, legal or logical questions, basic math, short coding tasks, multiple-choice questions, greetings, casual chat, schedule planning, and inquiries about you or your team. ## SEARCH For queries that require retrieving up-to-date or detailed information. This includes time-sensitive or location-specific questions like current events or weather. Use this only if the information isn't readily available. ## TASK -For complex requests that involve multiple steps or detailed instructions. Examples include software development, project planning, or any task that requires a sequence of actions. +For complex requests that involve tool utilizations, multiple steps or detailed instructions. Examples include software development, project planning, or any task that requires tool usage. ## AMBIGUOUS For requests that are unclear, lack sufficient detail, or are outside the system's capabilities. Common characteristics of AMBIGUOUS requests: -- Incomplete Information: Requests that imply complex tasks but lack critical details (e.g., "Redesign this logo" without providing the original logo or specifying design requirements). +- Incomplete Information: Requests that imply complex tasks but lack critical details (e.g., "Redesign this logo" without specifying design requirements). - Vagueness: Broad, unspecified, or unclear requests that make it difficult to provide a precise answer. -- Out of Expertise: Requests for specialized advice (e.g., medical or legal advice) or highly technical tasks beyond the model's scope. - Unrealistic Scope: Overly broad requests that are impossible to address meaningfully in a single response (e.g., "Tell me everything about..."). +- Missing files: Requests that refer to specific documents, images, or data without providing them for reference. (when providing a file, website, or data, either the content, link, or path **must** be included) -**Note:** Before categorizing a request as TASK, consider whether the user has provided sufficient information to proceed with the task. If the request is complex but lacks essential details or the mentioned files, it should fall under AMBIGUOUS. +**Note:** Before categorizing a request as TASK: +1. Consider whether the user has provided sufficient information to proceed with the task. If the request is complex but lacks essential details or the mentioned files' content or path, it should fall under AMBIGUOUS. +2. If the request is a "how-to" question that asks for a general approach or strategy, it should be categorized as QUICK. +3. Writing a travel/learning plan or providing a general outline should be categorized as **QUICK* because it doesn't involve detailed instructions or tool usage. {examples} +""" +QUICK_THINK_PROMPT = """ +# Instruction +Determine the previous message's intent. Respond with a concise thought, then provide the appropriate response category: QUICK, SEARCH, TASK, or AMBIGUOUS. -Important: You should **only** provide the thought, response category, and nothing else. -Your response: + +# Format +Thought: [Your thought here] +Response Category: [QUICK/SEARCH/TASK/AMBIGUOUS] + +# Response: """ @@ -166,7 +179,7 @@ Thought: This is a general knowledge question that can be answered concisely. Response Category: QUICK. 3. Request: "Can you help me plan a healthy diet for a week?" -Thought: The user is requesting a simple plan that can be provided immediately. +Thought: Writing a diet plan is a general task that can be answered directly. Response Category: QUICK. 4. Request: "Can you help me find the latest research papers on deep learning?" @@ -178,18 +191,16 @@ Thought: This is a detailed software development task that requires multiple ste Response Category: TASK. 6. Request: "Summarize this document for me." -Thought: The request mentions summarizing a document but doesn't provide the document itself, making it impossible to fulfill. +Thought: The request mentions summarizing a document but doesn't provide the path or content of the document, making it impossible to fulfill. Response Category: AMBIGUOUS. -7. Request: "Optimize this process." +7. Request: "Summarize this document for me '/data/path/docmument.pdf'." +Thought: The request mentions summarizing a document and has provided the path to the document. It can be done by reading the document using a tool then summarizing it. +Response Category: TASK. + +8. Request: "Optimize this process." Thought: The request is vague and lacks specifics, requiring clarification on the process to optimize. Response Category: AMBIGUOUS. -8. Request: "Create a poster for our upcoming event." -Thought: Critical details like event theme, date, and location are missing, making it impossible to complete the task. -Response Category: AMBIGUOUS. - -# Instruction """ - -QUICK_THINK_PROMPT = QUICK_THINK_PROMPT.format(examples=QUICK_THINK_EXAMPLES) \ No newline at end of file +# QUICK_THINK_EXAMPLES = "" \ No newline at end of file diff --git a/metagpt/roles/di/data_analyst.py b/metagpt/roles/di/data_analyst.py index f65042217..78f0b3040 100644 --- a/metagpt/roles/di/data_analyst.py +++ b/metagpt/roles/di/data_analyst.py @@ -30,7 +30,7 @@ class DataAnalyst(RoleZero): instruction: str = ROLE_INSTRUCTION + EXTRA_INSTRUCTION task_type_desc: str = TASK_TYPE_DESC - tools: list[str] = ["Plan", "DataAnalyst", "RoleZero", "Browser"] + tools: list[str] = ["Plan", "DataAnalyst", "RoleZero", "Browser", "Editor:write,read"] custom_tools: list[str] = ["web scraping", "Terminal"] custom_tool_recommender: ToolRecommender = None experience_retriever: Annotated[ExpRetriever, Field(exclude=True)] = KeywordExpRetriever() diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.py index 8d46b9c02..7cdd9bdea 100644 --- a/metagpt/roles/di/role_zero.py +++ b/metagpt/roles/di/role_zero.py @@ -21,6 +21,8 @@ from metagpt.prompts.di.role_zero import ( CMD_PROMPT, JSON_REPAIR_PROMPT, QUICK_THINK_PROMPT, + QUICK_THINK_EXAMPLES, + QUICK_THINK_SYSTEM_PROMPT, REGENERATE_PROMPT, ROLE_INSTRUCTION, SYSTEM_PROMPT, @@ -249,6 +251,10 @@ class RoleZero(Role): rsp = await self._act() actions_taken += 1 return rsp # return output from the last action + + def format_quick_system_prompt(self) -> str: + """Format the system prompt for quick thinking.""" + return QUICK_THINK_SYSTEM_PROMPT.format(examples=QUICK_THINK_EXAMPLES) async def _quick_think(self) -> Tuple[Message, str]: answer = "" @@ -260,7 +266,7 @@ class RoleZero(Role): # routing memory = self.get_memories(k=4) # FIXME: A magic number for two rounds of Q&A context = self.llm.format_msg(memory + [UserMessage(content=QUICK_THINK_PROMPT)]) - intent_result = await self.llm.aask(context) + intent_result = await self.llm.aask(context, system_msgs=self.format_quick_system_prompt()) if "QUICK" in intent_result or "AMBIGUOUS " in intent_result: # llm call with the original context async with ThoughtReporter(enable_llm_stream=True) as reporter: diff --git a/metagpt/roles/di/team_leader.py b/metagpt/roles/di/team_leader.py index 353e00620..f934c09f9 100644 --- a/metagpt/roles/di/team_leader.py +++ b/metagpt/roles/di/team_leader.py @@ -26,7 +26,7 @@ class TeamLeader(RoleZero): # TeamLeader only reacts once each time, but may encounter errors or need to ask human, thus allowing 2 more turns max_react_loop: int = 3 - tools: list[str] = ["Plan", "RoleZero", "TeamLeader"] + tools: list[str] = ["Plan", "RoleZero", "TeamLeader", "Editor:write,read"] experience_retriever: Annotated[ExpRetriever, Field(exclude=True)] = SimpleExpRetriever() @@ -48,12 +48,14 @@ class TeamLeader(RoleZero): team_info += f"{role.name}: {role.profile}, {role.goal}\n" return team_info - async def _quick_think(self) -> Message: - # insert team info for quick question - self.llm.system_prompt = QUICK_THINK_SYSTEM_PROMPT.format( + def format_quick_system_prompt(self) -> str: + qt_system_prompt = super().format_quick_system_prompt() + return qt_system_prompt + QUICK_THINK_SYSTEM_PROMPT.format( role_info=super()._get_prefix(), team_info=self._get_team_info(), ) + + async def _quick_think(self) -> Message: return await super()._quick_think() async def _think(self) -> bool: From 19dee63729f3dca4ea8d5811e90ec723cdee28f1 Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Tue, 13 Aug 2024 17:12:01 +0800 Subject: [PATCH 04/13] optimize quick think system prompt --- metagpt/prompts/di/role_zero.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index 1a340cdef..dfd8f0684 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -130,13 +130,13 @@ Your role is to determine the appropriate response category for the given reques # Response Categories ## QUICK: -For straightforward questions or requests that can be answered directly. This includes common-sense inquiries, legal or logical questions, basic math, short coding tasks, multiple-choice questions, greetings, casual chat, schedule planning, and inquiries about you or your team. +For straightforward questions or requests that can be answered directly. This includes common-sense inquiries, legal or logical questions, basic math, short coding tasks, multiple-choice questions, greetings, casual chat, daily planning, and inquiries about you or your team. ## SEARCH For queries that require retrieving up-to-date or detailed information. This includes time-sensitive or location-specific questions like current events or weather. Use this only if the information isn't readily available. ## TASK -For complex requests that involve tool utilizations, multiple steps or detailed instructions. Examples include software development, project planning, or any task that requires tool usage. +For requests that involve tool utilizations, computer operations, multiple steps or detailed instructions. Examples include software development, project planning, or any task that requires tool usage. ## AMBIGUOUS For requests that are unclear, lack sufficient detail, or are outside the system's capabilities. Common characteristics of AMBIGUOUS requests: @@ -148,8 +148,7 @@ For requests that are unclear, lack sufficient detail, or are outside the system **Note:** Before categorizing a request as TASK: 1. Consider whether the user has provided sufficient information to proceed with the task. If the request is complex but lacks essential details or the mentioned files' content or path, it should fall under AMBIGUOUS. -2. If the request is a "how-to" question that asks for a general approach or strategy, it should be categorized as QUICK. -3. Writing a travel/learning plan or providing a general outline should be categorized as **QUICK* because it doesn't involve detailed instructions or tool usage. +2. If the request is a "how-to" question that asks for a general plan, approach or strategy, it should be categorized as QUICK. {examples} """ From d6fd6f5ca0f79a83df92ecb605218a34a3965607 Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Tue, 13 Aug 2024 18:16:51 +0800 Subject: [PATCH 05/13] remove comment --- metagpt/prompts/di/role_zero.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index dfd8f0684..1bd2984a5 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -148,7 +148,7 @@ For requests that are unclear, lack sufficient detail, or are outside the system **Note:** Before categorizing a request as TASK: 1. Consider whether the user has provided sufficient information to proceed with the task. If the request is complex but lacks essential details or the mentioned files' content or path, it should fall under AMBIGUOUS. -2. If the request is a "how-to" question that asks for a general plan, approach or strategy, it should be categorized as QUICK. +2. If the request is a "how-to" question that asks for a general study plan, approach or strategy, it should be categorized as QUICK. {examples} """ @@ -177,8 +177,8 @@ Response Category: QUICK. Thought: This is a general knowledge question that can be answered concisely. Response Category: QUICK. -3. Request: "Can you help me plan a healthy diet for a week?" -Thought: Writing a diet plan is a general task that can be answered directly. +3. Request: "Please help me write a learning plan for Python web crawlers" +Thought: Writing a learning plan is a daily planning task that can be answered directly. Response Category: QUICK. 4. Request: "Can you help me find the latest research papers on deep learning?" @@ -201,5 +201,4 @@ Response Category: TASK. Thought: The request is vague and lacks specifics, requiring clarification on the process to optimize. Response Category: AMBIGUOUS. -""" -# QUICK_THINK_EXAMPLES = "" \ No newline at end of file +""" \ No newline at end of file From d4d581f3914b10945122e4f1503b209678301536 Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Wed, 14 Aug 2024 09:58:36 +0800 Subject: [PATCH 06/13] tl remove editor tool --- metagpt/roles/di/team_leader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metagpt/roles/di/team_leader.py b/metagpt/roles/di/team_leader.py index f934c09f9..8a2584905 100644 --- a/metagpt/roles/di/team_leader.py +++ b/metagpt/roles/di/team_leader.py @@ -26,7 +26,7 @@ class TeamLeader(RoleZero): # TeamLeader only reacts once each time, but may encounter errors or need to ask human, thus allowing 2 more turns max_react_loop: int = 3 - tools: list[str] = ["Plan", "RoleZero", "TeamLeader", "Editor:write,read"] + tools: list[str] = ["Plan", "RoleZero", "TeamLeader"] experience_retriever: Annotated[ExpRetriever, Field(exclude=True)] = SimpleExpRetriever() From f8c690804c4de2763a0e47ee20053e70060c5a3d Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Wed, 14 Aug 2024 10:16:28 +0800 Subject: [PATCH 07/13] =?UTF-8?q?role=20zero=E7=9A=84quick=20think=20syste?= =?UTF-8?q?m=20prompt=E5=A2=9E=E5=8A=A0role=20info?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/prompts/di/role_zero.py | 2 ++ metagpt/roles/di/role_zero.py | 2 +- metagpt/roles/di/team_leader.py | 10 +++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index 1bd2984a5..71625c780 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -151,6 +151,8 @@ For requests that are unclear, lack sufficient detail, or are outside the system 2. If the request is a "how-to" question that asks for a general study plan, approach or strategy, it should be categorized as QUICK. {examples} + +{role_info} """ QUICK_THINK_PROMPT = """ diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.py index 7cdd9bdea..f5278bda7 100644 --- a/metagpt/roles/di/role_zero.py +++ b/metagpt/roles/di/role_zero.py @@ -254,7 +254,7 @@ class RoleZero(Role): def format_quick_system_prompt(self) -> str: """Format the system prompt for quick thinking.""" - return QUICK_THINK_SYSTEM_PROMPT.format(examples=QUICK_THINK_EXAMPLES) + return QUICK_THINK_SYSTEM_PROMPT.format(examples=QUICK_THINK_EXAMPLES, role_info=super()._get_prefix()) async def _quick_think(self) -> Tuple[Message, str]: answer = "" diff --git a/metagpt/roles/di/team_leader.py b/metagpt/roles/di/team_leader.py index 8a2584905..a10b61843 100644 --- a/metagpt/roles/di/team_leader.py +++ b/metagpt/roles/di/team_leader.py @@ -49,13 +49,17 @@ class TeamLeader(RoleZero): return team_info def format_quick_system_prompt(self) -> str: - qt_system_prompt = super().format_quick_system_prompt() - return qt_system_prompt + QUICK_THINK_SYSTEM_PROMPT.format( - role_info=super()._get_prefix(), + quick_system_prompt = super().format_quick_system_prompt() + return quick_system_prompt + QUICK_THINK_SYSTEM_PROMPT.format( + role_info="", # rolezero's quick think system prompt will include role_info team_info=self._get_team_info(), ) async def _quick_think(self) -> Message: + self.llm.system_prompt = QUICK_THINK_SYSTEM_PROMPT.format( + role_info=self._get_role_info(), + team_info=self._get_team_info(), + ) return await super()._quick_think() async def _think(self) -> bool: From 27a5288596e5de5ccd6444bd93674d55ebe173b7 Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Wed, 14 Aug 2024 10:22:17 +0800 Subject: [PATCH 08/13] use get_prefix --- metagpt/roles/di/team_leader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metagpt/roles/di/team_leader.py b/metagpt/roles/di/team_leader.py index a10b61843..0a8fd7acb 100644 --- a/metagpt/roles/di/team_leader.py +++ b/metagpt/roles/di/team_leader.py @@ -57,7 +57,7 @@ class TeamLeader(RoleZero): async def _quick_think(self) -> Message: self.llm.system_prompt = QUICK_THINK_SYSTEM_PROMPT.format( - role_info=self._get_role_info(), + role_info=super()._get_prefix(), team_info=self._get_team_info(), ) return await super()._quick_think() From 1dcb7984c555a700a737c1b7f3c65e65ad81a0b0 Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Wed, 14 Aug 2024 10:54:37 +0800 Subject: [PATCH 09/13] make prompt more generalized --- metagpt/prompts/di/role_zero.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index 0af2b92d7..b1165473f 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -148,7 +148,7 @@ For requests that are unclear, lack sufficient detail, or are outside the system **Note:** Before categorizing a request as TASK: 1. Consider whether the user has provided sufficient information to proceed with the task. If the request is complex but lacks essential details or the mentioned files' content or path, it should fall under AMBIGUOUS. -2. If the request is a "how-to" question that asks for a general study plan, approach or strategy, it should be categorized as QUICK. +2. If the request is a "how-to" question that asks for a general plan, approach or strategy, it should be categorized as QUICK. {examples} From b6cf6048ec944b418698e2155c4b16bf0d53d4ba Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Wed, 14 Aug 2024 11:06:31 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E4=B8=8D=E4=BD=BF=E7=94=A8SEARCH?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=96=87=E4=BB=B6=E5=B7=B2=E6=8F=90?= =?UTF-8?q?=E4=BE=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/prompts/di/role_zero.py | 1 + 1 file changed, 1 insertion(+) diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index b1165473f..0060ac7ec 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -134,6 +134,7 @@ For straightforward questions or requests that can be answered directly. This in ## SEARCH For queries that require retrieving up-to-date or detailed information. This includes time-sensitive or location-specific questions like current events or weather. Use this only if the information isn't readily available. +If a file or link is provided, you don't need to search for additional information. ## TASK For requests that involve tool utilizations, computer operations, multiple steps or detailed instructions. Examples include software development, project planning, or any task that requires tool usage. From 0315a218bec040b7f9a1fdd4ceaaff1b4aa92a02 Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Wed, 14 Aug 2024 11:50:20 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0TL=5FINFO=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E6=94=B9TL=E7=9A=84=5Fget=5Fprefix,=E4=B8=8D=E7=94=A8?= =?UTF-8?q?=E9=A2=9D=E5=A4=96=E7=BB=B4=E6=8A=A4TL=E7=9A=84SYSTEM=5FPROMPT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/prompts/di/role_zero.py | 3 +-- metagpt/prompts/di/team_leader.py | 6 ++++++ metagpt/roles/di/role_zero.py | 2 +- metagpt/roles/di/team_leader.py | 15 +++++++-------- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index 0060ac7ec..b7b32b7f3 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -126,6 +126,7 @@ Output the JSON data in a format that can be loaded by the json.loads() function """ QUICK_THINK_SYSTEM_PROMPT = """ +{role_info} Your role is to determine the appropriate response category for the given request. # Response Categories @@ -152,8 +153,6 @@ For requests that are unclear, lack sufficient detail, or are outside the system 2. If the request is a "how-to" question that asks for a general plan, approach or strategy, it should be categorized as QUICK. {examples} - -{role_info} """ QUICK_THINK_PROMPT = """ diff --git a/metagpt/prompts/di/team_leader.py b/metagpt/prompts/di/team_leader.py index ad473dfff..7c536875c 100644 --- a/metagpt/prompts/di/team_leader.py +++ b/metagpt/prompts/di/team_leader.py @@ -42,6 +42,12 @@ Your team member: However, you MUST respond to the user message by yourself directly, DON'T ask your team members. """ +TL_INFO = """ +{role_info} +Your team member: +{team_info} +""" + FINISH_CURRENT_TASK_CMD = """ ```json [ diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.py index 681a82402..e287471f6 100644 --- a/metagpt/roles/di/role_zero.py +++ b/metagpt/roles/di/role_zero.py @@ -258,7 +258,7 @@ class RoleZero(Role): def format_quick_system_prompt(self) -> str: """Format the system prompt for quick thinking.""" - return QUICK_THINK_SYSTEM_PROMPT.format(examples=QUICK_THINK_EXAMPLES, role_info=super()._get_prefix()) + return QUICK_THINK_SYSTEM_PROMPT.format(examples=QUICK_THINK_EXAMPLES, role_info=self._get_prefix()) async def _quick_think(self) -> Tuple[Message, str]: answer = "" diff --git a/metagpt/roles/di/team_leader.py b/metagpt/roles/di/team_leader.py index 0a8fd7acb..305d546d8 100644 --- a/metagpt/roles/di/team_leader.py +++ b/metagpt/roles/di/team_leader.py @@ -8,6 +8,7 @@ from metagpt.actions.di.run_command import RunCommand from metagpt.prompts.di.team_leader import ( FINISH_CURRENT_TASK_CMD, QUICK_THINK_SYSTEM_PROMPT, + TL_INFO, TL_INSTRUCTION, TL_THOUGHT_GUIDANCE, ) @@ -47,14 +48,12 @@ class TeamLeader(RoleZero): # continue team_info += f"{role.name}: {role.profile}, {role.goal}\n" return team_info - - def format_quick_system_prompt(self) -> str: - quick_system_prompt = super().format_quick_system_prompt() - return quick_system_prompt + QUICK_THINK_SYSTEM_PROMPT.format( - role_info="", # rolezero's quick think system prompt will include role_info - team_info=self._get_team_info(), - ) - + + def _get_prefix(self) -> str: + role_info = super()._get_prefix() + team_info = self._get_team_info() + return TL_INFO.format(role_info=role_info, team_info=team_info) + async def _quick_think(self) -> Message: self.llm.system_prompt = QUICK_THINK_SYSTEM_PROMPT.format( role_info=super()._get_prefix(), From 3b7dbf5e4ee1826c2240698c948979dd4c820c38 Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Wed, 14 Aug 2024 14:46:38 +0800 Subject: [PATCH 12/13] Remove TL's quick think system prompt --- metagpt/prompts/di/team_leader.py | 6 ------ metagpt/roles/di/team_leader.py | 5 ----- 2 files changed, 11 deletions(-) diff --git a/metagpt/prompts/di/team_leader.py b/metagpt/prompts/di/team_leader.py index 7c536875c..d7eb33442 100644 --- a/metagpt/prompts/di/team_leader.py +++ b/metagpt/prompts/di/team_leader.py @@ -35,12 +35,6 @@ Sixth, describe the requirements as they pertain to software development, data a Seventh, describe the technologies you must use. """ ) -QUICK_THINK_SYSTEM_PROMPT = """ -{role_info} -Your team member: -{team_info} -However, you MUST respond to the user message by yourself directly, DON'T ask your team members. -""" TL_INFO = """ {role_info} diff --git a/metagpt/roles/di/team_leader.py b/metagpt/roles/di/team_leader.py index 305d546d8..82288a7ed 100644 --- a/metagpt/roles/di/team_leader.py +++ b/metagpt/roles/di/team_leader.py @@ -7,7 +7,6 @@ from pydantic import Field from metagpt.actions.di.run_command import RunCommand from metagpt.prompts.di.team_leader import ( FINISH_CURRENT_TASK_CMD, - QUICK_THINK_SYSTEM_PROMPT, TL_INFO, TL_INSTRUCTION, TL_THOUGHT_GUIDANCE, @@ -55,10 +54,6 @@ class TeamLeader(RoleZero): return TL_INFO.format(role_info=role_info, team_info=team_info) async def _quick_think(self) -> Message: - self.llm.system_prompt = QUICK_THINK_SYSTEM_PROMPT.format( - role_info=super()._get_prefix(), - team_info=self._get_team_info(), - ) return await super()._quick_think() async def _think(self) -> bool: From 3490a4e2344cc7082499f2ef94e19a41a78f5728 Mon Sep 17 00:00:00 2001 From: Yizhou Chi Date: Wed, 14 Aug 2024 14:52:14 +0800 Subject: [PATCH 13/13] remove tl's qt --- metagpt/roles/di/team_leader.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/metagpt/roles/di/team_leader.py b/metagpt/roles/di/team_leader.py index 82288a7ed..4a39193a2 100644 --- a/metagpt/roles/di/team_leader.py +++ b/metagpt/roles/di/team_leader.py @@ -53,9 +53,6 @@ class TeamLeader(RoleZero): team_info = self._get_team_info() return TL_INFO.format(role_info=role_info, team_info=team_info) - async def _quick_think(self) -> Message: - return await super()._quick_think() - async def _think(self) -> bool: self.instruction = TL_INSTRUCTION.format(team_info=self._get_team_info()) return await super()._think()