From 4e1955eba8199cdcdee890f26b24d7b8bfcb427b Mon Sep 17 00:00:00 2001 From: seehi <6580@pm.me> Date: Tue, 16 Jul 2024 20:52:44 +0800 Subject: [PATCH] update comment --- metagpt/exp_pool/context_builders/role_zero.py | 10 +++++----- metagpt/prompts/di/role_zero.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/metagpt/exp_pool/context_builders/role_zero.py b/metagpt/exp_pool/context_builders/role_zero.py index aa5524ab4..924bd56aa 100644 --- a/metagpt/exp_pool/context_builders/role_zero.py +++ b/metagpt/exp_pool/context_builders/role_zero.py @@ -12,12 +12,12 @@ class RoleZeroContextBuilder(BaseContextBuilder): """Builds the role zero context string. Note: - 1. The expected format for `req`, e.g., [{...}, {"role": "user", "content": "context"}, {"role": "user", "content": "context exp part"}]. - 2. Returns the original `req` if it is empty, incorrectly formatted or there are no experiences. + 1. The expected format for `req`, e.g., [{...}, {"role": "user", "content": "context"}]. + 2. Returns the original `req` if it is empty. 3. Creates a copy of req and replaces the example content in the copied req with actual experiences. """ - if not req or len(req) < 2: + if not req: return req exps = self.format_exps() @@ -26,12 +26,12 @@ class RoleZeroContextBuilder(BaseContextBuilder): req_copy = copy.deepcopy(req) - req_copy[-2]["content"] = self.replace_example_content(req_copy[-2].get("content", ""), exps) + req_copy[-1]["content"] = self.replace_example_content(req_copy[-1].get("content", ""), exps) return req_copy def replace_example_content(self, text: str, new_example_content: str) -> str: - return self.replace_content_between_markers(text, "# Example", "# Available Commands", new_example_content) + return self.replace_content_between_markers(text, "# Example", "# Instruction", new_example_content) @staticmethod def replace_content_between_markers(text: str, start_marker: str, end_marker: str, new_content: str) -> str: diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py index 41b9e023e..b2e931e23 100644 --- a/metagpt/prompts/di/role_zero.py +++ b/metagpt/prompts/di/role_zero.py @@ -18,9 +18,6 @@ class Task(BaseModel): task_type: str = "" assignee: str = "" -# Example -{example} - # Available Commands {available_commands} Special Command: Use {{"command_name": "end"}} to do nothing or indicate completion of all requirements and the end of actions. @@ -34,6 +31,9 @@ Special Command: Use {{"command_name": "end"}} to do nothing or indicate complet # Current Task {current_task} +# Example +{example} + # Instruction {instruction}