mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-07-14 16:32:16 +02:00
Merge remote-tracking branch 'origin/mgx_ops' into feat_zhg
# Conflicts: # metagpt/roles/di/engineer2.py # metagpt/tools/libs/cr.py
This commit is contained in:
commit
9f4dcf0ad0
30 changed files with 2288 additions and 261 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()
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,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, Message, UserMessage
|
||||
|
|
@ -62,7 +61,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
|
||||
|
||||
|
|
@ -85,7 +83,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 = 100 # number of memories (messages) to use as historical context
|
||||
use_fixed_sop: bool = False
|
||||
requirements_constraints: str = "" # the constraints in user requirements
|
||||
use_summary: bool = True # whether to summarize at the end
|
||||
|
|
@ -113,11 +111,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(
|
||||
{
|
||||
|
|
@ -136,6 +132,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
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from metagpt.prompts.di.swe_agent import (
|
|||
from metagpt.roles.di.role_zero import RoleZero
|
||||
from metagpt.schema import Message
|
||||
from metagpt.tools.libs.git import git_create_pull
|
||||
from metagpt.tools.libs.terminal import Bash
|
||||
from metagpt.tools.libs.terminal import Terminal
|
||||
|
||||
|
||||
class SWEAgent(RoleZero):
|
||||
|
|
@ -19,13 +19,8 @@ class SWEAgent(RoleZero):
|
|||
profile: str = "Issue Solver"
|
||||
goal: str = "Resolve GitHub issue or bug in any existing codebase"
|
||||
_instruction: str = NEXT_STEP_TEMPLATE
|
||||
tools: list[str] = [
|
||||
"Bash",
|
||||
"Browser:goto,scroll",
|
||||
"RoleZero",
|
||||
"git_create_pull",
|
||||
]
|
||||
terminal: Bash = Field(default_factory=Bash, exclude=True)
|
||||
tools: list[str] = ["Browser:goto,scroll", "RoleZero", "git_create_pull", "Editor", "Terminal"]
|
||||
terminal: Terminal = Field(default_factory=Terminal, exclude=True)
|
||||
output_diff: str = ""
|
||||
max_react_loop: int = 40
|
||||
run_eval: bool = False
|
||||
|
|
@ -38,7 +33,6 @@ class SWEAgent(RoleZero):
|
|||
def _update_tool_execution(self):
|
||||
self.tool_execution_map.update(
|
||||
{
|
||||
"Bash.run": self.terminal.run,
|
||||
"git_create_pull": git_create_pull,
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue