mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-01 20:03:28 +02:00
fix conflict
This commit is contained in:
commit
93d4c8c318
34 changed files with 2310 additions and 260 deletions
|
|
@ -30,8 +30,8 @@ class DataAnalyst(RoleZero):
|
|||
instruction: str = ROLE_INSTRUCTION + EXTRA_INSTRUCTION
|
||||
task_type_desc: str = TASK_TYPE_DESC
|
||||
|
||||
tools: list[str] = ["Plan", "DataAnalyst", "RoleZero", "Browser", "Editor:write,read"]
|
||||
custom_tools: list[str] = ["web scraping", "Terminal"]
|
||||
tools: list[str] = ["Plan", "DataAnalyst", "RoleZero", "Browser", "Editor:write,read", "SearchEnhancedQA"]
|
||||
custom_tools: list[str] = ["web scraping", "Terminal", "Editor:write,read"]
|
||||
custom_tool_recommender: ToolRecommender = None
|
||||
experience_retriever: Annotated[ExpRetriever, Field(exclude=True)] = KeywordExpRetriever()
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from metagpt.prompts.di.engineer2 import (
|
|||
from metagpt.roles.di.role_zero import RoleZero
|
||||
from metagpt.schema import UserMessage
|
||||
from metagpt.strategy.experience_retriever import ENGINEER_EXAMPLE
|
||||
from metagpt.tools.libs.cr import CodeReview
|
||||
from metagpt.tools.libs.terminal import Terminal
|
||||
from metagpt.tools.tool_registry import register_tool
|
||||
from metagpt.utils.common import CodeParser, awrite
|
||||
|
|
@ -28,14 +29,17 @@ class Engineer2(RoleZero):
|
|||
|
||||
terminal: Terminal = Field(default_factory=Terminal, exclude=True)
|
||||
|
||||
tools: list[str] = ["Plan", "Editor:read", "RoleZero", "Terminal:run_command", "Engineer2"]
|
||||
tools: list[str] = ["Plan", "Editor:read", "RoleZero", "Terminal:run_command", "Engineer2", "SearchEnhancedQA", "CodeReview"]
|
||||
|
||||
def _update_tool_execution(self):
|
||||
# validate = ValidateAndRewriteCode()
|
||||
cr = CodeReview()
|
||||
self.tool_execution_map.update(
|
||||
{
|
||||
"Terminal.run_command": self.terminal.run_command,
|
||||
"Engineer2.write_new_code": self.write_new_code,
|
||||
"CodeReview.review": cr.review,
|
||||
"CodeReview.fix": cr.fix,
|
||||
# "ValidateAndRewriteCode.run": validate.run,
|
||||
# "ValidateAndRewriteCode": validate.run,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ from metagpt.prompts.di.role_zero import (
|
|||
ROLE_INSTRUCTION,
|
||||
SUMMARY_PROMPT,
|
||||
SYSTEM_PROMPT,
|
||||
THOUGHT_GUIDANCE,
|
||||
)
|
||||
from metagpt.roles import Role
|
||||
from metagpt.schema import AIMessage, LongTermMemoryItem, Message, UserMessage
|
||||
|
|
@ -64,7 +63,6 @@ class RoleZero(Role):
|
|||
system_prompt: str = SYSTEM_PROMPT # Use None to conform to the default value at llm.aask
|
||||
cmd_prompt: str = CMD_PROMPT
|
||||
cmd_prompt_current_state: str = ""
|
||||
thought_guidance: str = THOUGHT_GUIDANCE
|
||||
instruction: str = ROLE_INSTRUCTION
|
||||
task_type_desc: Optional[str] = None
|
||||
|
||||
|
|
@ -87,7 +85,7 @@ class RoleZero(Role):
|
|||
# Others
|
||||
command_rsp: str = "" # the raw string containing the commands
|
||||
commands: list[dict] = [] # commands to be executed
|
||||
memory_k: int = 20 # number of memories (messages) to use as historical context
|
||||
memory_k: int = 200 # number of memories (messages) to use as historical context
|
||||
enable_longterm_memory: bool = True # whether to use longterm memory
|
||||
longterm_memory: RoleZeroLongTermMemory = None
|
||||
use_fixed_sop: bool = False
|
||||
|
|
@ -117,11 +115,9 @@ class RoleZero(Role):
|
|||
"Plan.append_task": self.planner.plan.append_task,
|
||||
"Plan.reset_task": self.planner.plan.reset_task,
|
||||
"Plan.replace_task": self.planner.plan.replace_task,
|
||||
"Editor.write": self.editor.write,
|
||||
"Editor.write_content": self.editor.write_content,
|
||||
"Editor.read": self.editor.read,
|
||||
"RoleZero.ask_human": self.ask_human,
|
||||
"RoleZero.reply_to_human": self.reply_to_human,
|
||||
"SearchEnhancedQA.run": SearchEnhancedQA().run,
|
||||
}
|
||||
self.tool_execution_map.update(
|
||||
{
|
||||
|
|
@ -140,6 +136,27 @@ class RoleZero(Role):
|
|||
]
|
||||
}
|
||||
)
|
||||
self.tool_execution_map.update(
|
||||
{
|
||||
f"Editor.{i}": getattr(self.editor, i)
|
||||
for i in [
|
||||
"append_file",
|
||||
"create_file",
|
||||
"edit_file_by_replace",
|
||||
"find_file",
|
||||
"goto_line",
|
||||
"insert_content_at_line",
|
||||
"open_file",
|
||||
"read",
|
||||
"scroll_down",
|
||||
"scroll_up",
|
||||
"search_dir",
|
||||
"search_file",
|
||||
"set_workdir",
|
||||
"write",
|
||||
]
|
||||
}
|
||||
)
|
||||
# can be updated by subclass
|
||||
self._update_tool_execution()
|
||||
return self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue