mindcraft/README.md

183 lines
11 KiB
Markdown
Raw Permalink Normal View History

# Mindcraft 🧠⛏️
2023-08-15 23:39:02 -07:00
2025-01-25 10:53:22 -06:00
Crafting minds for Minecraft with LLMs and [Mineflayer!](https://prismarinejs.github.io/mineflayer/#/)
2023-08-15 23:39:02 -07:00
2025-04-26 11:20:14 -05:00
[FAQ](https://github.com/kolbytn/mindcraft/blob/main/FAQ.md) | [Discord Support](https://discord.gg/mp73p35dzC) | [Video Tutorial](https://www.youtube.com/watch?v=gRotoL8P8D8) | [Blog Post](https://kolbynottingham.com/mindcraft/) | [Contributor TODO](https://github.com/users/kolbytn/projects/1) | [Paper Website](https://mindcraft-minecollab.github.io/index.html) | [MineCollab](https://github.com/kolbytn/mindcraft/blob/main/minecollab.md)
2024-11-02 14:08:59 -05:00
2024-10-06 14:23:33 -05:00
2025-02-17 13:54:12 -06:00
> [!Caution]
Do not connect this bot to public servers with coding enabled. This project allows an LLM to write/execute code on your computer. The code is sandboxed, but still vulnerable to injection attacks. Code writing is disabled by default, you can enable it by setting `allow_insecure_coding` to `true` in `settings.js`. Ye be warned.
2024-01-30 16:43:30 -06:00
2024-01-30 22:26:27 -06:00
## Requirements
2024-01-30 16:43:30 -06:00
- [Minecraft Java Edition](https://www.minecraft.net/en-us/store/minecraft-java-bedrock-edition-pc) (up to v1.21.4, recommend v1.21.1)
2025-06-10 13:56:56 -05:00
- [Node.js Installed](https://nodejs.org/) (at least v18)
- One of these: [OpenAI API Key](https://openai.com/blog/openai-api) | [Gemini API Key](https://aistudio.google.com/app/apikey) | [Anthropic API Key](https://docs.anthropic.com/claude/docs/getting-access-to-claude) | [Replicate API Key](https://replicate.com/) | [Hugging Face API Key](https://huggingface.co/) | [Groq API Key](https://console.groq.com/keys) | [Ollama Installed](https://ollama.com/download). | [Mistral API Key](https://docs.mistral.ai/getting-started/models/models_overview/) | [Qwen API Key [Intl.]](https://www.alibabacloud.com/help/en/model-studio/developer-reference/get-api-key)/[[cn]](https://help.aliyun.com/zh/model-studio/getting-started/first-api-call-to-qwen?) | [Novita AI API Key](https://novita.ai/settings?utm_source=github_mindcraft&utm_medium=github_readme&utm_campaign=link#key-management) | [Cerebras API Key](https://cloud.cerebras.ai) | [Mercury API](https://platform.inceptionlabs.ai/docs)
2024-01-30 16:43:30 -06:00
2024-11-02 13:03:58 -05:00
## Install and Run
1. Make sure you have the requirements above.
2025-06-09 01:45:28 -05:00
2. Clone or download this repository (big green button) 'git clone https://github.com/kolbytn/mindcraft.git'
2024-11-02 13:03:58 -05:00
3. Rename `keys.example.json` to `keys.json` and fill in your API keys (you only need one). The desired model is set in `andy.json` or other profiles. For other models refer to the table below.
4. In terminal/command prompt, run `npm install` from the installed directory
5. Start a minecraft world and open it to LAN on localhost port `55916`
6. Run `node main.js` from the installed directory
2025-06-09 01:46:08 -05:00
If you encounter issues, check the [FAQ](https://github.com/kolbytn/mindcraft/blob/main/FAQ.md) or find support on [discord](https://discord.gg/mp73p35dzC). We are currently not very responsive to github issues. To run tasks please refer to [Minecollab Instructions](minecollab.md#installation)
2024-11-02 14:08:59 -05:00
2025-04-26 11:20:14 -05:00
## Tasks
2025-04-23 13:21:48 -07:00
2025-04-26 11:20:14 -05:00
Bot performance can be roughly evaluated with Tasks. Tasks automatically intialize bots with a goal to aquire specific items or construct predefined buildings, and remove the bot once the goal is achieved.
2025-04-23 13:21:48 -07:00
2025-04-26 11:20:14 -05:00
To run tasks, you need python, pip, and optionally conda. You can then install dependencies with `pip install -r requirements.txt`.
2025-04-23 13:21:48 -07:00
2025-04-26 11:20:14 -05:00
Tasks are defined in json files in the `tasks` folder, and can be run with: `python tasks/run_task_file.py --task_path=tasks/example_tasks.json`
2025-04-23 13:21:48 -07:00
2025-04-26 11:20:14 -05:00
For full evaluations, you will need to [download and install the task suite. Full instructions.](minecollab.md#installation)
2025-04-23 13:21:48 -07:00
2025-02-17 13:54:12 -06:00
## Model Customization
2024-11-02 13:03:58 -05:00
You can configure project details in `settings.js`. [See file.](settings.js)
2025-02-17 13:54:12 -06:00
You can configure the agent's name, model, and prompts in their profile like `andy.json` with the `model` field. For comprehensive details, see [Model Specifications](#model-specifications).
2023-08-15 23:39:02 -07:00
2024-05-27 12:47:12 +01:00
| API | Config Variable | Example Model name | Docs |
2024-05-10 13:41:58 -05:00
|------|------|------|------|
2025-02-17 13:54:12 -06:00
| `openai` | `OPENAI_API_KEY` | `gpt-4o-mini` | [docs](https://platform.openai.com/docs/models) |
| `google` | `GEMINI_API_KEY` | `gemini-2.0-flash` | [docs](https://ai.google.dev/gemini-api/docs/models/gemini) |
2025-02-17 13:54:12 -06:00
| `anthropic` | `ANTHROPIC_API_KEY` | `claude-3-haiku-20240307` | [docs](https://docs.anthropic.com/claude/docs/models-overview) |
2025-03-04 15:56:39 -06:00
| `xai` | `XAI_API_KEY` | `grok-2-1212` | [docs](https://docs.x.ai/docs) |
| `deepseek` | `DEEPSEEK_API_KEY` | `deepseek-chat` | [docs](https://api-docs.deepseek.com/) |
2025-03-16 19:36:32 -05:00
| `ollama` (local) | n/a | `ollama/llama3.1` | [docs](https://ollama.com/library) |
2025-02-17 13:54:12 -06:00
| `qwen` | `QWEN_API_KEY` | `qwen-max` | [Intl.](https://www.alibabacloud.com/help/en/model-studio/developer-reference/use-qwen-by-calling-api)/[cn](https://help.aliyun.com/zh/model-studio/getting-started/models) |
2025-03-04 15:56:39 -06:00
| `mistral` | `MISTRAL_API_KEY` | `mistral-large-latest` | [docs](https://docs.mistral.ai/getting-started/models/models_overview/) |
| `replicate` | `REPLICATE_API_KEY` | `replicate/meta/meta-llama-3-70b-instruct` | [docs](https://replicate.com/collections/language-models) |
| `groq` (not grok) | `GROQCLOUD_API_KEY` | `groq/mixtral-8x7b-32768` | [docs](https://console.groq.com/docs/models) |
| `huggingface` | `HUGGINGFACE_API_KEY` | `huggingface/mistralai/Mistral-Nemo-Instruct-2407` | [docs](https://huggingface.co/models) |
| `novita` | `NOVITA_API_KEY` | `novita/deepseek/deepseek-r1` | [docs](https://novita.ai/model-api/product/llm-api?utm_source=github_mindcraft&utm_medium=github_readme&utm_campaign=link) |
2025-02-17 15:59:17 -06:00
| `openrouter` | `OPENROUTER_API_KEY` | `openrouter/anthropic/claude-3.5-sonnet` | [docs](https://openrouter.ai/models) |
| `glhf.chat` | `GHLF_API_KEY` | `glhf/hf:meta-llama/Llama-3.1-405B-Instruct` | [docs](https://glhf.chat/user-settings/api) |
| `hyperbolic` | `HYPERBOLIC_API_KEY` | `hyperbolic/deepseek-ai/DeepSeek-V3` | [docs](https://docs.hyperbolic.xyz/docs/getting-started) |
2025-04-26 11:20:14 -05:00
| `vllm` | n/a | `vllm/llama3` | n/a |
2025-05-12 10:52:24 -07:00
| `cerebras` | `CEREBRAS_API_KEY` | `cerebras/llama-3.3-70b` | [docs](https://inference-docs.cerebras.ai/introduction) |
2025-08-23 15:40:16 -05:00
| `mercury` | `MERCURY_API_KEY` | `mercury-coder-small` | [docs](https://www.inceptionlabs.ai/) |
2023-08-15 23:39:02 -07:00
2024-04-23 14:58:31 -07:00
If you use Ollama, to install the models used by default (generation and embedding), execute the following terminal command:
2025-03-04 17:05:42 -08:00
`ollama pull llama3.1 && ollama pull nomic-embed-text`
2024-04-05 17:25:06 -05:00
2025-08-23 16:14:30 -05:00
To use Azure, you can reuse the `OPENAI_API_KEY` environment variable. You can get the key from the Azure portal. See [azure.json](profiles/azure.json) for an example.
2025-02-17 13:54:12 -06:00
### Online Servers
2024-11-02 13:03:58 -05:00
To connect to online servers your bot will need an official Microsoft/Minecraft account. You can use your own personal one, but will need another account if you want to connect too and play with it. To connect, change these lines in `settings.js`:
```javascript
"host": "111.222.333.444",
"port": 55920,
"auth": "microsoft",
2024-11-02 13:03:58 -05:00
// rest is same...
```
2025-02-17 13:54:12 -06:00
> [!Important]
2025-01-25 10:53:22 -06:00
> The bot's name in the profile.json must exactly match the Minecraft profile name! Otherwise the bot will spam talk to itself.
2024-04-05 17:25:06 -05:00
2024-11-02 14:08:59 -05:00
To use different accounts, Mindcraft will connect with the account that the Minecraft launcher is currently using. You can switch accounts in the launcer, then run `node main.js`, then switch to your main account after the bot has connected.
2024-11-02 13:03:58 -05:00
### Docker Container
2024-11-02 13:03:58 -05:00
If you intend to `allow_insecure_coding`, it is a good idea to run the app in a docker container to reduce risks of running unknown code. This is strongly recommended before connecting to remote servers.
2024-10-25 10:30:32 +02:00
```bash
docker run -i -t --rm -v $(pwd):/app -w /app -p 3000-3003:3000-3003 node:latest node main.js
```
or simply
```bash
docker-compose up
```
2024-10-25 10:52:58 +02:00
When running in docker, if you want the bot to join your local minecraft server, you have to use a special host address `host.docker.internal` to call your localhost from inside your docker container. Put this into your [settings.js](settings.js):
2024-10-25 10:30:32 +02:00
```javascript
2024-10-25 10:52:58 +02:00
"host": "host.docker.internal", // instead of "localhost", to join your local minecraft from inside the docker container
2024-10-25 10:30:32 +02:00
```
To connect to an unsupported minecraft version, you can try to use [viaproxy](services/viaproxy/README.md)
2025-02-17 13:54:12 -06:00
# Bot Profiles
2024-04-24 11:28:04 -07:00
2024-05-10 13:41:58 -05:00
Bot profiles are json files (such as `andy.json`) that define:
2024-04-24 11:28:04 -07:00
2025-02-17 13:54:12 -06:00
1. Bot backend LLMs to use for talking, coding, and embedding.
2024-04-24 11:28:04 -07:00
2. Prompts used to influence the bot's behavior.
2024-05-10 13:41:58 -05:00
3. Examples help the bot perform tasks.
2025-02-17 13:54:12 -06:00
## Model Specifications
2024-09-08 21:07:25 -04:00
2025-02-17 13:54:12 -06:00
LLM models can be specified simply as `"model": "gpt-4o"`. However, you can use different models for chat, coding, and embeddings.
2025-02-04 15:00:55 -06:00
You can pass a string or an object for these fields. A model object must specify an `api`, and optionally a `model`, `url`, and additional `params`.
2024-04-24 11:28:04 -07:00
```json
2024-04-24 11:28:04 -07:00
"model": {
"api": "openai",
2025-02-04 15:00:55 -06:00
"model": "gpt-4o",
2024-04-24 11:28:04 -07:00
"url": "https://api.openai.com/v1/",
2025-02-04 15:00:55 -06:00
"params": {
"max_tokens": 1000,
"temperature": 1
}
},
"code_model": {
"api": "openai",
"model": "gpt-4",
"url": "https://api.openai.com/v1/"
2024-04-24 11:28:04 -07:00
},
2025-02-09 22:08:13 +09:00
"vision_model": {
"api": "openai",
"model": "gpt-4o",
"url": "https://api.openai.com/v1/"
},
2024-04-24 11:28:04 -07:00
"embedding": {
"api": "openai",
"url": "https://api.openai.com/v1/",
"model": "text-embedding-ada-002"
}
2025-02-04 15:00:55 -06:00
```
2024-04-24 11:28:04 -07:00
2025-03-05 15:30:19 -06:00
`model` is used for chat, `code_model` is used for newAction coding, `vision_model` is used for image interpretation, and `embedding` is used to embed text for example selection. If `code_model` or `vision_model` is not specified, `model` will be used by default. Not all APIs support embeddings or vision.
2025-02-17 13:54:12 -06:00
All apis have default models and urls, so those fields are optional. The `params` field is optional and can be used to specify additional parameters for the model. It accepts any key-value pairs supported by the api. Is not supported for embedding models.
## Embedding Models
Embedding models are used to embed and efficiently select relevant examples for conversation and coding.
2025-02-17 16:47:45 -06:00
Supported Embedding APIs: `openai`, `google`, `replicate`, `huggingface`, `novita`
2025-02-17 13:54:12 -06:00
If you try to use an unsupported model, then it will default to a simple word-overlap method. Expect reduced performance, recommend mixing APIs to ensure embedding support.
2024-04-24 11:28:04 -07:00
2025-02-17 13:54:12 -06:00
## Specifying Profiles via Command Line
2024-04-24 11:28:04 -07:00
2025-02-17 13:54:12 -06:00
By default, the program will use the profiles specified in `settings.js`. You can specify one or more agent profiles using the `--profiles` argument: `node main.js --profiles ./profiles/andy.json ./profiles/jill.json`
2023-12-04 21:33:40 -06:00
## Patches
2023-11-27 21:07:52 -06:00
2024-02-17 16:42:10 -06:00
Some of the node modules that we depend on have bugs in them. To add a patch, change your local node module file and run `npx patch-package [package-name]`
2024-11-06 09:48:53 -08:00
## Citation:
2024-11-06 09:49:59 -08:00
2024-11-06 09:48:53 -08:00
```
2025-05-21 09:48:28 -07:00
@article{mindcraft2025,
2025-05-21 09:44:47 -07:00
title = {Collaborating Action by Action: A Multi-agent LLM Framework for Embodied Reasoning},
author = {White*, Isadora and Nottingham*, Kolby and Maniar, Ayush and Robinson, Max and Lillemark, Hansen and Maheshwari, Mehul and Qin, Lianhui and Ammanabrolu, Prithviraj},
journal = {arXiv preprint arXiv:2504.17950},
year = {2025},
url = {https://arxiv.org/abs/2504.17950},
2024-11-06 09:48:53 -08:00
}
```
2025-08-23 13:40:00 -04:00