mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-27 17:56:23 +02:00
update: terminal run command 改为异步
This commit is contained in:
parent
48062fff9f
commit
ff5dbfbc52
4 changed files with 81 additions and 66 deletions
|
|
@ -29,7 +29,7 @@ class SWEAgent(RoleZero):
|
|||
|
||||
async def _think(self) -> bool:
|
||||
self._update_system_msg()
|
||||
self._format_instruction()
|
||||
await self._format_instruction()
|
||||
res = await super()._think()
|
||||
if self.run_eval:
|
||||
await self._parse_commands_for_eval()
|
||||
|
|
@ -46,14 +46,14 @@ class SWEAgent(RoleZero):
|
|||
self._bash_window_size = int(os.getenv("WINDOW"))
|
||||
self.system_msg = [self._system_msg.format(WINDOW=self._bash_window_size)]
|
||||
|
||||
def _format_instruction(self):
|
||||
async def _format_instruction(self):
|
||||
"""
|
||||
Formats the instruction message for the SWE agent.
|
||||
|
||||
Runs the "state" command in the terminal, parses its output as JSON,
|
||||
and uses it to format the `_instruction` template.
|
||||
"""
|
||||
state_output = self.terminal.run("state")
|
||||
state_output = await self.terminal.run("state")
|
||||
bash_state = json.loads(state_output)
|
||||
|
||||
self.instruction = self._instruction.format(
|
||||
|
|
@ -81,7 +81,7 @@ class SWEAgent(RoleZero):
|
|||
if "end" != cmd.get("command_name", ""):
|
||||
return
|
||||
try:
|
||||
diff_output = self.terminal.run("git diff --cached")
|
||||
diff_output = await self.terminal.run("git diff --cached")
|
||||
clear_diff = extract_patch(diff_output)
|
||||
logger.info(f"Diff output: \n{clear_diff}")
|
||||
if clear_diff:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue