mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-07-02 16:01:04 +02:00
update: SWE Agent
This commit is contained in:
parent
5c0f490c04
commit
816a6eadde
5 changed files with 36 additions and 30 deletions
|
|
@ -14,9 +14,9 @@ from metagpt.tools.libs.terminal import Bash
|
|||
from metagpt.tools.swe_agent_commands.swe_agent_utils import extract_patch
|
||||
|
||||
|
||||
class SWE(RoleZero):
|
||||
name: str = "SweAgent"
|
||||
profile: str = "Software Engineer"
|
||||
class SWEAgent(RoleZero):
|
||||
name: str = "Swen"
|
||||
profile: str = "Issue Solver"
|
||||
goal: str = "Resolve GitHub issue"
|
||||
_bash_window_size: int = 100
|
||||
_system_msg: str = SWE_AGENT_SYSTEM_TEMPLATE
|
||||
|
|
@ -26,12 +26,14 @@ class SWE(RoleZero):
|
|||
terminal: Bash = Field(default_factory=Bash, exclude=True)
|
||||
output_diff: str = ""
|
||||
max_react_loop: int = 40
|
||||
run_eval: bool = False
|
||||
|
||||
async def _think(self) -> bool:
|
||||
self._set_system_msg()
|
||||
self._format_instruction()
|
||||
res = await super()._think()
|
||||
await self._handle_action()
|
||||
if self.run_eval:
|
||||
await self._parse_commands_for_eval()
|
||||
return res
|
||||
|
||||
def _set_system_msg(self):
|
||||
|
|
@ -61,7 +63,7 @@ class SWE(RoleZero):
|
|||
|
||||
return self.instruction
|
||||
|
||||
async def _handle_action(self):
|
||||
async def _parse_commands_for_eval(self):
|
||||
"""
|
||||
Handles actions based on parsed commands.
|
||||
|
||||
|
|
@ -2,7 +2,7 @@ import subprocess
|
|||
import threading
|
||||
from queue import Queue
|
||||
|
||||
from metagpt.const import SWE_SETUP_PATH, SWE_WORKSPACE_ROOT
|
||||
from metagpt.const import DEFAULT_WORKSPACE_ROOT, SWE_SETUP_PATH
|
||||
from metagpt.tools.tool_registry import register_tool
|
||||
from metagpt.utils.report import END_MARKER_VALUE, TerminalReporter
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ class Bash(Terminal):
|
|||
def __init__(self):
|
||||
"""init"""
|
||||
super().__init__()
|
||||
self.run_command(f"cd {SWE_WORKSPACE_ROOT}")
|
||||
self.run_command(f"cd {DEFAULT_WORKSPACE_ROOT}")
|
||||
self.run_command(f"source {SWE_SETUP_PATH}")
|
||||
|
||||
def run(self, cmd) -> str:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
This tool is originally developed by the team behind the princeton-nlp/SWE-agent repository.
|
||||
This folder is borrowed from princeton-nlp/SWE-agent
|
||||
You can find the original repository here:
|
||||
https://github.com/princeton-nlp/SWE-agent/tree/main/config/commands
|
||||
We are using a modified version from OpenDevin:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue