mindcraft/README.md

133 lines
5.9 KiB
Markdown
Raw Normal View History

# Mindcraft 🧠⛏️
2023-08-15 23:39:02 -07:00
Crafting minds for Minecraft with Language Models and Mineflayer!
2023-08-15 23:39:02 -07:00
2024-10-06 14:23:33 -05:00
[Join the discord for support!](https://discord.gg/ZsrAAByEnr)
2024-01-30 22:26:27 -06:00
#### ‼️Warning‼️
2024-01-30 16:43:30 -06:00
2024-05-29 22:04:30 -05:00
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.
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
2024-10-27 15:06:23 -05:00
- [Minecraft Java Edition](https://www.minecraft.net/en-us/store/minecraft-java-bedrock-edition-pc) (up to v1.21.1)
2024-01-30 22:26:27 -06:00
- [Node.js](https://nodejs.org/) (at least v14)
2024-10-20 11:53:18 -05:00
- 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)
2024-01-30 16:43:30 -06:00
2023-08-15 23:39:02 -07:00
## Installation
2024-05-30 18:00:48 -05:00
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.
2024-05-27 12:47:12 +01:00
| API | Config Variable | Example Model name | Docs |
2024-05-10 13:41:58 -05:00
|------|------|------|------|
| OpenAI | `OPENAI_API_KEY` | `gpt-3.5-turbo` | [docs](https://platform.openai.com/docs/models) | (optionally add `OPENAI_ORG_ID`)
| Google | `GEMINI_API_KEY` | `gemini-pro` | [docs](https://ai.google.dev/gemini-api/docs/models/gemini) |
| Anthropic | `ANTHROPIC_API_KEY` | `claude-3-haiku-20240307` | [docs](https://docs.anthropic.com/claude/docs/models-overview) |
| Replicate | `REPLICATE_API_KEY` | `meta/meta-llama-3-70b-instruct` | [docs](https://replicate.com/collections/language-models) |
| Ollama (local) | n/a | `llama3` | [docs](https://ollama.com/library) |
2024-08-31 15:29:34 -07:00
| Groq | `GROQCLOUD_API_KEY` | `groq/mixtral-8x7b-32768` | [docs](https://console.groq.com/docs/models) |
| Hugging Face | `HUGGINGFACE_API_KEY` | `huggingface/mistralai/Mistral-Nemo-Instruct-2407` | [docs](https://huggingface.co/models) |
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:
`ollama pull llama3 && ollama pull nomic-embed-text`
2024-04-05 17:25:06 -05:00
2024-04-08 13:31:20 +02:00
Then, clone/download this repository
2023-08-15 23:39:02 -07:00
2024-05-29 22:04:30 -05:00
Run `npm install` from the installed directory
2023-08-15 23:39:02 -07:00
2024-10-27 15:06:23 -05:00
Install the minecraft version specified in `settings.js`, currently supports up to 1.21.1
2024-02-17 16:42:10 -06:00
2024-05-10 13:41:58 -05:00
### Running Locally
2024-01-30 16:43:30 -06:00
2024-01-30 22:26:27 -06:00
Start a minecraft world and open it to LAN on localhost port `55916`
2024-01-30 16:43:30 -06:00
Run `node main.js`
You can configure the agent's name, model, and prompts in their profile like `andy.json`.
2024-05-29 22:04:30 -05:00
You can configure project details in `settings.js`. [See file for more details](settings.js)
2024-04-05 17:25:06 -05:00
### Run in docker to reduce some of the risks
2024-10-25 10:52:58 +02:00
If you intent to `allow_insecure_coding`, it might be a good idea to put the whole app into a docker container to reduce risks of running unknown code.
2024-10-25 10:30:32 +02:00
```bash
2024-10-25 10:52:58 +02:00
docker run -i -t --rm -v $(pwd):/app -w /app 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
```
2024-05-10 13:41:58 -05:00
### Online Servers
2024-05-29 22:04:30 -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 with it. Here are example settings for this:
```javascript
2024-05-29 22:04:30 -05:00
"host": "111.222.333.444",
"port": 55920,
"auth": "microsoft",
// rest is same...
2024-05-10 13:41:58 -05:00
```
2024-09-20 15:19:30 -07:00
‼️ Please make sure your bot's name in the profile.json matches the account name! Otherwise the bot will spam talk to itself.
2024-05-10 13:41:58 -05: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
1. Bot backend LLMs to use for chat and embeddings.
2. Prompts used to influence the bot's behavior.
2024-05-10 13:41:58 -05:00
3. Examples help the bot perform tasks.
2024-09-08 21:07:25 -04:00
### Specifying Profiles via Command Line
By default, the program will use the profiles specified in `settings.js`. You can specify one or more agent profiles using the `--profiles` argument:
```bash
node main.js --profiles ./profiles/andy.json ./profiles/jill.json
```
2024-04-24 11:28:04 -07:00
### Model Specifications
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:
```json
2024-04-24 11:28:04 -07:00
"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:
```json
2024-04-24 11:28:04 -07:00
"model": "gpt-3.5-turbo"
```
```json
2024-04-24 11:28:04 -07:00
"model": {
"api": "openai"
}
```
```json
2024-04-24 11:28:04 -07:00
"model": "gpt-3.5-turbo",
"embedding": "openai"
```
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]`