mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-30 19:36:24 +02:00
update comment
This commit is contained in:
parent
5693594afe
commit
4e1955eba8
2 changed files with 8 additions and 8 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue