minerl icon indicating copy to clipboard operation
minerl copied to clipboard

v0.4.4 ChatAction error

Open mwang808 opened this issue 2 years ago • 9 comments

Hello, I try to add the ChatAction to the custom environment following the documents

  1. https://minerl.readthedocs.io/en/v0.4.4/tutorials/custom_environments.html
  2. 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.

mwang808 avatar Nov 02 '22 18:11 mwang808

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()
    ]

Miffyli avatar Nov 02 '22 20:11 Miffyli

I tried this way before. It shows "No module named 'minerl.herobraine.hero.handlers.agent.actions.chat'"

mwang808 avatar Nov 02 '22 23:11 mwang808

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.

Miffyli avatar Nov 03 '22 00:11 Miffyli

That is exactly what I am using: !pip3 install --upgrade minerl==0.4.4

mwang808 avatar Nov 03 '22 00:11 mwang808

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]

Miffyli avatar Nov 03 '22 19:11 Miffyli

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?

mwang808 avatar Nov 04 '22 16:11 mwang808

Hard to say with more info. Make sure you added the handler in the right place and that you are creating the right environment.

Miffyli avatar Nov 05 '22 00:11 Miffyli

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 avatar Mar 01 '23 17:03 jhsul

@jhsul Answered over email, but for completeness: ChatAction is now available in v1.0.0 thanks to this PR #638

Miffyli avatar Mar 06 '23 15:03 Miffyli