mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-17 15:35:21 +02:00
update code: add exception in execution
This commit is contained in:
parent
896932e02d
commit
4bb69f4503
1 changed files with 21 additions and 2 deletions
|
|
@ -346,8 +346,27 @@ class GameEnvironment(BaseModel, arbitrary_types_allowed=True):
|
|||
self.update_event(events)
|
||||
return events
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to execute Minecraft events: {str(e)}")
|
||||
raise {}
|
||||
### add: 异常的话结束当前流程,继续后续运行
|
||||
logger.error(f"Failed to retrieve Minecraft events: {str(e)}")
|
||||
time.sleep(3) # wait for mineflayer to exit
|
||||
info = {
|
||||
"task": self.current_task,
|
||||
"success": False,
|
||||
}
|
||||
# reset bot status here
|
||||
events = self.mf_instance.reset(
|
||||
options={
|
||||
"mode": "hard",
|
||||
"wait_ticks": 20,
|
||||
"inventory": self.events[-1][1]["inventory"],
|
||||
"equipment": self.events[-1][1]["status"]["equipment"],
|
||||
"position": self.events[-1][1]["status"]["position"],
|
||||
}
|
||||
)
|
||||
self.update_event(events)
|
||||
# use red color background to print the error
|
||||
logger.info("Your last round rollout terminated due to error:")
|
||||
logger.info(f"\033[41m{e}\033[0m")
|
||||
|
||||
|
||||
class MinecraftPlayer(SoftwareCompany):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue