minerl
minerl copied to clipboard
v0.4.4 ChatAction error
Hello, I try to add the ChatAction to the custom environment following the documents
- https://minerl.readthedocs.io/en/v0.4.4/tutorials/custom_environments.html
- https://minerl.readthedocs.io/en/v0.4.4/tutorials/minecraft_commands.html
Here is my code inside the MLGWB clas: from minerl.herobraine.env_specs.simple_embodiment import SimpleEmbodimentEnvSpec from minerl.herobraine.hero.handler import Handler import minerl.herobraine.hero.handlers as handlers from typing import List #from minerl.herobraine.hero.handlers.agent.actions.chat import ChatAction
... ...
def create_actionables(self) -> List[Handler]:
return super().create_actionables() + [
# allow agent to place water
handlers.KeybasedCommandAction("use"),
# also allow it to equip the pickaxe
handlers.EquipAction(["diamond_pickaxe"]),
# enable chat
handlers.ChatAction()
]
I got the following error: AttributeError: module 'minerl.herobraine.hero.handlers' has no attribute 'ChatAction'
I tried to add from minerl.herobraine.hero.handlers.agent.actions.chat import ChatAction but still got an error.
Can you tell me how to enable the chat? Thanks.
Try
from minerl.herobraine.env_specs.simple_embodiment import SimpleEmbodimentEnvSpec
from minerl.herobraine.hero.handler import Handler
import minerl.herobraine.hero.handlers as handlers
from typing import List
from minerl.herobraine.hero.handlers.agent.actions.chat import ChatAction
...
...
def create_actionables(self) -> List[Handler]:
return super().create_actionables() + [
# allow agent to place water
handlers.KeybasedCommandAction("use"),
# also allow it to equip the pickaxe
handlers.EquipAction(["diamond_pickaxe"]),
# enable chat
ChatAction()
]
I tried this way before. It shows "No module named 'minerl.herobraine.hero.handlers.agent.actions.chat'"
Ah, you might be running v1.0 of MineRL in that case (the current version on github). The chat commands are available in MineRL v0.4.4, which you can install with pip install minerl==0.4.4
.
That is exactly what I am using: !pip3 install --upgrade minerl==0.4.4
Oh ah sorry, my mistake! Pypi was not updated with that version. You need to install specific branch from github: pip install git+https://github.com/minerllabs/[email protected]
Thanks. I can load the environment now. However, when I ran a simple test following the instruction: actions = {} env.set_next_chat_message("/tp @r 320 54 66") env.step(actions) I got the following error: RuntimeError: Tried to use chat action but no ChatAction handler is present (see docs on how to send Minecraft commands).
Any suggestion?
Hard to say with more info. Make sure you added the handler in the right place and that you are creating the right environment.
Ah, you might be running v1.0 of MineRL in that case (the current version on github). The chat commands are available in MineRL v0.4.4, which you can install with
pip install minerl==0.4.4
.
Is it possible to use ChatAction
in MineRL v1.0?
Edit: More broadly speaking, is there any way to inject server commands in minerl v1.0?
@jhsul Answered over email, but for completeness: ChatAction is now available in v1.0.0 thanks to this PR #638