Crafting minds for Minecraft with Language Models and Mineflayer!
This project allows an AI model to write/execute code on your computer that may be insecure, dangerous, and vulnerable to injection attacks on public servers. Code writing is disabled by default, you can enable it by setting allow_insecure_coding
to true
in settings.js
. Enable only on local or private servers, never on public servers. Ye be warned.
- Minecraft Java Edition (up to v1.20.4)
- Node.js (at least v14)
- One of these: OpenAI API Key | Gemini API Key |Anthropic API Key | Replicate API Key | Hugging Face API Key | Groq API Key | Ollama Installed
Rename keys.example.json
to keys.json
and fill in your API keys, and you can set the desired model in andy.json
or other profiles.
API | Config Variable | Example Model name | Docs |
---|---|---|---|
OpenAI | OPENAI_API_KEY |
gpt-3.5-turbo |
docs |
GEMINI_API_KEY |
gemini-pro |
docs | |
Anthropic | ANTHROPIC_API_KEY |
claude-3-haiku-20240307 |
docs |
Replicate | REPLICATE_API_KEY |
meta/meta-llama-3-70b-instruct |
docs |
Ollama (local) | n/a | llama3 |
docs |
Groq | GROQCLOUD_API_KEY |
groq/mixtral-8x7b-32768 |
docs |
Hugging Face | HUGGINGFACE_API_KEY |
huggingface/mistralai/Mistral-Nemo-Instruct-2407 |
docs |
If you use Ollama, to install the models used by default (generation and embedding), execute the following terminal command:
ollama pull llama3 && ollama pull nomic-embed-text
Then, clone/download this repository
Run npm install
from the installed directory
Install the minecraft version specified in settings.js
, currently supports up to 1.20.4
Start a minecraft world and open it to LAN on localhost port 55916
Run node main.js
You can configure the agent's name, model, and prompts in their profile like andy.json
.
You can configure project details in settings.js
. See file for more details
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 with it. Here are example settings for this:
"host": "111.222.333.444",
"port": 55920,
"auth": "microsoft",
// rest is same...
Bot profiles are json files (such as andy.json
) that define:
- Bot backend LLMs to use for chat and embeddings.
- Prompts used to influence the bot's behavior.
- Examples help the bot perform tasks.
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
LLM backends can be specified as simply as "model": "gpt-3.5-turbo"
. However, for both the chat model and the embedding model, the bot profile can specify the below attributes:
"model": {
"api": "openai",
"url": "https://api.openai.com/v1/",
"model": "gpt-3.5-turbo"
},
"embedding": {
"api": "openai",
"url": "https://api.openai.com/v1/",
"model": "text-embedding-ada-002"
}
The model parameter accepts either a string or object. If a string, it should specify the model to be used. The api and url will be assumed. If an object, the api field must be specified. Each api has a default model and url, so those fields are optional.
If the embedding field is not specified, then it will use the default embedding method for the chat model's api (Note that anthropic has no embedding model). The embedding parameter can also be a string or object. If a string, it should specify the embedding api and the default model and url will be used. If a valid embedding is not specified and cannot be assumed, then word overlap will be used to retrieve examples instead.
Thus, all the below specifications are equivalent to the above example:
"model": "gpt-3.5-turbo"
"model": {
"api": "openai"
}
"model": "gpt-3.5-turbo",
"embedding": "openai"
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]