Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

增加TL_INFO,更改TL的_get_prefix,不用额外维护TL的SYSTEM_PROMPT

Yizhou Chi0315a218bec0
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(),