Voyager Documentation

repository·main·Indexed 27 days ago

https://github.com/minedojo/voyager

Voyager is an LLM-powered embodied lifelong learning agent for Minecraft version 1.19. It utilizes an automatic curriculum, a skill library of executable code, and iterative prompting to acquire complex behaviors without human intervention. The documentation covers installation requirements for Python (≥ 3.9) and Node.js (≥ 16.13.0), Minecraft instance setup with Fabric mods, and the Voyager class API for learning, task decomposition, and inference.

Tokens
5.2K
Snippets
13
Records
29
Agent score
92%

What's inside Voyager

  1. Install Minecraft Instance via Official Launcher

    main

    If you prefer not to use Azure login, you can use an existing Minecraft instance by opening it via the official launcher and configuring a LAN world.

    Setup Steps:

    1. Open the Minecraft official launcher.
    2. Select your desired version and start the game.
    3. Create a new Singleplayer world.
    4. Set Game Mode to Creative and Difficulty to Peaceful.
    5. Once the world is loaded, press Esc and select Open to LAN.
    6. Set Allow cheats to ON and select Start LAN World.
    7. Locate the port number displayed in the chat log. This is your mc-port, which you will use to instantiate Voyager.
  2. Install Fabric Loader for Minecraft 1.19

    main

    To run Voyager with Fabric mods, you must install the Fabric loader matching your Minecraft version (1.19).

    1. Download the Fabric Installer from fabricmc.net.
    2. Windows: Run the .exe file.
    3. Mac/Ubuntu: Run the .jar file using java -jar fabric-installer-0.11.2.jar.
    4. Configuration: Select game version 1.19 and loader version 0.14.18 during installation. The installer should automatically detect your Minecraft installation location.
    java -jar fabric-installer-0.11.2.jar
  3. Initialize and Start Voyager Lifelong Learning

    main

    To start the lifelong learning process, instantiate the Voyager class with your OpenAI API key and Azure login configuration.

    Note on Azure Login: While you can use mc_port instead of azure_login, azure_login is highly recommended. When running azure_login for the first time, follow the CLI instructions to generate a config file.

    Minecraft World Setup: After running voyager.learn(), you must manually configure the world:

    1. Select Singleplayer -> Create New World.
    2. Set Game Mode to Creative and Difficulty to Peaceful.
    3. Once created, press Esc and select Open to LAN.
    4. Set Allow cheats: ON and press Start LAN World.
    from voyager import Voyager
    
    # Configuration for Azure Login
    azure_login = {
        "client_id": "YOUR_CLIENT_ID",
        "redirect_url": "https://127.0.0.1/auth-response",
        "secret_value": "[OPTIONAL] YOUR_SECRET_VALUE",
        "version": "fabric-loader-0.14.18-1.19", # the version Voyager is tested on
    }
    openai_api_key = "YOUR_API_KEY"
    
    voyager = Voyager(
        azure_login=azure_login,
        openai_api_key=openai_api_key,
    )
    
    # Start the learning process
    voyager.learn()
  4. Compile and install the Better Respawn mod

    main

    The Better Respawn mod must be manually cloned and compiled. You require Java Runtime Environment (JRE) v17+ to build it.

    1. Clone the better-respawn repository.
    2. Open settings.gradle and remove the 'forge' string from the last line.
    3. Run ./gradlew build to compile.
    4. Locate the compiled jar at better-respawn/fabric/build/libs/better-respawn-fabric-1.19-2.0.0.jar and move it to your YOUR_MINECRAFT_GAME_LOCATION/mods folder.
    5. After launching the game once, configure the mod by editing YOUR_MINECRAFT_GAME_LOCATION/config/better-respawn/properties with the following values:
    respawn_block_range=32
    max_respawn_distance=32
    min_respawn_distance=0
    gradlew build
  5. Share your learned skill library

    main
    A learned skill library is contained within the skill subdirectory of your checkpoint directory. To contribute your skills to the project, identify the skill folder and share its location (e.g., via a repository link) by creating a pull request to the project's documentation.
  6. Run Voyager for Specific Tasks using a Skill Library

    main

    To execute specific tasks using previously learned skills rather than starting a new learning session, follow this pattern:

    1. Instantiate with Skill Library: Pass skill_library_dir to load existing skills. Set resume=False because this is an inference task, not a learning task. Use a separate ckpt_dir for recording new events.
    2. Decompose Task: Use decompose_task() to break the high-level goal into sub-goals. If sub-goals appear illogical, rerun the decomposition.
    3. Inference: Use inference() to execute the sub-goals using the skill library.
    from voyager import Voyager
    
    # 1. Instantiate with skill library
    voyager = Voyager(
        azure_login=azure_login,
        openai_api_key=openai_api_key,
        skill_library_dir="./skill_library/trial1",
        ckpt_dir="YOUR_CKPT_DIR",
        resume=False,
    )
    
    # 2. Run task decomposition
    task = "Craft a diamond pickaxe"
    sub_goals = voyager.decompose_task(task=task)
    
    # 3. Run inference
    voyager.inference(sub_goals=sub_goals)
  7. Install Voyager (Python and Node.js)

    main

    Voyager requires Python ≥ 3.9 and Node.js ≥ 16.13.0. Follow these steps to install the dependencies:

    1. Python Installation

    git clone https://github.com/MineDojo/Voyager
    cd Voyager
    pip install -e .

    2. Node.js Installation

    Install the required Node.js packages for the environment:

    cd voyager/env/mineflayer
    npm install -g npx
    npm install
    cd mineflayer-collectblock
    npx tsc
    cd ..
    npm install
    git clone https://github.com/MineDojo/Voyager
    cd Voyager
    pip install -e .
    
    cd voyager/env/mineflayer
    npm install -g npx
    npm install
    cd mineflayer-collectblock
    npx tsc
    cd ..
    npm install
  8. Resume learning from a community skill library

    main

    To use a skill library contributed by the community, download or clone the contributor's repository. You can then resume the learning process by setting the skill_library_dir parameter to the checkpoint directory (ckpt dir) located within the downloaded folder.

    skill_library_dir=COMMUNITY_CKPT_DIR
  9. Install required Fabric mods

    main

    After installing Fabric, place the following mods into your YOUR_MINECRAFT_GAME_LOCATION/mods folder:

    • Fabric API: Basic Fabric APIs.
    • Mod Menu: Used to manage downloaded mods.
    • Complete Config: Dependency for server pause.
    • Multi Server Pause: Used to pause the server while waiting for GPT-4 responses.

    Ensure all downloaded mods are compatible with Minecraft version 1.19.

  10. Install Minecraft Instance via Microsoft Azure Login (Recommended)

    main

    This method allows Voyager to automatically resume if a request timeout occurs (e.g., when GPT-4 generates an infinite loop). This setup uses the minecraft-launcher-lib library.

    Setup Steps:

    1. Sign in to the Azure Portal.
    2. Navigate to Azure Active Directory > App Registrations.
    3. Click New registration and configure:
      • Name: YOUR_APP_NAME
      • Supported account types: Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts
      • Redirect URI Type: Public client/native (mobile & desktop)
      • Redirect URI Value: https://127.0.0.1/auth-response (Note: If you encounter KeyError: 'access_token', try changing the type to Web).
    4. Click Register. The Application (client) ID is your client_id.
    5. [Optional] Under Certificates & Secrets, create a New client secret. The generated value is your secret_value.
    6. Identify your Minecraft version by checking the folder names in your Minecraft install location: YOUR_MINECRAFT_GAME_LOCATION/versions.

    Note: Voyager uses fabric-loader-0.14.18-1.19 for experiments. If you do not have this version, refer to the Fabric Mods Install guide.

    Configuration Object:

    Use the following structure for your azure_login configuration:

    azure_login = {
        "client_id": "CLIENT_ID FROM STEP 7",
        "redirect_url": "https://127.0.0.1/auth-response",
        "secret_value": "[OPTIONAL] SECRET_KEY FROM STEP 8",
        "version": "MINECRAFT VERSION YOU WANT TO USE",
    }