Awesome
π° VillagerAgent: A Graph-Based Multi-Agent Framework for Coordinating Complex Task Dependencies in Minecraft π
<img src="img/VillagerBench.png" width="100%" /> <!-- <style> .showcase-table { width: 100%; border-spacing: 10px; border-collapse: separate; } .showcase-cell { width: 25%; padding: 10px; background: #f5f5f5; border-radius: 8px; transition: transform 0.2s; } .showcase-cell:hover { transform: scale(1.02); box-shadow: 0 4px 8px rgba(0,0,0,0.1); } .showcase-image { width: 256px; height: 256px; object-fit: cover; border-radius: 4px; margin-bottom: 8px; } .showcase-title { font-size: 14px; color: #333; margin-top: 8px; font-weight: 500; } </style> --> <table class="showcase-table"> <tr> <td class="showcase-cell" align="center"> <img src="img/fishing.png" class="showcase-image" /><br> <sub class="showcase-title">Fishing</sub> </td> <td class="showcase-cell" align="center"> <img src="img/build.png" class="showcase-image" /><br> <sub class="showcase-title">Building</sub> </td> <td class="showcase-cell" align="center"> <img src="img/cart.png" class="showcase-image" /><br> <sub class="showcase-title">Driving</sub> </td> <td class="showcase-cell" align="center"> <img src="img/conversition.png" class="showcase-image" /><br> <sub class="showcase-title">Talking</sub> </td> </tr> <tr> <td class="showcase-cell" align="center"> <img src="img/farm.png" class="showcase-image" /><br> <sub class="showcase-title">Farming</sub> </td> <td class="showcase-cell" align="center"> <img src="img/feed.png" class="showcase-image" /><br> <sub class="showcase-title">Feeding</sub> </td> <td class="showcase-cell" align="center"> <img src="img/grow.png" class="showcase-image" /><br> <sub class="showcase-title">Cultivate</sub> </td> <td class="showcase-cell" align="center"> <img src="img/saddle.png" class="showcase-image" /><br> <sub class="showcase-title">Holding</sub> </td> </tr> <tr> <td class="showcase-cell" align="center"> <img src="img/ride.png" class="showcase-image" /><br> <sub class="showcase-title">Riding</sub> </td> <td class="showcase-cell" align="center"> <img src="img/seed.png" class="showcase-image" /><br> <sub class="showcase-title">Seeding</sub> </td> <td class="showcase-cell" align="center"> <img src="img/store.png" class="showcase-image" /><br> <sub class="showcase-title">Storing</sub> </td> <td class="showcase-cell" align="center"> <img src="img/sleep.png" class="showcase-image" /><br> <sub class="showcase-title">Sleeping</sub> </td> </tr> </table>We aim to investigate the interactions between agents within the Minecraft environment and their collaboration with human players. Concurrently, we will explore the capabilities of Large Language Models (LLMs) in task decomposition and cooperation.
Welcome to VillagerBench, where the blocky world of Minecraft isn't just for fun and gamesβit's a testing ground for the cutting-edge of multi-agent collaboration! π€ Our benchmark suite is designed to push the boundaries of what virtual agents can achieve together, tackling everything from construction projects ποΈ to culinary quests π³ and escape room puzzles π.
Customize your private tasks in your Minecraft server with our VillagerAgent multi-agent framework, designed for personalized gameplay experiences! π ηΉε»ζ€ε€ζ₯η δΈζη READMEγ γ―γͺγγ―γγ¦ README γγ覧γγ γγγ
<p align="center"> <a href='https://arxiv.org/abs/2406.05720'> <img src='https://img.shields.io/badge/Paper-PDF-green?style=for-the-badge&logo=arXiv&logoColor=green' alt='Paper PDF'> </a> <a href='https://cnsdqd-dyb.github.io/VillagerAgent.github.io/2024/04/01/VillagerAgent.html'> <img src='https://img.shields.io/badge/Project-Page-blue?style=for-the-badge&logo=Web&logoColor=white' alt='Project Page'> </a> </p>News
[2024.12.18] We've added new attributes. VillagerBaseAgent LLM 8b v1 will be released soon.
[2024.12.11] Support LLM api ranking with PPO method.
[2024.12.08] LLM driven AutoGen task to get data for Agent-tuning.
<table> <tr> <td><img src="img/chat.png" width="100%" /></td> <td><img src="img/chat2.png" width="100%" /></td> </tr> <tr> <td><img src="img/chat3.png" width="100%" /></td> <td><img src="img/chat4.png" width="100%" /></td> </tr> </table>[2024.12.01] [Human -- Agent] [Agent -- Agent] Real Time Chat supports now!!!π
<table> <tr> <td><img src="img/autogen1.png" width="100%" /></td> <td><img src="img/autogen2.png" width="100%" /></td> </tr> </table>[2024.10.23] We are trying to replace the LLM in VillagerAgent with finetuned open source LLMs to improve the performance and efficiency of the agent's task execution.
[2024.10.04] πOur minecraft multi-agent framework VillagerAgent has been accepted by ACL 2024.
Setup and Configuration π οΈ
Requirements
- Python Version: Python 3.8 or newer installed on your system.
- API Keys: Obtain API keys from one or more of the following services:
- OpenAI (for access to models like GPT-4)
- Google Cloud (for access to models like Gemini)
- Zhipu AI (for access to GLM models)
- NPM Package: Node Package Manager (npm) installed, which is typically included with Node.jsοΌ
python js_setup.py
- Minecraft Server: If you want to know how to configure the Minecraft 1.19.2 server, please see the tutorial here.
- Python Dependencies: Install all necessary Python libraries as specified in the
requirements.txt
file. You can install these dependencies using the following command:pip install -r requirements.txt
- Other Model Choice: You have the option to use models from Hugging Face's Transformers library. Ensure you have the necessary credentials to use and download the model.
Installation Steps
- Clone the repository π¦:
git clone https://github.com/cnsdqd-dyb/VillagerAgent.git
- Opt for a virtual environment π§Ή:
python -m venv venv source venv/bin/activate # On Windows, try venv\Scripts\activate
- Install the dependencies π§βπ³:
pip install -r requirements.txt
- Set up your API key ποΈ:
- Craft a file named
API_KEY_LIST
and inscribe your API key in this way:
{ "OPENAI":["put your openai key here", ...], "GEMINI":[...], "GLM":[...], ... }
- We might try calling multiple available APIs to break through the access limit.
- Place this file in the root of the project directory.
- Craft a file named
QuickStart π
from env.env import VillagerBench, env_type, Agent
from pipeline.controller import GlobalController
from pipeline.data_manager import DataManager
from pipeline.task_manager import TaskManager
import json
if __name__ == "__main__":
# π Set Environment
env = VillagerBench(env_type.construction, task_id=0, _virtual_debug=False, dig_needed=False)
# π€ Set Agent
api_key_list = json.load(open("API_KEY_LIST", "r"))["OPENAI"] # ποΈ Use OPENAI as an example
base_url = "base url of the model"
llm_config = {
"api_model": "fill in the model name here", # For example, "gpt-4-1106-preview"
"api_base": base_url, # π For example, "https://api.openai.com/v1"
"api_key_list": api_key_list
}
Agent.model = "fill in the agent model name here" # π οΈ Customize your agent model
Agent.base_url = base_url
Agent.api_key_list = api_key_list
# π¨ More agent tools can be added here - refer to the agent_tool in doc/api_library.md
agent_tool = [Agent.fetchContainerContents, Agent.MineBlock, ..., Agent.handoverBlock]
# π Register Agent
env.agent_register(agent_tool=agent_tool, agent_number=3, name_list=["Agent1", "Agent2", "Agent3"]) # Ensure the agent number matches the agent_tool
# β οΈ Use /op to give the agent permission to use commands on the Minecraft server, e.g., /op Agent1
# πββοΈ Run Environment
with env.run():
# Set Data Manager
dm = DataManager(silent=False)
dm.update_database_init(env.get_init_state())
# Set Task Manager
tm = TaskManager(silent=False)
# Set Controller
ctrl = GlobalController(llm_config, tm, dm, env)
# Set Task
tm.init_task("Write your task description here.", json.load(open("your json task related file here if any.")))
# π Run Controller
ctrl.run()
Batch Testing π§ͺ
- Whip up test configs with
config.py
π. - Kick off automated batch testing with
start with config.py
π€.
Docker π³
- Build your Docker image with
docker build -t VillagerAgent .
π. - Launch the Docker container with
docker run VillagerAgent
π. - Note: If you need to open specific ports for API connectivity, you may need to modify the Dockerfile accordingly and launch with
docker run -p <your_port>:<app_port> VillagerAgent
π.
Overview π
VillagerBench
Dive into VillagerBench, powered by Mineflayer, to explore the dynamics of cooperative AI. Our agents don't just playβthey learn π, adapt π, and work together to overcome challenges that would stump the lone wolf πΊ.
<img src="img/benchmark.png" width="55%" /> <img src="img/radar.png" width="43.2%" />VillagerAgent Framework
Meet VillagerAgent, our multi-agent maestro πΌ, orchestrating a symphony of tasks with its four core components: Task Decomposer, Agent Controller, State Manager, and Base Agents. It's like a conductor for AI, turning individual actions into a masterpiece of collaboration.
<img src="img/framework.png" width="100%" />Core Components π
- VillagerBench: The virtual sandbox where agents interact and learn π€Ή.
- TaskManager: The master planner, keeping tasks on track and agents in the know π.
- DataManager: The keeper of knowledge, holding all the data cards close to its chest ποΈ.
- GlobalController: The overseer, ensuring every agent plays their part to perfection π―.
npm Installation
Windows
-
Download the Node.js Installer:
- Visit the Node.js official website.
- Download the latest stable version of the Node.js installer for Windows (the LTS version is usually recommended).
-
Run the Installer:
- Double-click the downloaded installer file.
- Follow the instructions provided by the installation wizard. Make sure to include all necessary components, including npm, during the installation process.
-
Verify Installation:
- Open Command Prompt or PowerShell.
- Enter the following commands to check the versions of Node.js and npm:
node -v npm -v
- If the installation was successful, you will see the version numbers of Node.js and npm displayed.
Linux (Debian/Ubuntu-based)
-
Install Using Package Manager:
- Open the terminal.
- First, update your package index:
sudo apt update
- Install Node.js and npm:
sudo apt install nodejs npm
-
Install Using nvm (Node Version Manager, recommended for managing multiple versions of Node.js):
- Open the terminal.
- Install nvm by running:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
- Restart the terminal or run the following command to update the current session:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
- Install Node.js using nvm (this will also install npm):
nvm install node
-
Verify Installation:
- Type the following commands to check the versions of Node.js and npm:
node -v npm -v
- If the installation was successful, you will see the version numbers of Node.js and npm displayed.
- Type the following commands to check the versions of Node.js and npm:
Minecraft 1.19.2 Server Setup
Preparation
-
Ensure Java is Installed: Minecraft servers require the Java runtime environment. Make sure you have the latest version of Java installed on your computer. You can check if Java is installed by running
java -version
in the command line. -
Download Server File: Visit the official Minecraft website to download the 1.19.2 version of the server file (
minecraft_server.1.19.2.jar
).
Configuring the Server
-
Create a Server Folder: Choose a location on your computer to create a new folder that will hold all the Minecraft server files.
-
Move Server File: Move the downloaded server file (
minecraft_server.1.19.2.jar
) into the folder you created. -
Run the Server:
- Open the command line interface.
- Navigate to the folder containing the server file using the
cd
command. - Run the following command to start the server:
java -Xmx1024M -Xms1024M -jar minecraft_server.1.19.2.jar nogui
- The
-Xmx1024M
and-Xms1024M
parameters set the maximum and initial memory allocation for the server in megabytes (MB). You may need to adjust these values based on your server's hardware.
-
Accept the EULA: The first time you run the server, a file named
eula.txt
will be generated. Open this file and changeeula=false
toeula=true
to accept the Minecraft End User License Agreement. -
Restart the Server: Run the
java
command again to start the server.
Configuring Server Properties
-
Edit the
server.properties
File: After the first server run, a configuration file namedserver.properties
will be generated. You can edit this file to customize the server settings, such as game mode, difficulty, etc. If you are testing the capabilities of multiple agents on VillagerBench, set the mode to peaceful and the terrain to superflat. -
Port Forwarding: If you want other players to be able to access your server from outside networks, you may need to set up port forwarding on your router. By default, the Minecraft server uses port 25565.
-
Start and Test the Server: After completing all the settings, restart the server and try connecting to it to ensure everything is running smoothly.
Important Notes
- Ensure that any agents that may join the server have been granted admin privileges (you can add permissions with the command
/op agent_name
). - Make sure your server's firewall rules allow the port used by the Minecraft server.
- Regularly back up your server files to prevent data loss.
- Keep the server's Java version up to date for optimal performance and security.
The steps above provide a basic tutorial for setting up a Minecraft server. Depending on your specific needs and configuration, more advanced settings may be required.
Citation
π If you find our work helpful, please leave us a star and cite our paper.
@inproceedings{dong2024villageragent,
title={VillagerAgent: A Graph-Based Multi-Agent Framework for Coordinating Complex Task Dependencies in Minecraft},
author={Dong, Yubo and Zhu, Xukun and Pan, Zhengzhe and Zhu, Linchao and Yang, Yi},
booktitle={Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (ACL)},
year={2024},
url={https://arxiv.org/abs/2406.05720}
}
Contribution Guide π€
Jump on board! We love contributions. Before you submit your pull request, make sure:
- Your changes have aced the tests π.
- You've spruced up the docs (if you've added some pizzazz) π.
License π
This project is all yours under the MIT License.