Merge pull request #229 from keneo/patch-1

Instruction on how to run the bot in the docker to reduce some of the risks of running unknown code
This commit is contained in:
Max Robinson 2024-11-02 10:35:05 -05:00 committed by GitHub
commit a33e34aebb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 80 additions and 7 deletions

8
.gitignore vendored
View file

@ -5,4 +5,10 @@ code_records/
scratch.js
bots/**/action-code/**
bots/**/
keys.json
keys.json
services/viaproxy/jars/**
services/viaproxy/logs/**
services/viaproxy/plugins/**
services/viaproxy/ViaLoader/**
services/viaproxy/saves.json
services/viaproxy/viaproxy.yml

View file

@ -46,9 +46,29 @@ You can configure the agent's name, model, and prompts in their profile like `an
You can configure project details in `settings.js`. [See file for more details](settings.js)
### Run in docker to reduce some of the risks
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.
```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
```
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):
```javascript
"host": "host.docker.internal", // instead of "localhost", to join your local minecraft from inside the docker container
```
To connect to an unsupported minecraft version, you can try to use [viaproxy](services/viaproxy/README.md)
### Online Servers
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
"host": "111.222.333.444",
"port": 55920,
"auth": "microsoft",
@ -69,13 +89,15 @@ Bot profiles are json files (such as `andy.json`) that define:
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`
```bash
node main.js --profiles ./profiles/andy.json ./profiles/jill.json
```
### 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
"model": {
"api": "openai",
"url": "https://api.openai.com/v1/",
@ -94,15 +116,15 @@ If the embedding field is not specified, then it will use the default embedding
Thus, all the below specifications are equivalent to the above example:
```
```json
"model": "gpt-3.5-turbo"
```
```
```json
"model": {
"api": "openai"
}
```
```
```json
"model": "gpt-3.5-turbo",
"embedding": "openai"
```

20
docker-compose.yml Normal file
View file

@ -0,0 +1,20 @@
version: '3.8'
services:
app:
image: node:latest
working_dir: /app
volumes:
- .:/app
command: node main.js
ports:
- "3000-3003:3000-3003" # see the view from the camera mounted on your bot head: http://localhost:3000/
viaproxy: #use this service to connect to an unsupported minecraft server versions. more info: ./services/viaproxy/README.md
image: ghcr.io/viaversion/viaproxy:latest
volumes:
- ./services/viaproxy:/app/run
ports:
- "25568:25568"
profiles:
- viaproxy

View file

@ -0,0 +1,25 @@
Use this service to connect your bot to an unsupported minecraft server versions.
Run:
```bash
docker-compose --profile viaproxy up
```
After first start it will create config file `services/viaproxy/viaproxy.yml`.
Edit this file, and change your desired target `target-address`,
then point your `settings.js` `host` and `port` to viaproxy endpoint:
```javascript
"host": "host.docker.internal",
"port": 25568,
```
This easily works with "offline" servers.
Connecting to "online" servers via viaproxy involves more effort: see `auth-method` in `services/viaproxy/viaproxy.yml` (TODO describe)