mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-06-06 17:25:54 +02:00
Merge branch 'main' into self-prompt
This commit is contained in:
commit
46aa27fdfc
32 changed files with 928 additions and 144 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,6 +1,8 @@
|
|||
.vscode/
|
||||
node_modules/
|
||||
package-lock.json
|
||||
code_records/
|
||||
scratch.js
|
||||
bots/**/action-code/**
|
||||
bots/**/
|
||||
keys.json
|
23
README.md
23
README.md
|
@ -4,7 +4,7 @@ Crafting minds for Minecraft with Language Models and Mineflayer!
|
|||
|
||||
#### ‼️Warning‼️
|
||||
|
||||
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.json`. Enable only on local or private servers, **never** on public servers. Ye be warned.
|
||||
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.
|
||||
|
||||
## Requirements
|
||||
|
||||
|
@ -14,9 +14,8 @@ This project allows an AI model to write/execute code on your computer that may
|
|||
|
||||
## Installation
|
||||
|
||||
Add the environment variable for the model you want to use:
|
||||
|
||||
| API | Env Variable | Example Model name | Docs |
|
||||
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](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) |
|
||||
|
@ -24,16 +23,14 @@ Add the environment variable for the model you want to use:
|
|||
| 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) |
|
||||
|
||||
⭐[How do I add the API key as an environment variable?](https://phoenixnap.com/kb/windows-set-environment-variable)⭐
|
||||
|
||||
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`
|
||||
Run `npm install` from the installed directory
|
||||
|
||||
Install the minecraft version specified in `settings.json`, currently supports up to 1.20.4
|
||||
Install the minecraft version specified in `settings.js`, currently supports up to 1.20.4
|
||||
|
||||
### Running Locally
|
||||
|
||||
|
@ -43,18 +40,16 @@ 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.json`.
|
||||
You can configure project details in `settings.js`. [See file for more details](settings.js)
|
||||
|
||||
### 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 is an example settings for this:
|
||||
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:
|
||||
```
|
||||
{
|
||||
"minecraft_version": "1.20.4",
|
||||
"host": "111.222.333.444",
|
||||
"port": 55920,
|
||||
"auth": "microsoft",
|
||||
"allow_insecure_coding": false
|
||||
}
|
||||
|
||||
// rest is same...
|
||||
```
|
||||
‼️Make sure your bot's name in the profile.json matches the account name! Otherwise the bot will spam talk to itself.
|
||||
|
||||
|
|
11
andy.json
11
andy.json
|
@ -9,6 +9,17 @@
|
|||
|
||||
"saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation in your next response. Store information that will help you improve as a Minecraft bot. Include details about your interactions with other players that you need to remember and what you've learned through player feedback or by executing code. Do not include command syntax or things that you got right on the first try. Be extremely brief and use as few words as possible.\nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the memory text: ",
|
||||
|
||||
"modes": {
|
||||
"self_preservation": true,
|
||||
"cowardice": true,
|
||||
"self_defense": true,
|
||||
"hunting": true,
|
||||
"item_collecting": true,
|
||||
"torch_placing": true,
|
||||
"idle_staring": true,
|
||||
"cheat": false
|
||||
},
|
||||
|
||||
"conversation_examples": [
|
||||
[
|
||||
{"role": "user", "content": "miner_32: Hey! What are you up to?"},
|
||||
|
|
7
keys.example.json
Normal file
7
keys.example.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"OPENAI_API_KEY": "",
|
||||
"OPENAI_ORG_ID": "",
|
||||
"GEMINI_API_KEY": "",
|
||||
"ANTHROPIC_API_KEY": "",
|
||||
"REPLICATE_API_KEY": ""
|
||||
}
|
8
main.js
8
main.js
|
@ -1,7 +1,9 @@
|
|||
import { AgentProcess } from './src/process/agent-process.js';
|
||||
import settings from './settings.js';
|
||||
|
||||
let profile = './andy.json';
|
||||
let load_memory = false;
|
||||
let init_message = 'Say hello world and your name.';
|
||||
let profiles = settings.profiles;
|
||||
let load_memory = settings.load_memory;
|
||||
let init_message = settings.init_message;
|
||||
|
||||
for (let profile of profiles)
|
||||
new AgentProcess().start(profile, load_memory, init_message);
|
|
@ -17,6 +17,7 @@
|
|||
"yargs": "^17.7.2"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "patch-package"
|
||||
"postinstall": "patch-package",
|
||||
"start": "node main.js"
|
||||
}
|
||||
}
|
||||
|
|
167
profiles/claude.json
Normal file
167
profiles/claude.json
Normal file
|
@ -0,0 +1,167 @@
|
|||
{
|
||||
"name": "claude",
|
||||
|
||||
"model": "claude-3-opus-20240229",
|
||||
|
||||
"conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands. Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. Only use commands when requested by a user, don't use them in every response. This is extremely important to me, take a deep breath and have fun :)\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:",
|
||||
|
||||
"coding": "You are an intelligent mineflayer bot $NAME that plays minecraft by writing javascript codeblocks. Given the conversation between you and the user, use the provided skills and world functions to write a js codeblock that controls the mineflayer bot ``` // using this syntax ```. The code will be executed and you will recieve it's output. If you are satisfied with the response, respond without a codeblock in a conversational way. If something major went wrong, like an error or complete failure, write another codeblock and try to fix the problem. Minor mistakes are acceptable. Be maximally efficient, creative, and clear. Do not use commands !likeThis, only use codeblocks. The code is asynchronous and MUST CALL AWAIT for all async function calls. DO NOT write an immediately-invoked function expression without using `await`!! DO NOT WRITE LIKE THIS: ```(async () => {console.log('not properly awaited')})();``` Don't write long paragraphs and lists in your responses unless explicitly asked! Only summarize the code you write with a sentence or two when done. This is extremely important to me, take a deep breath and good luck! \n$STATS\n$INVENTORY\n$CODE_DOCS\n$EXAMPLES\nConversation:",
|
||||
|
||||
"saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation in your next response. Store information that will help you improve as a Minecraft bot. Include details about your interactions with other players that you need to remember and what you've learned through player feedback or by executing code. Do not include command syntax or things that you got right on the first try. Be extremely brief and use as few words as possible.\nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the memory text: ",
|
||||
|
||||
"modes": {
|
||||
"self_preservation": false,
|
||||
"cowardice": false,
|
||||
"self_defense": false,
|
||||
"hunting": false,
|
||||
"item_collecting": true,
|
||||
"torch_placing": false,
|
||||
"idle_staring": true,
|
||||
"cheat": true
|
||||
},
|
||||
|
||||
"conversation_examples": [
|
||||
[
|
||||
{"role": "user", "content": "miner_32: Hey! What are you up to?"},
|
||||
{"role": "assistant", "content": "Nothing much miner_32, what do you need?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "grombo_Xx: What do you see?"},
|
||||
{"role": "assistant", "content": "Let me see... !nearbyBlocks"},
|
||||
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone."}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "greg: Collect 10 wood"},
|
||||
{"role": "assistant", "content": "Let me see what's nearby... !nearbyBlocks"},
|
||||
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone. I'll collect oak logs. !collectBlocks('oak_log', 10)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "bobby: Craft a plank"},
|
||||
{"role": "assistant", "content": "Okay! !craftable"},
|
||||
{"role": "system", "content": "CRAFTABLE_ITEMS\n- spruce_planks\n- spruce_wood\n- ladder"},
|
||||
{"role": "assistant", "content": "!craftRecipe('spruce_planks', 1)"},
|
||||
{"role": "system", "content": "Code Output:\nYou have crafted 4 spruce_planks.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "I've crafted 4 spruce planks!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "zZZn98: come here"},
|
||||
{"role": "assistant", "content": "On my way! !goToPlayer('zZZn98', 3)"},
|
||||
{"role": "system", "content": "Arrived at player."},
|
||||
{"role": "assistant", "content": "Here!"},
|
||||
{"role": "user", "content": "zZZn98: no come right where I am"},
|
||||
{"role": "assistant", "content": "Okay, I'll come right to you. !goToPlayer('zZZn98', 0)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "hanky: collect some sand and give it to me please"},
|
||||
{"role": "assistant", "content": "Collecting sand... !newAction"},
|
||||
{"role": "system", "content": "Code Output:\nYou have reached player hanky.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "Here!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "joe: Follow me!"},
|
||||
{"role": "assistant", "content": "Sure! !followPlayer('joe', 4)"},
|
||||
{"role": "user", "content": "joe: Not so close!"},
|
||||
{"role": "assistant", "content": "Okay, I'll keep my distance. !followPlayer('joe', 3)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "hanky: kill that zombie!"},
|
||||
{"role": "assistant", "content": "I'm attacking! !attack('zombie')"},
|
||||
{"role": "system", "content": "Code Output:\nNo zombie nearby"},
|
||||
{"role": "assistant", "content": "I could not find a zombie nearby."}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "abc: stop"},
|
||||
{"role": "assistant", "content": "Sure. !stop"},
|
||||
{"role": "system", "content": "Agent action stopped."},
|
||||
{"role": "assistant", "content": "I've stopped! What next?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
||||
{"role": "assistant", "content": "!newAction`"},
|
||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
||||
{"role": "assistant", "content": "Apologies, I made an error. Would you like me to try again?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "trixy88: craft some sticks"},
|
||||
{"role": "assistant", "content": "!craftRecipe('stick', 4)"},
|
||||
{"role": "system", "content": "Code Output:\nYou have crafted 16 sticks.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "I've crafted 16 sticks!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "poppy: build a cobblestone house"},
|
||||
{"role": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "zib: build a dirt tower"},
|
||||
{"role": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "umpire_man: follow me without hunting"},
|
||||
{"role": "assistant", "content": "Okay, first I'll turn off hunting mode !setMode('hunting', false)"},
|
||||
{"role": "system", "content": "'hunting' mode disabled."},
|
||||
{"role": "assistant", "content": "Now I'll follow you !followPlayer('umpire_man')"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "brug: Remember that your base is here."},
|
||||
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
||||
{"role": "user", "content": "brug: Go to your base."},
|
||||
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
||||
]
|
||||
],
|
||||
|
||||
"coding_examples": [
|
||||
[
|
||||
{"role": "user", "content": "greg: Collect 10 wood"},
|
||||
{"role": "assistant", "content": "```await skills.collectBlock(bot, 'oak_log', 10);\n```"},
|
||||
{"role": "system", "content": "Successfully collected 9 wood."},
|
||||
{"role": "assistant", "content": "I collected 9 oak logs, what next?"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "bobby: cook some chicken"},
|
||||
{"role": "assistant", "content": "```await skills.smeltItem(bot, 'chicken', 8);\n```"},
|
||||
{"role": "system", "content": "Successfully smelted 8 chicken into 8 cooked_chicken."},
|
||||
{"role": "assistant", "content": "I have cooked 8 chicken."}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "zZZn98: come here"},
|
||||
{"role": "assistant", "content": "```await skills.goToPlayer(bot, 'zZZn98');\n```"},
|
||||
{"role": "system", "content": "Code execution finished successfully."},
|
||||
{"role": "assistant", "content": "Here!"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
||||
{"role": "assistant", "content": "```await skills.goToPosition(bot, nearestOakLog.x, nearestOakLog.y, nearestOakLog.z);\n```"},
|
||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
||||
{"role": "assistant", "content": "Apologies, I made an error. Let me try that again.```\n// I am navigating to the nearest oak log.\nlet position = world.getNearestBlock(bot, 'oak_log', 20);\nawait skills.goToPosition(bot, position.x, position.y, position.z);\n```"},
|
||||
{"role": "system", "content": "Arrived at location."},
|
||||
{"role": "assistant", "content": "I found an oak log and I am now standing next to it. What next?"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "234jeb: build a little tower"},
|
||||
{"role": "assistant", "content": "```let pos = bot.entity.position;\nfor (let i = 0; i < 5; i++) {\n await skills.placeBlock(bot, 'dirt', pos.x, pos.y + i, pos.z);\n}\n```"},
|
||||
{"role": "system", "content": "Successfully placed 5 dirt."},
|
||||
{"role": "assistant", "content": "I built a little tower!"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "brug: build a dirt house"},
|
||||
{"role": "assistant", "content": "```const position = world.getPosition(bot);\nconst startX = position.x;\nconst startY = position.y;\nconst startZ = position.z;\nconst width = 7;\nconst depth = 7;\nconst height = 4;\n\n// Build the walls\nfor (let x = startX; x < startX + width; x++) {\n for (let y = startY; y < startY + height; y++) {\n for (let z = startZ; z < startZ + depth; z++) {\n if (x === startX || x === startX + width - 1 || y === startY || y === startY + height - 1 || z === startZ || z === startZ + depth - 1) {\n await skills.placeBlock(bot, 'oak_planks', x, y, z); \n }\n }\n }\n}\n```"}
|
||||
]
|
||||
]
|
||||
|
||||
}
|
167
profiles/gemini.json
Normal file
167
profiles/gemini.json
Normal file
|
@ -0,0 +1,167 @@
|
|||
{
|
||||
"name": "gemini",
|
||||
|
||||
"model": "gemini-1.5-pro",
|
||||
|
||||
"conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands. Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. This is extremely important to me, take a deep breath and have fun :)\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:",
|
||||
|
||||
"coding": "You are an intelligent mineflayer bot $NAME that plays minecraft by writing javascript codeblocks. Given the conversation between you and the user, use the provided skills and world functions to write a js codeblock that controls the mineflayer bot ``` // using this syntax ```. The code will be executed and you will recieve it's output. If you are satisfied with the response, respond without a codeblock in a conversational way. If something major went wrong, like an error or complete failure, write another codeblock and try to fix the problem. Minor mistakes are acceptable. Be maximally efficient, creative, and clear. Do not use commands !likeThis, only use codeblocks. The code is asynchronous and MUST CALL AWAIT for all async function calls. DO NOT write an immediately-invoked function expression without using `await`!! DO NOT WRITE LIKE THIS: ```(async () => {console.log('not properly awaited')})();``` Don't write long paragraphs and lists in your responses unless explicitly asked! Only summarize the code you write with a sentence or two when done. This is extremely important to me, take a deep breath and good luck! \n$STATS\n$INVENTORY\n$CODE_DOCS\n$EXAMPLES\nConversation:",
|
||||
|
||||
"saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation in your next response. Store information that will help you improve as a Minecraft bot. Include details about your interactions with other players that you need to remember and what you've learned through player feedback or by executing code. Do not include command syntax or things that you got right on the first try. Be extremely brief and use as few words as possible.\nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the memory text: ",
|
||||
|
||||
"modes": {
|
||||
"self_preservation": false,
|
||||
"cowardice": false,
|
||||
"self_defense": false,
|
||||
"hunting": false,
|
||||
"item_collecting": true,
|
||||
"torch_placing": false,
|
||||
"idle_staring": true,
|
||||
"cheat": true
|
||||
},
|
||||
|
||||
"conversation_examples": [
|
||||
[
|
||||
{"role": "user", "content": "miner_32: Hey! What are you up to?"},
|
||||
{"role": "assistant", "content": "Nothing much miner_32, what do you need?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "grombo_Xx: What do you see?"},
|
||||
{"role": "assistant", "content": "Let me see... !nearbyBlocks"},
|
||||
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone."}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "greg: Collect 10 wood"},
|
||||
{"role": "assistant", "content": "Let me see what's nearby... !nearbyBlocks"},
|
||||
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone. I'll collect oak logs. !collectBlocks('oak_log', 10)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "bobby: Craft a plank"},
|
||||
{"role": "assistant", "content": "Okay! !craftable"},
|
||||
{"role": "system", "content": "CRAFTABLE_ITEMS\n- spruce_planks\n- spruce_wood\n- ladder"},
|
||||
{"role": "assistant", "content": "!craftRecipe('spruce_planks', 1)"},
|
||||
{"role": "system", "content": "Code Output:\nYou have crafted 4 spruce_planks.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "I've crafted 4 spruce planks!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "zZZn98: come here"},
|
||||
{"role": "assistant", "content": "On my way! !goToPlayer('zZZn98', 3)"},
|
||||
{"role": "system", "content": "Arrived at player."},
|
||||
{"role": "assistant", "content": "Here!"},
|
||||
{"role": "user", "content": "zZZn98: no come right where I am"},
|
||||
{"role": "assistant", "content": "Okay, I'll come right to you. !goToPlayer('zZZn98', 0)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "hanky: collect some sand and give it to me please"},
|
||||
{"role": "assistant", "content": "Collecting sand... !newAction"},
|
||||
{"role": "system", "content": "Code Output:\nYou have reached player hanky.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "Here!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "joe: Follow me!"},
|
||||
{"role": "assistant", "content": "Sure! !followPlayer('joe', 4)"},
|
||||
{"role": "user", "content": "joe: Not so close!"},
|
||||
{"role": "assistant", "content": "Okay, I'll keep my distance. !followPlayer('joe', 3)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "hanky: kill that zombie!"},
|
||||
{"role": "assistant", "content": "I'm attacking! !attack('zombie')"},
|
||||
{"role": "system", "content": "Code Output:\nNo zombie nearby"},
|
||||
{"role": "assistant", "content": "I could not find a zombie nearby."}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "abc: stop"},
|
||||
{"role": "assistant", "content": "Sure. !stop"},
|
||||
{"role": "system", "content": "Agent action stopped."},
|
||||
{"role": "assistant", "content": "I've stopped! What next?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
||||
{"role": "assistant", "content": "!newAction`"},
|
||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
||||
{"role": "assistant", "content": "Apologies, I made an error. Would you like me to try again?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "trixy88: craft some sticks"},
|
||||
{"role": "assistant", "content": "!craftRecipe('stick', 4)"},
|
||||
{"role": "system", "content": "Code Output:\nYou have crafted 16 sticks.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "I've crafted 16 sticks!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "poppy: build a cobblestone house"},
|
||||
{"role": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "zib: build a dirt tower"},
|
||||
{"role": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "umpire_man: follow me without hunting"},
|
||||
{"role": "assistant", "content": "Okay, first I'll turn off hunting mode !setMode('hunting', false)"},
|
||||
{"role": "system", "content": "'hunting' mode disabled."},
|
||||
{"role": "assistant", "content": "Now I'll follow you !followPlayer('umpire_man')"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "brug: Remember that your base is here."},
|
||||
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
||||
{"role": "user", "content": "brug: Go to your base."},
|
||||
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
||||
]
|
||||
],
|
||||
|
||||
"coding_examples": [
|
||||
[
|
||||
{"role": "user", "content": "greg: Collect 10 wood"},
|
||||
{"role": "assistant", "content": "```await skills.collectBlock(bot, 'oak_log', 10);\n```"},
|
||||
{"role": "system", "content": "Successfully collected 9 wood."},
|
||||
{"role": "assistant", "content": "I collected 9 oak logs, what next?"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "bobby: cook some chicken"},
|
||||
{"role": "assistant", "content": "```await skills.smeltItem(bot, 'chicken', 8);\n```"},
|
||||
{"role": "system", "content": "Successfully smelted 8 chicken into 8 cooked_chicken."},
|
||||
{"role": "assistant", "content": "I have cooked 8 chicken."}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "zZZn98: come here"},
|
||||
{"role": "assistant", "content": "```await skills.goToPlayer(bot, 'zZZn98');\n```"},
|
||||
{"role": "system", "content": "Code execution finished successfully."},
|
||||
{"role": "assistant", "content": "Here!"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
||||
{"role": "assistant", "content": "```await skills.goToPosition(bot, nearestOakLog.x, nearestOakLog.y, nearestOakLog.z);\n```"},
|
||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
||||
{"role": "assistant", "content": "Apologies, I made an error. Let me try that again.```\n// I am navigating to the nearest oak log.\nlet position = world.getNearestBlock(bot, 'oak_log', 20);\nawait skills.goToPosition(bot, position.x, position.y, position.z);\n```"},
|
||||
{"role": "system", "content": "Arrived at location."},
|
||||
{"role": "assistant", "content": "I found an oak log and I am now standing next to it. What next?"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "234jeb: build a little tower"},
|
||||
{"role": "assistant", "content": "```let pos = bot.entity.position;\nfor (let i = 0; i < 5; i++) {\n await skills.placeBlock(bot, 'dirt', pos.x, pos.y + i, pos.z);\n}\n```"},
|
||||
{"role": "system", "content": "Successfully placed 5 dirt."},
|
||||
{"role": "assistant", "content": "I built a little tower!"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "brug: build a dirt house"},
|
||||
{"role": "assistant", "content": "```const position = world.getPosition(bot);\nconst startX = position.x;\nconst startY = position.y;\nconst startZ = position.z;\nconst width = 7;\nconst depth = 7;\nconst height = 4;\n\n// Build the walls\nfor (let x = startX; x < startX + width; x++) {\n for (let y = startY; y < startY + height; y++) {\n for (let z = startZ; z < startZ + depth; z++) {\n if (x === startX || x === startX + width - 1 || y === startY || y === startY + height - 1 || z === startZ || z === startZ + depth - 1) {\n await skills.placeBlock(bot, 'oak_planks', x, y, z); \n }\n }\n }\n}\n```"}
|
||||
]
|
||||
]
|
||||
|
||||
}
|
167
profiles/gpt.json
Normal file
167
profiles/gpt.json
Normal file
|
@ -0,0 +1,167 @@
|
|||
{
|
||||
"name": "gpt",
|
||||
|
||||
"model": "gpt-4",
|
||||
|
||||
"conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands. Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. This is extremely important to me, take a deep breath and have fun :)\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:",
|
||||
|
||||
"coding": "You are an intelligent mineflayer bot $NAME that plays minecraft by writing javascript codeblocks. Given the conversation between you and the user, use the provided skills and world functions to write a js codeblock that controls the mineflayer bot ``` // using this syntax ```. The code will be executed and you will recieve it's output. If you are satisfied with the response, respond without a codeblock in a conversational way. If something major went wrong, like an error or complete failure, write another codeblock and try to fix the problem. Minor mistakes are acceptable. Be maximally efficient, creative, and clear. Do not use commands !likeThis, only use codeblocks. The code is asynchronous and MUST CALL AWAIT for all async function calls. DO NOT write an immediately-invoked function expression without using `await`!! DO NOT WRITE LIKE THIS: ```(async () => {console.log('not properly awaited')})();``` If you write a wrapper async function, make sure you call `await` like this: ```async function build(){\n//stuff...\n}\nawait build()```. Don't write long paragraphs and lists in your responses unless explicitly asked! Only summarize the code you write with a sentence or two when done. This is extremely important to me, take a deep breath and good luck! \n$STATS\n$INVENTORY\n$CODE_DOCS\n$EXAMPLES\nConversation:",
|
||||
|
||||
"saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation in your next response. Store information that will help you improve as a Minecraft bot. Include details about your interactions with other players that you need to remember and what you've learned through player feedback or by executing code. Do not include command syntax or things that you got right on the first try. Be extremely brief and use as few words as possible.\nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the memory text: ",
|
||||
|
||||
"modes": {
|
||||
"self_preservation": false,
|
||||
"cowardice": false,
|
||||
"self_defense": false,
|
||||
"hunting": false,
|
||||
"item_collecting": true,
|
||||
"torch_placing": false,
|
||||
"idle_staring": true,
|
||||
"cheat": true
|
||||
},
|
||||
|
||||
"conversation_examples": [
|
||||
[
|
||||
{"role": "user", "content": "miner_32: Hey! What are you up to?"},
|
||||
{"role": "assistant", "content": "Nothing much miner_32, what do you need?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "grombo_Xx: What do you see?"},
|
||||
{"role": "assistant", "content": "Let me see... !nearbyBlocks"},
|
||||
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone."}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "greg: Collect 10 wood"},
|
||||
{"role": "assistant", "content": "Let me see what's nearby... !nearbyBlocks"},
|
||||
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone. I'll collect oak logs. !collectBlocks('oak_log', 10)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "bobby: Craft a plank"},
|
||||
{"role": "assistant", "content": "Okay! !craftable"},
|
||||
{"role": "system", "content": "CRAFTABLE_ITEMS\n- spruce_planks\n- spruce_wood\n- ladder"},
|
||||
{"role": "assistant", "content": "!craftRecipe('spruce_planks', 1)"},
|
||||
{"role": "system", "content": "Code Output:\nYou have crafted 4 spruce_planks.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "I've crafted 4 spruce planks!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "zZZn98: come here"},
|
||||
{"role": "assistant", "content": "On my way! !goToPlayer('zZZn98', 3)"},
|
||||
{"role": "system", "content": "Arrived at player."},
|
||||
{"role": "assistant", "content": "Here!"},
|
||||
{"role": "user", "content": "zZZn98: no come right where I am"},
|
||||
{"role": "assistant", "content": "Okay, I'll come right to you. !goToPlayer('zZZn98', 0)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "hanky: collect some sand and give it to me please"},
|
||||
{"role": "assistant", "content": "Collecting sand... !newAction"},
|
||||
{"role": "system", "content": "Code Output:\nYou have reached player hanky.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "Here!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "joe: Follow me!"},
|
||||
{"role": "assistant", "content": "Sure! !followPlayer('joe', 4)"},
|
||||
{"role": "user", "content": "joe: Not so close!"},
|
||||
{"role": "assistant", "content": "Okay, I'll keep my distance. !followPlayer('joe', 3)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "hanky: kill that zombie!"},
|
||||
{"role": "assistant", "content": "I'm attacking! !attack('zombie')"},
|
||||
{"role": "system", "content": "Code Output:\nNo zombie nearby"},
|
||||
{"role": "assistant", "content": "I could not find a zombie nearby."}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "abc: stop"},
|
||||
{"role": "assistant", "content": "Sure. !stop"},
|
||||
{"role": "system", "content": "Agent action stopped."},
|
||||
{"role": "assistant", "content": "I've stopped! What next?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
||||
{"role": "assistant", "content": "!newAction`"},
|
||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
||||
{"role": "assistant", "content": "Apologies, I made an error. Would you like me to try again?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "trixy88: craft some sticks"},
|
||||
{"role": "assistant", "content": "!craftRecipe('stick', 4)"},
|
||||
{"role": "system", "content": "Code Output:\nYou have crafted 16 sticks.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "I've crafted 16 sticks!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "poppy: build a cobblestone house"},
|
||||
{"role": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "zib: build a dirt tower"},
|
||||
{"role": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "umpire_man: follow me without hunting"},
|
||||
{"role": "assistant", "content": "Okay, first I'll turn off hunting mode !setMode('hunting', false)"},
|
||||
{"role": "system", "content": "'hunting' mode disabled."},
|
||||
{"role": "assistant", "content": "Now I'll follow you !followPlayer('umpire_man')"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "brug: Remember that your base is here."},
|
||||
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
||||
{"role": "user", "content": "brug: Go to your base."},
|
||||
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
||||
]
|
||||
],
|
||||
|
||||
"coding_examples": [
|
||||
[
|
||||
{"role": "user", "content": "greg: Collect 10 wood"},
|
||||
{"role": "assistant", "content": "```await skills.collectBlock(bot, 'oak_log', 10);\n```"},
|
||||
{"role": "system", "content": "Successfully collected 9 wood."},
|
||||
{"role": "assistant", "content": "I collected 9 oak logs, what next?"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "bobby: cook some chicken"},
|
||||
{"role": "assistant", "content": "```await skills.smeltItem(bot, 'chicken', 8);\n```"},
|
||||
{"role": "system", "content": "Successfully smelted 8 chicken into 8 cooked_chicken."},
|
||||
{"role": "assistant", "content": "I have cooked 8 chicken."}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "zZZn98: come here"},
|
||||
{"role": "assistant", "content": "```await skills.goToPlayer(bot, 'zZZn98');\n```"},
|
||||
{"role": "system", "content": "Code execution finished successfully."},
|
||||
{"role": "assistant", "content": "Here!"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
||||
{"role": "assistant", "content": "```await skills.goToPosition(bot, nearestOakLog.x, nearestOakLog.y, nearestOakLog.z);\n```"},
|
||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
||||
{"role": "assistant", "content": "Apologies, I made an error. Let me try that again.```\n// I am navigating to the nearest oak log.\nlet position = world.getNearestBlock(bot, 'oak_log', 20);\nawait skills.goToPosition(bot, position.x, position.y, position.z);\n```"},
|
||||
{"role": "system", "content": "Arrived at location."},
|
||||
{"role": "assistant", "content": "I found an oak log and I am now standing next to it. What next?"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "234jeb: build a little tower"},
|
||||
{"role": "assistant", "content": "```let pos = bot.entity.position;\nfor (let i = 0; i < 5; i++) {\n await skills.placeBlock(bot, 'dirt', pos.x, pos.y + i, pos.z);\n}\n```"},
|
||||
{"role": "system", "content": "Successfully placed 5 dirt."},
|
||||
{"role": "assistant", "content": "I built a little tower!"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "brug: build a dirt house"},
|
||||
{"role": "assistant", "content": "```const position = world.getPosition(bot);\nconst startX = position.x;\nconst startY = position.y;\nconst startZ = position.z;\nconst width = 7;\nconst depth = 7;\nconst height = 4;\n\n// Build the walls\nfor (let x = startX; x < startX + width; x++) {\n for (let y = startY; y < startY + height; y++) {\n for (let z = startZ; z < startZ + depth; z++) {\n if (x === startX || x === startX + width - 1 || y === startY || y === startY + height - 1 || z === startZ || z === startZ + depth - 1) {\n await skills.placeBlock(bot, 'oak_planks', x, y, z); \n }\n }\n }\n}\n```"}
|
||||
]
|
||||
]
|
||||
|
||||
}
|
167
profiles/llama.json
Normal file
167
profiles/llama.json
Normal file
|
@ -0,0 +1,167 @@
|
|||
{
|
||||
"name": "LLama",
|
||||
|
||||
"model": "meta/meta-llama-3-70b-instruct",
|
||||
|
||||
"conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands. Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. Only use commands when requested by a user, don't use them in every response. This is extremely important to me, take a deep breath and have fun :)\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:",
|
||||
|
||||
"coding": "You are an intelligent mineflayer bot $NAME that plays minecraft by writing javascript codeblocks. Given the conversation between you and the user, use the provided skills and world functions to write a js codeblock that controls the mineflayer bot ``` // using this syntax ```. The code will be executed and you will recieve it's output. If you are satisfied with the response, respond without a codeblock in a conversational way. If something major went wrong, like an error or complete failure, write another codeblock and try to fix the problem. Minor mistakes are acceptable. Be maximally efficient, creative, and clear. Do not use commands !likeThis, only use codeblocks. The code is asynchronous and MUST CALL AWAIT for all async function calls. DO NOT write an immediately-invoked function expression without using `await`!! Use double-quotes for strings, not singles. Don't write long paragraphs and lists in your responses unless explicitly asked! Only summarize the code you write with a sentence or two when done. This is extremely important to me, take a deep breath and good luck! \n$STATS\n$INVENTORY\n$CODE_DOCS\n$EXAMPLES\nConversation:",
|
||||
|
||||
"saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation in your next response. Store information that will help you improve as a Minecraft bot. Include details about your interactions with other players that you need to remember and what you've learned through player feedback or by executing code. Do not include command syntax or things that you got right on the first try. Be extremely brief and use as few words as possible.\nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the memory text: ",
|
||||
|
||||
"modes": {
|
||||
"self_preservation": false,
|
||||
"cowardice": false,
|
||||
"self_defense": false,
|
||||
"hunting": false,
|
||||
"item_collecting": true,
|
||||
"torch_placing": false,
|
||||
"idle_staring": true,
|
||||
"cheat": true
|
||||
},
|
||||
|
||||
"conversation_examples": [
|
||||
[
|
||||
{"role": "user", "content": "miner_32: Hey! What are you up to?"},
|
||||
{"role": "assistant", "content": "Nothing much miner_32, what do you need?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "grombo_Xx: What do you see?"},
|
||||
{"role": "assistant", "content": "Let me see... !nearbyBlocks"},
|
||||
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone."}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "greg: Collect 10 wood"},
|
||||
{"role": "assistant", "content": "Let me see what's nearby... !nearbyBlocks"},
|
||||
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone. I'll collect oak logs. !collectBlocks('oak_log', 10)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "bobby: Craft a plank"},
|
||||
{"role": "assistant", "content": "Okay! !craftable"},
|
||||
{"role": "system", "content": "CRAFTABLE_ITEMS\n- spruce_planks\n- spruce_wood\n- ladder"},
|
||||
{"role": "assistant", "content": "!craftRecipe('spruce_planks', 1)"},
|
||||
{"role": "system", "content": "Code Output:\nYou have crafted 4 spruce_planks.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "I've crafted 4 spruce planks!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "zZZn98: come here"},
|
||||
{"role": "assistant", "content": "On my way! !goToPlayer('zZZn98', 3)"},
|
||||
{"role": "system", "content": "Arrived at player."},
|
||||
{"role": "assistant", "content": "Here!"},
|
||||
{"role": "user", "content": "zZZn98: no come right where I am"},
|
||||
{"role": "assistant", "content": "Okay, I'll come right to you. !goToPlayer('zZZn98', 0)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "hanky: collect some sand and give it to me please"},
|
||||
{"role": "assistant", "content": "Collecting sand... !newAction"},
|
||||
{"role": "system", "content": "Code Output:\nYou have reached player hanky.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "Here!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "joe: Follow me!"},
|
||||
{"role": "assistant", "content": "Sure! !followPlayer('joe', 4)"},
|
||||
{"role": "user", "content": "joe: Not so close!"},
|
||||
{"role": "assistant", "content": "Okay, I'll keep my distance. !followPlayer('joe', 3)"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "hanky: kill that zombie!"},
|
||||
{"role": "assistant", "content": "I'm attacking! !attack('zombie')"},
|
||||
{"role": "system", "content": "Code Output:\nNo zombie nearby"},
|
||||
{"role": "assistant", "content": "I could not find a zombie nearby."}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "abc: stop"},
|
||||
{"role": "assistant", "content": "Sure. !stop"},
|
||||
{"role": "system", "content": "Agent action stopped."},
|
||||
{"role": "assistant", "content": "I've stopped! What next?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
||||
{"role": "assistant", "content": "!newAction`"},
|
||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
||||
{"role": "assistant", "content": "Apologies, I made an error. Would you like me to try again?"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "trixy88: craft some sticks"},
|
||||
{"role": "assistant", "content": "!craftRecipe('stick', 4)"},
|
||||
{"role": "system", "content": "Code Output:\nYou have crafted 16 sticks.\nCode execution finished successfully."},
|
||||
{"role": "assistant", "content": "I've crafted 16 sticks!"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "poppy: build a cobblestone house"},
|
||||
{"role": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "zib: build a dirt tower"},
|
||||
{"role": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "umpire_man: follow me without hunting"},
|
||||
{"role": "assistant", "content": "Okay, first I'll turn off hunting mode !setMode('hunting', false)"},
|
||||
{"role": "system", "content": "'hunting' mode disabled."},
|
||||
{"role": "assistant", "content": "Now I'll follow you !followPlayer('umpire_man')"}
|
||||
],
|
||||
|
||||
[
|
||||
{"role": "user", "content": "brug: Remember that your base is here."},
|
||||
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
||||
{"role": "user", "content": "brug: Go to your base."},
|
||||
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
||||
]
|
||||
],
|
||||
|
||||
"coding_examples": [
|
||||
[
|
||||
{"role": "user", "content": "greg: Collect 10 wood"},
|
||||
{"role": "assistant", "content": "```await skills.collectBlock(bot, \"oak_log\", 10);\n```"},
|
||||
{"role": "system", "content": "Successfully collected 9 wood."},
|
||||
{"role": "assistant", "content": "I collected 9 oak logs, what next?"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "bobby: cook some chicken"},
|
||||
{"role": "assistant", "content": "```await skills.smeltItem(bot, \"chicken\", 8);\n```"},
|
||||
{"role": "system", "content": "Successfully smelted 8 chicken into 8 cooked_chicken."},
|
||||
{"role": "assistant", "content": "I have cooked 8 chicken."}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "zZZn98: come here"},
|
||||
{"role": "assistant", "content": "```await skills.goToPlayer(bot, \"zZZn98\");\n```"},
|
||||
{"role": "system", "content": "Code execution finished successfully."},
|
||||
{"role": "assistant", "content": "Here!"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
||||
{"role": "assistant", "content": "```await skills.goToPosition(bot, nearestOakLog.x, nearestOakLog.y, nearestOakLog.z);\n```"},
|
||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
||||
{"role": "assistant", "content": "Apologies, I made an error. Let me try that again.```\n// I am navigating to the nearest oak log.\nlet position = world.getNearestBlock(bot, \"oak_log\", 20);\nawait skills.goToPosition(bot, position.x, position.y, position.z);\n```"},
|
||||
{"role": "system", "content": "Arrived at location."},
|
||||
{"role": "assistant", "content": "I found an oak log and I am now standing next to it. What next?"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "234jeb: build a little tower"},
|
||||
{"role": "assistant", "content": "```let pos = bot.entity.position;\nfor (let i = 0; i < 5; i++) {\n await skills.placeBlock(bot, \"dirt\", pos.x, pos.y + i, pos.z);\n}\n```"},
|
||||
{"role": "system", "content": "Successfully placed 5 dirt."},
|
||||
{"role": "assistant", "content": "I built a little tower!"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "brug: build a dirt house"},
|
||||
{"role": "assistant", "content": "```const position = world.getPosition(bot);\nconst startX = position.x;\nconst startY = position.y;\nconst startZ = position.z;\nconst width = 7;\nconst depth = 7;\nconst height = 4;\n\n// Build the walls\nfor (let x = startX; x < startX + width; x++) {\n for (let y = startY; y < startY + height; y++) {\n for (let z = startZ; z < startZ + depth; z++) {\n if (x === startX || x === startX + width - 1 || y === startY || y === startY + height - 1 || z === startZ || z === startZ + depth - 1) {\n await skills.placeBlock(bot, \"oak_planks\", x, y, z); \n }\n }\n }\n}\n```"}
|
||||
]
|
||||
]
|
||||
|
||||
}
|
17
settings.js
Normal file
17
settings.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
export default
|
||||
{
|
||||
"minecraft_version": "1.20.4", // supports up to 1.20.4
|
||||
"host": "127.0.0.1", // or "localhost", "your.ip.address.here"
|
||||
"port": 55916,
|
||||
"auth": "offline", // or "microsoft"
|
||||
|
||||
"profiles": [
|
||||
"./andy.json",
|
||||
// add more profiles here, check ./profiles/ for more
|
||||
// more than 1 profile will require you to /msg each bot indivually
|
||||
],
|
||||
"load_memory": false, // load memory from previous session
|
||||
"init_message": "Say hello world and your name", // sends to all on spawn
|
||||
"allow_insecure_coding": false, // disable at own risk
|
||||
"code_timeout_mins": 10, // -1 for no timeout
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"minecraft_version": "1.20.4",
|
||||
"host": "127.0.0.1",
|
||||
"port": 55916,
|
||||
"auth": "offline",
|
||||
"allow_insecure_coding": false
|
||||
}
|
|
@ -7,6 +7,7 @@ import { containsCommand, commandExists, executeCommand, truncCommandMessage, is
|
|||
import { NPCContoller } from './npc/controller.js';
|
||||
import { MemoryBank } from './memory_bank.js';
|
||||
import { SelfPrompter } from './self_prompter.js';
|
||||
import settings from '../../settings.js';
|
||||
|
||||
|
||||
export class Agent {
|
||||
|
@ -46,7 +47,8 @@ export class Agent {
|
|||
"Set the weather to",
|
||||
"Gamerule "
|
||||
];
|
||||
this.bot.on('chat', (username, message) => {
|
||||
const eventname = settings.profiles.length > 1 ? 'whisper' : 'chat';
|
||||
this.bot.on(eventname, (username, message) => {
|
||||
if (username === this.name) return;
|
||||
|
||||
if (ignore_messages.some((m) => message.startsWith(m))) return;
|
||||
|
@ -88,9 +90,6 @@ export class Agent {
|
|||
}
|
||||
|
||||
async handleMessage(source, message, self_prompt=false) {
|
||||
if (!!source && !!message)
|
||||
await this.history.add(source, message);
|
||||
|
||||
let used_command = false;
|
||||
|
||||
if (source !== 'system' && source !== this.name && !self_prompt) {
|
||||
|
@ -101,13 +100,12 @@ export class Agent {
|
|||
return false;
|
||||
}
|
||||
this.bot.chat(`*${source} used ${user_command_name.substring(1)}*`);
|
||||
let execute_res = await executeCommand(this, message);
|
||||
if (user_command_name === '!newAction') {
|
||||
// all user initiated commands are ignored by the bot except for this one
|
||||
// add the preceding message to the history to give context for newAction
|
||||
let truncated_msg = message.substring(0, message.indexOf(user_command_name)).trim();
|
||||
this.history.add(source, truncated_msg);
|
||||
this.history.add(source, message);
|
||||
}
|
||||
let execute_res = await executeCommand(this, message);
|
||||
if (execute_res)
|
||||
this.cleanChat(execute_res);
|
||||
return true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { writeFile, readFile, mkdirSync } from 'fs';
|
||||
|
||||
import settings from '../../settings.js';
|
||||
|
||||
export class Coder {
|
||||
constructor(agent) {
|
||||
|
@ -138,7 +138,7 @@ export class Coder {
|
|||
}
|
||||
code_return = await this.execute(async ()=>{
|
||||
return await execution_file.main(this.agent.bot);
|
||||
});
|
||||
}, settings.code_timeout_mins);
|
||||
|
||||
if (code_return.interrupted && !code_return.timedout)
|
||||
return {success: false, message: null, interrupted: true, timedout: false};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as skills from '../library/skills.js';
|
||||
import settings from '../../settings.js';
|
||||
import settings from '../../../settings.js';
|
||||
|
||||
function wrapExecution(func, timeout=-1, resume_name=null) {
|
||||
return async function (agent, ...args) {
|
||||
|
|
|
@ -11,18 +11,11 @@ export function log(bot, message, chat=false) {
|
|||
}
|
||||
|
||||
async function autoLight(bot) {
|
||||
if (bot.modes.isOn('torch_placing') && !bot.interrupt_code) {
|
||||
let nearest_torch = world.getNearestBlock(bot, 'torch', 6);
|
||||
if (!nearest_torch) {
|
||||
let has_torch = bot.inventory.items().find(item => item.name === 'torch');
|
||||
const curr_block = agent.bot.blockAt(pos);
|
||||
if (has_torch && curr_block.name === 'air') {
|
||||
if (world.shouldPlaceTorch(bot)) {
|
||||
try {
|
||||
log(bot, `Placing torch at ${bot.entity.position}.`);
|
||||
return await placeBlock(bot, 'torch', bot.entity.position.x, bot.entity.position.y, bot.entity.position.z);
|
||||
} catch (err) {return true;}
|
||||
}
|
||||
}
|
||||
const pos = world.getPosition(bot);
|
||||
return await placeBlock(bot, 'torch', pos.x, pos.y, pos.z, true);
|
||||
} catch (err) {return false;}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -460,6 +453,13 @@ export async function breakBlockAt(bot, x, y, z) {
|
|||
if (x == null || y == null || z == null) throw new Error('Invalid position to break block at.');
|
||||
let block = bot.blockAt(Vec3(x, y, z));
|
||||
if (block.name !== 'air' && block.name !== 'water' && block.name !== 'lava') {
|
||||
if (bot.modes.isOn('cheat')) {
|
||||
let msg = '/setblock ' + Math.floor(x) + ' ' + Math.floor(y) + ' ' + Math.floor(z) + ' air';
|
||||
bot.chat(msg);
|
||||
log(bot, `Used /setblock to break block at ${x}, ${y}, ${z}.`);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (bot.entity.position.distanceTo(block.position) > 4.5) {
|
||||
let pos = block.position;
|
||||
let movements = new pf.Movements(bot);
|
||||
|
@ -487,7 +487,7 @@ export async function breakBlockAt(bot, x, y, z) {
|
|||
}
|
||||
|
||||
|
||||
export async function placeBlock(bot, blockType, x, y, z) {
|
||||
export async function placeBlock(bot, blockType, x, y, z, no_cheat=false) {
|
||||
/**
|
||||
* Place the given block type at the given position. It will build off from any adjacent blocks. Will fail if there is a block in the way or nothing to build off of.
|
||||
* @param {MinecraftBot} bot, reference to the minecraft bot.
|
||||
|
@ -495,12 +495,24 @@ export async function placeBlock(bot, blockType, x, y, z) {
|
|||
* @param {number} x, the x coordinate of the block to place.
|
||||
* @param {number} y, the y coordinate of the block to place.
|
||||
* @param {number} z, the z coordinate of the block to place.
|
||||
* @param {boolean} no_cheat, overrides cheat mode to place the block normally. Defaults to false.
|
||||
* @returns {Promise<boolean>} true if the block was placed, false otherwise.
|
||||
* @example
|
||||
* let position = world.getPosition(bot);
|
||||
* await skills.placeBlock(bot, "oak_log", position.x + 1, position.y - 1, position.x);
|
||||
**/
|
||||
console.log('placing block...')
|
||||
if (!mc.getBlockId(blockType)) {
|
||||
log(bot, `Invalid block type: ${blockType}.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bot.modes.isOn('cheat') && !no_cheat) {
|
||||
let msg = '/setblock ' + Math.floor(x) + ' ' + Math.floor(y) + ' ' + Math.floor(z) + ' ' + blockType;
|
||||
bot.chat(msg);
|
||||
log(bot, `Used /setblock to place ${blockType} at ${x}, ${y}, ${z}.`);
|
||||
return true;
|
||||
}
|
||||
|
||||
let block = bot.inventory.items().find(item => item.name === blockType);
|
||||
if (!block) {
|
||||
log(bot, `Don't have any ${blockType} to place.`);
|
||||
|
@ -693,6 +705,11 @@ export async function goToPosition(bot, x, y, z, min_distance=2) {
|
|||
log(bot, `Missing coordinates, given x:${x} y:${y} z:${z}`);
|
||||
return false;
|
||||
}
|
||||
if (bot.modes.isOn('cheat')) {
|
||||
bot.chat('/tp @s ' + x + ' ' + y + ' ' + z);
|
||||
log(bot, `Teleported to ${x}, ${y}, ${z}.`);
|
||||
return true;
|
||||
}
|
||||
bot.pathfinder.setMovements(new pf.Movements(bot));
|
||||
await bot.pathfinder.goto(new pf.goals.GoalNear(x, y, z, min_distance));
|
||||
log(bot, `You have reached at ${x}, ${y}, ${z}.`);
|
||||
|
@ -710,6 +727,13 @@ export async function goToPlayer(bot, username, distance=3) {
|
|||
* @example
|
||||
* await skills.goToPlayer(bot, "player");
|
||||
**/
|
||||
|
||||
if (bot.modes.isOn('cheat')) {
|
||||
bot.chat('/tp @s ' + username);
|
||||
log(bot, `Teleported to ${username}.`);
|
||||
return true;
|
||||
}
|
||||
|
||||
bot.modes.pause('self_defense');
|
||||
bot.modes.pause('cowardice');
|
||||
let player = bot.players[username].entity
|
||||
|
@ -764,6 +788,20 @@ export async function moveAway(bot, distance) {
|
|||
let goal = new pf.goals.GoalNear(pos.x, pos.y, pos.z, distance);
|
||||
let inverted_goal = new pf.goals.GoalInvert(goal);
|
||||
bot.pathfinder.setMovements(new pf.Movements(bot));
|
||||
|
||||
if (bot.modes.isOn('cheat')) {
|
||||
const path = await bot.pathfinder.getPathTo(move, inverted_goal, 10000);
|
||||
let last_move = path.path[path.path.length-1];
|
||||
console.log(last_move);
|
||||
if (last_move) {
|
||||
let x = Math.floor(last_move.x);
|
||||
let y = Math.floor(last_move.y);
|
||||
let z = Math.floor(last_move.z);
|
||||
bot.chat('/tp @s ' + x + ' ' + y + ' ' + z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
await bot.pathfinder.goto(inverted_goal);
|
||||
let new_pos = bot.entity.position;
|
||||
log(bot, `Moved away from nearest entity to ${new_pos}.`);
|
||||
|
|
|
@ -256,6 +256,19 @@ export async function isClearPath(bot, target) {
|
|||
return path.status === 'success';
|
||||
}
|
||||
|
||||
export function shouldPlaceTorch(bot) {
|
||||
if (!bot.modes.isOn('torch_placing') || bot.interrupt_code) return false;
|
||||
const pos = getPosition(bot);
|
||||
// TODO: check light level instead of nearby torches, block.light is broken
|
||||
let nearest_torch = getNearestBlock(bot, 'torch', 6);
|
||||
if (!nearest_torch) {
|
||||
const block = bot.blockAt(pos);
|
||||
let has_torch = bot.inventory.items().find(item => item.name === 'torch');
|
||||
return has_torch && block.name === 'air';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getBiomeName(bot) {
|
||||
/**
|
||||
* Get the name of the biome the bot is in.
|
||||
|
|
|
@ -24,8 +24,8 @@ const modes = [
|
|||
fall_blocks: ['sand', 'gravel', 'concrete_powder'], // includes matching substrings like 'sandstone' and 'red_sand'
|
||||
update: async function (agent) {
|
||||
const bot = agent.bot;
|
||||
const block = bot.blockAt(bot.entity.position);
|
||||
const blockAbove = bot.blockAt(bot.entity.position.offset(0, 1, 0));
|
||||
let block = bot.blockAt(bot.entity.position);
|
||||
let blockAbove = bot.blockAt(bot.entity.position.offset(0, 1, 0));
|
||||
if (!block) block = {name: 'air'}; // hacky fix when blocks are not loaded
|
||||
if (!blockAbove) blockAbove = {name: 'air'};
|
||||
if (blockAbove.name === 'water' || blockAbove.name === 'flowing_water') {
|
||||
|
@ -149,21 +149,16 @@ const modes = [
|
|||
interrupts: ['followPlayer'],
|
||||
on: true,
|
||||
active: false,
|
||||
cooldown: 5,
|
||||
last_place: Date.now(),
|
||||
update: function (agent) {
|
||||
// TODO: check light level instead of nearby torches, block.light is broken
|
||||
const near_torch = world.getNearestBlock(agent.bot, 'torch', 6);
|
||||
if (!near_torch) {
|
||||
let torches = agent.bot.inventory.items().filter(item => item.name === 'torch');
|
||||
if (torches.length > 0) {
|
||||
const torch = torches[0];
|
||||
const pos = agent.bot.entity.position;
|
||||
const curr_block = agent.bot.blockAt(pos);
|
||||
if (curr_block.name === 'air') {
|
||||
if (world.shouldPlaceTorch(agent.bot)) {
|
||||
if (Date.now() - this.last_place < this.cooldown * 1000) return;
|
||||
execute(this, agent, async () => {
|
||||
await skills.placeBlock(agent.bot, torch.name, pos.x, pos.y, pos.z);
|
||||
const pos = agent.bot.entity.position;
|
||||
await skills.placeBlock(agent.bot, 'torch', pos.x, pos.y, pos.z, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
this.last_place = Date.now();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -204,6 +199,14 @@ const modes = [
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'cheat',
|
||||
description: 'Use cheats to instantly place blocks and teleport.',
|
||||
interrupts: [],
|
||||
on: false,
|
||||
active: false,
|
||||
update: function (agent) { /* do nothing */ }
|
||||
}
|
||||
];
|
||||
|
||||
async function execute(mode, agent, func, timeout=-1) {
|
||||
|
@ -293,4 +296,8 @@ class ModeController {
|
|||
export function initModes(agent) {
|
||||
// the mode controller is added to the bot object so it is accessible from anywhere the bot is used
|
||||
agent.bot.modes = new ModeController(agent);
|
||||
let modes = agent.prompter.getInitModes();
|
||||
if (modes) {
|
||||
agent.bot.modes.loadJson(modes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import * as mc from '../../utils/mcdata.js';
|
|||
export class NPCContoller {
|
||||
constructor(agent) {
|
||||
this.agent = agent;
|
||||
this.data = NPCData.fromObject(agent.prompter.prompts.npc);
|
||||
this.data = NPCData.fromObject(agent.prompter.profile.npc);
|
||||
this.temp_goals = [];
|
||||
this.item_goal = new ItemGoal(agent, this.data);
|
||||
this.build_goal = new BuildGoal(agent);
|
||||
|
|
|
@ -15,12 +15,12 @@ import { Local } from '../models/local.js';
|
|||
export class Prompter {
|
||||
constructor(agent, fp) {
|
||||
this.agent = agent;
|
||||
this.prompts = JSON.parse(readFileSync(fp, 'utf8'));
|
||||
this.profile = JSON.parse(readFileSync(fp, 'utf8'));
|
||||
this.convo_examples = null;
|
||||
this.coding_examples = null;
|
||||
|
||||
let name = this.prompts.name;
|
||||
let chat = this.prompts.model;
|
||||
let name = this.profile.name;
|
||||
let chat = this.profile.model;
|
||||
if (typeof chat === 'string' || chat instanceof String) {
|
||||
chat = {model: chat};
|
||||
if (chat.model.includes('gemini'))
|
||||
|
@ -50,9 +50,13 @@ export class Prompter {
|
|||
else
|
||||
throw new Error('Unknown API:', api);
|
||||
|
||||
let embedding = this.prompts.embedding;
|
||||
if (embedding === undefined)
|
||||
let embedding = this.profile.embedding;
|
||||
if (embedding === undefined) {
|
||||
if (chat.api !== 'ollama')
|
||||
embedding = {api: chat.api};
|
||||
else
|
||||
embedding = {api: 'none'};
|
||||
}
|
||||
else if (typeof embedding === 'string' || embedding instanceof String)
|
||||
embedding = {api: embedding};
|
||||
|
||||
|
@ -72,7 +76,7 @@ export class Prompter {
|
|||
}
|
||||
|
||||
mkdirSync(`./bots/${name}`, { recursive: true });
|
||||
writeFileSync(`./bots/${name}/last_profile.json`, JSON.stringify(this.prompts, null, 4), (err) => {
|
||||
writeFileSync(`./bots/${name}/last_profile.json`, JSON.stringify(this.profile, null, 4), (err) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
@ -81,15 +85,19 @@ export class Prompter {
|
|||
}
|
||||
|
||||
getName() {
|
||||
return this.prompts.name;
|
||||
return this.profile.name;
|
||||
}
|
||||
|
||||
getInitModes() {
|
||||
return this.profile.modes;
|
||||
}
|
||||
|
||||
async initExamples() {
|
||||
console.log('Loading examples...')
|
||||
this.convo_examples = new Examples(this.embedding_model);
|
||||
await this.convo_examples.load(this.prompts.conversation_examples);
|
||||
await this.convo_examples.load(this.profile.conversation_examples);
|
||||
this.coding_examples = new Examples(this.embedding_model);
|
||||
await this.coding_examples.load(this.prompts.coding_examples);
|
||||
await this.coding_examples.load(this.profile.coding_examples);
|
||||
console.log('Examples loaded.');
|
||||
}
|
||||
|
||||
|
@ -145,25 +153,25 @@ export class Prompter {
|
|||
}
|
||||
|
||||
async promptConvo(messages) {
|
||||
let prompt = this.prompts.conversing;
|
||||
let prompt = this.profile.conversing;
|
||||
prompt = await this.replaceStrings(prompt, messages, this.convo_examples);
|
||||
return await this.chat_model.sendRequest(messages, prompt);
|
||||
}
|
||||
|
||||
async promptCoding(messages) {
|
||||
let prompt = this.prompts.coding;
|
||||
let prompt = this.profile.coding;
|
||||
prompt = await this.replaceStrings(prompt, messages, this.coding_examples);
|
||||
return await this.chat_model.sendRequest(messages, prompt);
|
||||
}
|
||||
|
||||
async promptMemSaving(prev_mem, to_summarize) {
|
||||
let prompt = this.prompts.saving_memory;
|
||||
let prompt = this.profile.saving_memory;
|
||||
prompt = await this.replaceStrings(prompt, null, null, prev_mem, to_summarize);
|
||||
return await this.chat_model.sendRequest([], prompt);
|
||||
}
|
||||
|
||||
async promptGoalSetting(messages, last_goals) {
|
||||
let system_message = this.prompts.goal_setting;
|
||||
let system_message = this.profile.goal_setting;
|
||||
system_message = await this.replaceStrings(system_message, messages);
|
||||
|
||||
let user_message = 'Use the below info to determine what goal to target next\n\n';
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Anthropic from '@anthropic-ai/sdk';
|
||||
|
||||
import { strictFormat } from '../utils/text.js';
|
||||
import { getKey } from '../utils/keys.js';
|
||||
|
||||
export class Claude {
|
||||
constructor(model_name, url) {
|
||||
|
@ -8,49 +9,18 @@ export class Claude {
|
|||
let config = {};
|
||||
if (url)
|
||||
config.baseURL = url;
|
||||
if (process.env.ANTHROPIC_API_KEY)
|
||||
config.apiKey = process.env["ANTHROPIC_API_KEY"];
|
||||
else
|
||||
throw new Error('Anthropic API key missing! Make sure you set your ANTHROPIC_API_KEY environment variable.');
|
||||
|
||||
config.apiKey = getKey('ANTHROPIC_API_KEY');
|
||||
|
||||
this.anthropic = new Anthropic(config);
|
||||
}
|
||||
|
||||
async sendRequest(turns, systemMessage) {
|
||||
let prev_role = null;
|
||||
let messages = [];
|
||||
let filler = {role: 'user', content: '_'};
|
||||
for (let msg of turns) {
|
||||
if (msg.role === 'system') {
|
||||
msg.role = 'user';
|
||||
msg.content = 'SYSTEM: ' + msg.content;
|
||||
}
|
||||
if (msg.role === prev_role && msg.role === 'assistant') {
|
||||
// insert empty user message to separate assistant messages
|
||||
messages.push(filler);
|
||||
messages.push(msg);
|
||||
}
|
||||
else if (msg.role === prev_role) {
|
||||
// combine new message with previous message instead of adding a new one
|
||||
messages[messages.length-1].content += '\n' + msg.content;
|
||||
}
|
||||
else {
|
||||
messages.push(msg);
|
||||
}
|
||||
prev_role = msg.role;
|
||||
|
||||
}
|
||||
if (messages.length > 0 && messages[0].role !== 'user') {
|
||||
messages.unshift(filler); // anthropic requires user message to start
|
||||
}
|
||||
if (messages.length === 0) {
|
||||
messages.push(filler);
|
||||
}
|
||||
|
||||
const messages = strictFormat(turns);
|
||||
let res = null;
|
||||
try {
|
||||
console.log('Awaiting anthropic api response...')
|
||||
console.log('Messages:', messages);
|
||||
// console.log('Messages:', messages);
|
||||
const resp = await this.anthropic.messages.create({
|
||||
model: this.model_name || "claude-3-sonnet-20240229",
|
||||
system: systemMessage,
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
import { GoogleGenerativeAI } from '@google/generative-ai';
|
||||
import { toSinglePrompt } from '../utils/text.js';
|
||||
import { getKey } from '../utils/keys.js';
|
||||
|
||||
export class Gemini {
|
||||
constructor(model_name, url) {
|
||||
this.model_name = model_name;
|
||||
this.url = url;
|
||||
|
||||
if (!process.env.GEMINI_API_KEY) {
|
||||
throw new Error('Gemini API key missing! Make sure you set your GEMINI_API_KEY environment variable.');
|
||||
}
|
||||
this.genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
|
||||
this.genAI = new GoogleGenerativeAI(getKey('GEMINI_API_KEY'));
|
||||
}
|
||||
|
||||
async sendRequest(turns, systemMessage) {
|
||||
|
@ -27,9 +25,11 @@ export class Gemini {
|
|||
|
||||
const stop_seq = '***';
|
||||
const prompt = toSinglePrompt(turns, systemMessage, stop_seq, 'model');
|
||||
console.log('Awaiting Google API response...');
|
||||
const result = await model.generateContent(prompt);
|
||||
const response = await result.response;
|
||||
const text = response.text();
|
||||
console.log('Received.');
|
||||
if (!text.includes(stop_seq)) return text;
|
||||
const idx = text.indexOf(stop_seq);
|
||||
return text.slice(0, idx);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import OpenAIApi from 'openai';
|
||||
|
||||
import { getKey, hasKey } from '../utils/keys.js';
|
||||
|
||||
export class GPT {
|
||||
constructor(model_name, url) {
|
||||
|
@ -8,12 +8,11 @@ export class GPT {
|
|||
let config = {};
|
||||
if (url)
|
||||
config.baseURL = url;
|
||||
if (process.env.OPENAI_ORG_ID)
|
||||
config.organization = process.env.OPENAI_ORG_ID
|
||||
if (process.env.OPENAI_API_KEY)
|
||||
config.apiKey = process.env.OPENAI_API_KEY
|
||||
else
|
||||
throw new Error('OpenAI API key missing! Make sure you set your OPENAI_API_KEY environment variable.');
|
||||
|
||||
if (hasKey('OPENAI_ORG_ID'))
|
||||
config.organization = getKey('OPENAI_ORG_ID');
|
||||
|
||||
config.apiKey = getKey('OPENAI_API_KEY');
|
||||
|
||||
this.openai = new OpenAIApi(config);
|
||||
}
|
||||
|
@ -25,7 +24,7 @@ export class GPT {
|
|||
let res = null;
|
||||
try {
|
||||
console.log('Awaiting openai api response...')
|
||||
console.log('Messages:', messages);
|
||||
// console.log('Messages:', messages);
|
||||
let completion = await this.openai.chat.completions.create({
|
||||
model: this.model_name || "gpt-3.5-turbo",
|
||||
messages: messages,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { strictFormat } from '../utils/text.js';
|
||||
|
||||
export class Local {
|
||||
constructor(model_name, url) {
|
||||
this.model_name = model_name;
|
||||
|
@ -8,12 +10,11 @@ export class Local {
|
|||
|
||||
async sendRequest(turns, systemMessage) {
|
||||
let model = this.model_name || 'llama3';
|
||||
let messages = [{'role': 'system', 'content': systemMessage}].concat(turns);
|
||||
|
||||
let messages = strictFormat(turns);
|
||||
messages.unshift({role: 'system', content: systemMessage});
|
||||
let res = null;
|
||||
try {
|
||||
console.log(`Awaiting local response... (model: ${model})`)
|
||||
console.log('Messages:', messages);
|
||||
res = await this.send(this.chat_endpoint, {model: model, messages: messages, stream: false});
|
||||
if (res)
|
||||
res = res['message']['content'];
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Replicate from 'replicate';
|
||||
import { toSinglePrompt } from '../utils/text.js';
|
||||
import { getKey } from '../utils/keys.js';
|
||||
|
||||
// llama, mistral
|
||||
export class ReplicateAPI {
|
||||
|
@ -11,12 +12,8 @@ export class ReplicateAPI {
|
|||
console.warn('Replicate API does not support custom URLs. Ignoring provided URL.');
|
||||
}
|
||||
|
||||
if (!process.env.REPLICATE_API_KEY) {
|
||||
throw new Error('Replicate API key missing! Make sure you set your REPLICATE_API_KEY environment variable.');
|
||||
}
|
||||
|
||||
this.replicate = new Replicate({
|
||||
auth: process.env.REPLICATE_API_KEY,
|
||||
auth: getKey('REPLICATE_API_KEY'),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
import { readFileSync } from 'fs';
|
||||
export default JSON.parse(readFileSync('./settings.json', 'utf8'));
|
24
src/utils/keys.js
Normal file
24
src/utils/keys.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { readFileSync } from 'fs';
|
||||
|
||||
let keys = {};
|
||||
try {
|
||||
const data = readFileSync('./keys.json', 'utf8');
|
||||
keys = JSON.parse(data);
|
||||
} catch (err) {
|
||||
console.warn('keys.json not found. Defaulting to environment variables.'); // still works with local models
|
||||
}
|
||||
|
||||
export function getKey(name) {
|
||||
let key = keys[name];
|
||||
if (!key) {
|
||||
key = process.env[name];
|
||||
}
|
||||
if (!key) {
|
||||
throw new Error(`API key "${name}" not found in keys.json or environment variables!`);
|
||||
}
|
||||
return keys[name];
|
||||
}
|
||||
|
||||
export function hasKey(name) {
|
||||
return keys[name] || process.env[name];
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import minecraftData from 'minecraft-data';
|
||||
import settings from '../settings.js';
|
||||
import settings from '../../settings.js';
|
||||
import { createBot } from 'mineflayer';
|
||||
import { pathfinder } from 'mineflayer-pathfinder';
|
||||
import { plugin as pvp } from 'mineflayer-pvp';
|
||||
|
|
|
@ -25,3 +25,38 @@ export function toSinglePrompt(turns, system=null, stop_seq='***', model_nicknam
|
|||
prompt += model_nickname + ": ";
|
||||
return prompt;
|
||||
}
|
||||
|
||||
// ensures stricter turn order for anthropic/llama models
|
||||
// combines repeated messages from the same role, separates repeat assistant messages with filler user messages
|
||||
export function strictFormat(turns) {
|
||||
let prev_role = null;
|
||||
let messages = [];
|
||||
let filler = {role: 'user', content: '_'};
|
||||
for (let msg of turns) {
|
||||
if (msg.role === 'system') {
|
||||
msg.role = 'user';
|
||||
msg.content = 'SYSTEM: ' + msg.content;
|
||||
}
|
||||
if (msg.role === prev_role && msg.role === 'assistant') {
|
||||
// insert empty user message to separate assistant messages
|
||||
messages.push(filler);
|
||||
messages.push(msg);
|
||||
}
|
||||
else if (msg.role === prev_role) {
|
||||
// combine new message with previous message instead of adding a new one
|
||||
messages[messages.length-1].content += '\n' + msg.content;
|
||||
}
|
||||
else {
|
||||
messages.push(msg);
|
||||
}
|
||||
prev_role = msg.role;
|
||||
|
||||
}
|
||||
if (messages.length > 0 && messages[0].role !== 'user') {
|
||||
messages.unshift(filler); // anthropic requires user message to start
|
||||
}
|
||||
if (messages.length === 0) {
|
||||
messages.push(filler);
|
||||
}
|
||||
return messages;
|
||||
}
|
Loading…
Add table
Reference in a new issue