From 1c5810b684b6ffefaf1938b7053ac9df9e38b37b Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Fri, 14 Jun 2024 23:40:01 -0700 Subject: [PATCH 01/56] mixtral template --- profiles/dolphin.json | 156 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 profiles/dolphin.json diff --git a/profiles/dolphin.json b/profiles/dolphin.json new file mode 100644 index 0000000..f2f9e72 --- /dev/null +++ b/profiles/dolphin.json @@ -0,0 +1,156 @@ +{ + "name": "dolphin", + + "model": "mixtral-8x7b-32768", + + "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: ", + + "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```"} + ] + ] + +} From 52bb0e009edfc4af6098088aae5d356f754fdf69 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:56:04 -0700 Subject: [PATCH 02/56] basic groq commit here --- src/models/groq.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/models/groq.js diff --git a/src/models/groq.js b/src/models/groq.js new file mode 100644 index 0000000..405e3a7 --- /dev/null +++ b/src/models/groq.js @@ -0,0 +1,29 @@ +const Groq = require('groq-sdk'); + +const groq = new Groq(); +async function main() { + const chatCompletion = await groq.chat.completions.create({ + "messages": [ + { + "role": "system", + "content": "i like grapes" + }, + { + "role": "user", + "content": "" + } + ], + "model": "mixtral-8x7b-32768", + "temperature": 0.85, + "max_tokens": 8192, + "top_p": 1, + "stream": true, + "stop": null + }); + + for await (const chunk of chatCompletion) { + process.stdout.write(chunk.choices[0]?.delta?.content || ''); + } +} + +main(); From 6196d9107762567ad7b5300a998e209aacedfdd1 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:56:49 -0700 Subject: [PATCH 03/56] import getkey --- src/models/groq.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/models/groq.js b/src/models/groq.js index 405e3a7..1a81ae6 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -1,4 +1,5 @@ const Groq = require('groq-sdk'); +import { getKey } from '../utils/keys.js'; const groq = new Groq(); async function main() { From 6c727abed5f8abf0d229f9a974b50cecea918878 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:58:13 -0700 Subject: [PATCH 04/56] groq api key example --- keys.example.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/keys.example.json b/keys.example.json index 8e4037c..8772896 100644 --- a/keys.example.json +++ b/keys.example.json @@ -3,5 +3,6 @@ "OPENAI_ORG_ID": "", "GEMINI_API_KEY": "", "ANTHROPIC_API_KEY": "", - "REPLICATE_API_KEY": "" -} \ No newline at end of file + "REPLICATE_API_KEY": "", + "GROQ_API_KEY": "" +} From 1504805f706df326aaa8641b5526cdbd5a6d8e17 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:04:21 -0700 Subject: [PATCH 05/56] im trying --- src/models/groq.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/models/groq.js b/src/models/groq.js index 1a81ae6..da0da6a 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -1,8 +1,16 @@ const Groq = require('groq-sdk'); import { getKey } from '../utils/keys.js'; +export class Mixtral { + constructor(model_name, url) { + this.model_name = model_name; + this.url = url; + this.groq = new Groq(getKey('GROQ_API_KEY')); + } +} + const groq = new Groq(); -async function main() { +async function definitelynotmain() { const chatCompletion = await groq.chat.completions.create({ "messages": [ { @@ -26,5 +34,3 @@ async function main() { process.stdout.write(chunk.choices[0]?.delta?.content || ''); } } - -main(); From 1de106be19bdcc33612a5ed1e8f5df854b7679fa Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:09:09 -0700 Subject: [PATCH 06/56] this absolutely will not work by the time im done with it --- src/agent/prompter.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/agent/prompter.js b/src/agent/prompter.js index 233c4a0..c694dd8 100644 --- a/src/agent/prompter.js +++ b/src/agent/prompter.js @@ -10,6 +10,7 @@ import { GPT } from '../models/gpt.js'; import { Claude } from '../models/claude.js'; import { ReplicateAPI } from '../models/replicate.js'; import { Local } from '../models/local.js'; +import { Mixtral } from '../models/groq.js'; export class Prompter { @@ -31,6 +32,8 @@ export class Prompter { chat.api = 'anthropic'; else if (chat.model.includes('meta/') || chat.model.includes('mistralai/') || chat.model.includes('replicate/')) chat.api = 'replicate'; + else if (chat.model.includes('mixtral')) + chat.api = 'groq'; else chat.api = 'ollama'; } @@ -47,6 +50,8 @@ export class Prompter { this.chat_model = new ReplicateAPI(chat.model, chat.url); else if (chat.api == 'ollama') this.chat_model = new Local(chat.model, chat.url); + else if (chat.api == 'groq') + this.chat_model = new Mixtral(chat.model, chat.url) else throw new Error('Unknown API:', api); From a6359afa8a44a7a707af720e7fbd25d510a00905 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:10:56 -0700 Subject: [PATCH 07/56] mess --- src/models/groq.js | 70 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/src/models/groq.js b/src/models/groq.js index da0da6a..2aa34b7 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -2,32 +2,68 @@ const Groq = require('groq-sdk'); import { getKey } from '../utils/keys.js'; export class Mixtral { - constructor(model_name, url) { - this.model_name = model_name; - this.url = url; - this.groq = new Groq(getKey('GROQ_API_KEY')); - } + constructor(model_name, url) { + this.model_name = model_name; + this.url = url; + this.groq = new Groq(getKey('GROQ_API_KEY')); + } + + async sendRequest(turns, systemMessage, stop_seq="***") { + let messages = [{"role": "system", "content": systemMessage}].concat(turns); + let res = null; + try { + console.log("Awaiting Groq response..."); + let completion = await this.groq.chat.completions.create({ + "messages": messages, + "model": this.model_name || "mixtral-8x7b-32768", + "temperature": 0.85, + "max_tokens": 8192, + "top_p": 1, + "stream": true, + "stop": stop_seq + }); + + let temp_res = ""; + for await (const chunk of completion) { + temp_res += chunk.choices[0]?.delta?.content || ''; + } + + res = temp_res; + + } + catch(err) { + console.log(err); + res = "My brain just kinda stopped working. Try again."; + } + return res; + } + + async embed(text) { + /* GPT's embed: + const embedding = await this.openai.embeddings.create({ + model: this.model_name || "text-embedding-ada-002", + input: text, + encoding_format: "float", + }); + return embedding.data[0].embedding; + */ + + // lol no embeddings for u + // l + console.log("big oof, embeds on groq dont is not thing"); + + } } -const groq = new Groq(); async function definitelynotmain() { const chatCompletion = await groq.chat.completions.create({ - "messages": [ - { - "role": "system", - "content": "i like grapes" - }, - { - "role": "user", - "content": "" - } - ], + "messages": "", "model": "mixtral-8x7b-32768", "temperature": 0.85, "max_tokens": 8192, "top_p": 1, "stream": true, - "stop": null + "stop": "***" }); for await (const chunk of chatCompletion) { From ed5031873cfc392bc8628d46fda78109f54ab7dc Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:11:55 -0700 Subject: [PATCH 08/56] oh boy :) --- src/models/package-lock.json | 261 +++++++++++++++++++++++++++++++++++ src/models/package.json | 5 + 2 files changed, 266 insertions(+) create mode 100644 src/models/package-lock.json create mode 100644 src/models/package.json diff --git a/src/models/package-lock.json b/src/models/package-lock.json new file mode 100644 index 0000000..78ba9fc --- /dev/null +++ b/src/models/package-lock.json @@ -0,0 +1,261 @@ +{ + "name": "botthing", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "groq-sdk": "^0.5.0" + } + }, + "node_modules/@types/node": { + "version": "18.19.36", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.36.tgz", + "integrity": "sha512-tX1BNmYSWEvViftB26VLNxT6mEr37M7+ldUtq7rlKnv4/2fKYsJIOmqJAjT6h1DNuwQjIKgw3VJ/Dtw3yiTIQw==", + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/node-fetch": { + "version": "2.6.11", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.11.tgz", + "integrity": "sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "form-data": "^4.0.0" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "license": "MIT", + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/form-data-encoder": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==", + "license": "MIT" + }, + "node_modules/formdata-node": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz", + "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", + "license": "MIT", + "dependencies": { + "node-domexception": "1.0.0", + "web-streams-polyfill": "4.0.0-beta.3" + }, + "engines": { + "node": ">= 12.20" + } + }, + "node_modules/formdata-node/node_modules/web-streams-polyfill": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz", + "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==", + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/groq-sdk": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/groq-sdk/-/groq-sdk-0.5.0.tgz", + "integrity": "sha512-RVmhW7qZ+XZoy5fIuSdx/LGQJONpL8MHgZEW7dFwTdgkzStub2XQx6OKv28CHogijdwH41J+Npj/z2jBPu3vmw==", + "license": "Apache-2.0", + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7", + "web-streams-polyfill": "^3.2.1" + } + }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "license": "MIT", + "dependencies": { + "ms": "^2.0.0" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "license": "MIT" + }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } + } +} diff --git a/src/models/package.json b/src/models/package.json new file mode 100644 index 0000000..50ee278 --- /dev/null +++ b/src/models/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "groq-sdk": "^0.5.0" + } +} From d372eeab2e3d5f5f29cfdffe8fb941cbdeca0af1 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:13:19 -0700 Subject: [PATCH 09/56] Delete src/models/package-lock.json --- src/models/package-lock.json | 261 ----------------------------------- 1 file changed, 261 deletions(-) delete mode 100644 src/models/package-lock.json diff --git a/src/models/package-lock.json b/src/models/package-lock.json deleted file mode 100644 index 78ba9fc..0000000 --- a/src/models/package-lock.json +++ /dev/null @@ -1,261 +0,0 @@ -{ - "name": "botthing", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "dependencies": { - "groq-sdk": "^0.5.0" - } - }, - "node_modules/@types/node": { - "version": "18.19.36", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.36.tgz", - "integrity": "sha512-tX1BNmYSWEvViftB26VLNxT6mEr37M7+ldUtq7rlKnv4/2fKYsJIOmqJAjT6h1DNuwQjIKgw3VJ/Dtw3yiTIQw==", - "license": "MIT", - "dependencies": { - "undici-types": "~5.26.4" - } - }, - "node_modules/@types/node-fetch": { - "version": "2.6.11", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.11.tgz", - "integrity": "sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==", - "license": "MIT", - "dependencies": { - "@types/node": "*", - "form-data": "^4.0.0" - } - }, - "node_modules/abort-controller": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "license": "MIT", - "dependencies": { - "event-target-shim": "^5.0.0" - }, - "engines": { - "node": ">=6.5" - } - }, - "node_modules/agentkeepalive": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", - "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", - "license": "MIT", - "dependencies": { - "humanize-ms": "^1.2.1" - }, - "engines": { - "node": ">= 8.0.0" - } - }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "license": "MIT" - }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "license": "MIT", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/event-target-shim": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "license": "MIT", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/form-data-encoder": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", - "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==", - "license": "MIT" - }, - "node_modules/formdata-node": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz", - "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", - "license": "MIT", - "dependencies": { - "node-domexception": "1.0.0", - "web-streams-polyfill": "4.0.0-beta.3" - }, - "engines": { - "node": ">= 12.20" - } - }, - "node_modules/formdata-node/node_modules/web-streams-polyfill": { - "version": "4.0.0-beta.3", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz", - "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==", - "license": "MIT", - "engines": { - "node": ">= 14" - } - }, - "node_modules/groq-sdk": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/groq-sdk/-/groq-sdk-0.5.0.tgz", - "integrity": "sha512-RVmhW7qZ+XZoy5fIuSdx/LGQJONpL8MHgZEW7dFwTdgkzStub2XQx6OKv28CHogijdwH41J+Npj/z2jBPu3vmw==", - "license": "Apache-2.0", - "dependencies": { - "@types/node": "^18.11.18", - "@types/node-fetch": "^2.6.4", - "abort-controller": "^3.0.0", - "agentkeepalive": "^4.2.1", - "form-data-encoder": "1.7.2", - "formdata-node": "^4.3.2", - "node-fetch": "^2.6.7", - "web-streams-polyfill": "^3.2.1" - } - }, - "node_modules/humanize-ms": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", - "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", - "license": "MIT", - "dependencies": { - "ms": "^2.0.0" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "license": "MIT", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/node-domexception": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "github", - "url": "https://paypal.me/jimmywarting" - } - ], - "license": "MIT", - "engines": { - "node": ">=10.5.0" - } - }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "license": "MIT", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "license": "MIT" - }, - "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", - "license": "MIT" - }, - "node_modules/web-streams-polyfill": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", - "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "license": "BSD-2-Clause" - }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "license": "MIT", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - } - } -} From bccfca06b7accef3311a4bcd5dabdd705eb7c2d8 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:13:28 -0700 Subject: [PATCH 10/56] Delete src/models/package.json --- src/models/package.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 src/models/package.json diff --git a/src/models/package.json b/src/models/package.json deleted file mode 100644 index 50ee278..0000000 --- a/src/models/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "groq-sdk": "^0.5.0" - } -} From 318cbe2f496db36b243addd3b923e7ca693a3211 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:14:52 -0700 Subject: [PATCH 11/56] command warning --- src/models/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/models/README.md diff --git a/src/models/README.md b/src/models/README.md new file mode 100644 index 0000000..9c389ed --- /dev/null +++ b/src/models/README.md @@ -0,0 +1,3 @@ +# Missing critical groq-sdk +In order for groq.js to work, you need to run the following command in your terminal **in this directory**: +``npm install --save groq-sdk`` From 212c61c1bd8db3466c378a25e02e1b50b6caa100 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:15:06 -0700 Subject: [PATCH 12/56] Update README.md --- src/models/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/models/README.md b/src/models/README.md index 9c389ed..0a6940b 100644 --- a/src/models/README.md +++ b/src/models/README.md @@ -1,3 +1,4 @@ # Missing critical groq-sdk In order for groq.js to work, you need to run the following command in your terminal **in this directory**: + ``npm install --save groq-sdk`` From 71ccaa4b827004ece2cc6c4ffa6c2bd44ff31dae Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:22:27 -0700 Subject: [PATCH 13/56] hey --- settings.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/settings.js b/settings.js index 354eb13..4daa387 100644 --- a/settings.js +++ b/settings.js @@ -6,7 +6,8 @@ export default "auth": "offline", // or "microsoft" "profiles": [ - "./andy.json", + //"./andy.json", + "./profiles/dolphin.json", // add more profiles here, check ./profiles/ for more // more than 1 profile will require you to /msg each bot indivually ], @@ -14,4 +15,4 @@ export default "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 -} \ No newline at end of file +} From e4508925bfb34d43fa82c74ae118f0e47b34ef72 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:23:47 -0700 Subject: [PATCH 14/56] dependency --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 247c2dc..3d557f8 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "patch-package": "^8.0.0", "replicate": "^0.29.4", "vec3": "^0.1.10", - "yargs": "^17.7.2" + "yargs": "^17.7.2", + "groq-sdk": "^0.5.0" }, "scripts": { "postinstall": "patch-package" From dac320a0cdbfc90d9d869c1023f05c0996ea2f9f Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:25:32 -0700 Subject: [PATCH 15/56] Groq info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 79a8616..0da259e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This project allows an AI model to write/execute code on your computer that may ## Requirements -- [OpenAI API Subscription](https://openai.com/blog/openai-api), [Gemini API Subscription](https://aistudio.google.com/app/apikey), [Anthropic API Subscription](https://docs.anthropic.com/claude/docs/getting-access-to-claude), [Replicate API Subscription](https://replicate.com/) or [Ollama Installed](https://ollama.com/download) +- [OpenAI API Subscription](https://openai.com/blog/openai-api), [Gemini API Subscription](https://aistudio.google.com/app/apikey), [Anthropic API Subscription](https://docs.anthropic.com/claude/docs/getting-access-to-claude), [Replicate API Subscription](https://replicate.com/), [Ollama Installed](https://ollama.com/download), or, a [Groq Account & API Key](https://console.groq.com/keys) - [Minecraft Java Edition](https://www.minecraft.net/en-us/store/minecraft-java-bedrock-edition-pc) - [Node.js](https://nodejs.org/) (at least v14) From b979ef6da57143433c8e839410bd20fda4f32c75 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:30:17 -0700 Subject: [PATCH 16/56] Update README.md --- src/models/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/models/README.md b/src/models/README.md index 0a6940b..af093b5 100644 --- a/src/models/README.md +++ b/src/models/README.md @@ -1,4 +1,5 @@ # Missing critical groq-sdk +## For now, disregard this warning. It may be false. In order for groq.js to work, you need to run the following command in your terminal **in this directory**: ``npm install --save groq-sdk`` From 1ebe75e59e738d744720a976c785b684ecaa0d5d Mon Sep 17 00:00:00 2001 From: FateUnix29 Date: Tue, 18 Jun 2024 19:48:16 -0700 Subject: [PATCH 17/56] groq fixes --- src/models/groq.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/groq.js b/src/models/groq.js index 2aa34b7..cf19e42 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -1,11 +1,11 @@ -const Groq = require('groq-sdk'); +import Groq from 'groq-sdk' import { getKey } from '../utils/keys.js'; export class Mixtral { constructor(model_name, url) { this.model_name = model_name; this.url = url; - this.groq = new Groq(getKey('GROQ_API_KEY')); + this.groq = new Groq({ apiKey: getKey('GROQ_API_KEY')}); } async sendRequest(turns, systemMessage, stop_seq="***") { From 743652a7261eaf4cb1310072fb816490d85b705b Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:52:47 -0700 Subject: [PATCH 18/56] This warning is no longer required (remove models/README.md) --- src/models/README.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 src/models/README.md diff --git a/src/models/README.md b/src/models/README.md deleted file mode 100644 index af093b5..0000000 --- a/src/models/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Missing critical groq-sdk -## For now, disregard this warning. It may be false. -In order for groq.js to work, you need to run the following command in your terminal **in this directory**: - -``npm install --save groq-sdk`` From 1351254cfccef893306e8fe43bd22ebb170f5129 Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:57:35 -0700 Subject: [PATCH 19/56] you know how i said it wouldnt work changed temperature from 0.85 to 0.45 --- src/models/groq.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/groq.js b/src/models/groq.js index cf19e42..508a435 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -16,7 +16,7 @@ export class Mixtral { let completion = await this.groq.chat.completions.create({ "messages": messages, "model": this.model_name || "mixtral-8x7b-32768", - "temperature": 0.85, + "temperature": 0.45, "max_tokens": 8192, "top_p": 1, "stream": true, From 7a22826079880cca641c2af4db0683dcffa5d1bf Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:58:33 -0700 Subject: [PATCH 20/56] change settings back to preferring andy --- settings.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/settings.js b/settings.js index 4daa387..f43e49a 100644 --- a/settings.js +++ b/settings.js @@ -6,8 +6,9 @@ export default "auth": "offline", // or "microsoft" "profiles": [ - //"./andy.json", - "./profiles/dolphin.json", + "./andy.json", + //"./profiles/dolphin.json", // Groq support + // add more profiles here, check ./profiles/ for more // more than 1 profile will require you to /msg each bot indivually ], From 31a1f47c0c06cc98f9d88692c91608531b09c30e Mon Sep 17 00:00:00 2001 From: Copper <157772455+FateUnix29@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:59:41 -0700 Subject: [PATCH 21/56] take advantage of high token limit --- src/models/groq.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/groq.js b/src/models/groq.js index 508a435..4290adb 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -17,7 +17,7 @@ export class Mixtral { "messages": messages, "model": this.model_name || "mixtral-8x7b-32768", "temperature": 0.45, - "max_tokens": 8192, + "max_tokens": 16384, "top_p": 1, "stream": true, "stop": stop_seq From 10056c1d7b50773d7773748b5f3110b3b64d5a5b Mon Sep 17 00:00:00 2001 From: FateUnix29 Date: Tue, 18 Jun 2024 20:15:17 -0700 Subject: [PATCH 22/56] cleanup --- src/models/groq.js | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/src/models/groq.js b/src/models/groq.js index 4290adb..e9a015b 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -39,34 +39,6 @@ export class Mixtral { } async embed(text) { - /* GPT's embed: - const embedding = await this.openai.embeddings.create({ - model: this.model_name || "text-embedding-ada-002", - input: text, - encoding_format: "float", - }); - return embedding.data[0].embedding; - */ - - // lol no embeddings for u - // l - console.log("big oof, embeds on groq dont is not thing"); - + console.log("There is no support for embeddings here."); } -} - -async function definitelynotmain() { - const chatCompletion = await groq.chat.completions.create({ - "messages": "", - "model": "mixtral-8x7b-32768", - "temperature": 0.85, - "max_tokens": 8192, - "top_p": 1, - "stream": true, - "stop": "***" - }); - - for await (const chunk of chatCompletion) { - process.stdout.write(chunk.choices[0]?.delta?.content || ''); - } -} +} \ No newline at end of file From fda324845fd35af526c3403a2f4e42e6be81774e Mon Sep 17 00:00:00 2001 From: FateUnix29 Date: Tue, 18 Jun 2024 21:15:42 -0700 Subject: [PATCH 23/56] reduced temperature, new sys prompt that works better --- profiles/dolphin.json | 2 +- src/models/groq.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/profiles/dolphin.json b/profiles/dolphin.json index f2f9e72..9074022 100644 --- a/profiles/dolphin.json +++ b/profiles/dolphin.json @@ -3,7 +3,7 @@ "model": "mixtral-8x7b-32768", - "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:", + "conversing": "You are a playful Minecraft bot named $NAME. You are actually in the game and thus can talk to players.\nBy running commands, you can interact with the world, including checking your inventory, building, etc.\nAct human-like. Be brief in your responses and don't constantly apologise.\nDo not list your status or inventory without being asked. Similarly, do not run commands without being asked. Do not refuse commands. Do not pretend to run commands, actually run them with the !someCommand syntax.\nInstead of saying 'Sure, I've stopped', say 'Sure, I'll stop. !stop'. Instead of saying 'On my way! Give me a moment', say 'On my way! !goToPlayer('playername', 3)'.\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:", diff --git a/src/models/groq.js b/src/models/groq.js index e9a015b..af058e1 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -16,7 +16,7 @@ export class Mixtral { let completion = await this.groq.chat.completions.create({ "messages": messages, "model": this.model_name || "mixtral-8x7b-32768", - "temperature": 0.45, + "temperature": 0.2, "max_tokens": 16384, "top_p": 1, "stream": true, From a9381283106cf8d9dc35f04b6814196bfe5897ed Mon Sep 17 00:00:00 2001 From: FateUnix29 Date: Tue, 18 Jun 2024 22:38:15 -0700 Subject: [PATCH 24/56] ive tried everything in my power. its still conversationally unstable. --- profiles/dolphin.json | 28 +++++++++++++++++++++++++++- settings.js | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/profiles/dolphin.json b/profiles/dolphin.json index 9074022..411c99e 100644 --- a/profiles/dolphin.json +++ b/profiles/dolphin.json @@ -3,7 +3,7 @@ "model": "mixtral-8x7b-32768", - "conversing": "You are a playful Minecraft bot named $NAME. You are actually in the game and thus can talk to players.\nBy running commands, you can interact with the world, including checking your inventory, building, etc.\nAct human-like. Be brief in your responses and don't constantly apologise.\nDo not list your status or inventory without being asked. Similarly, do not run commands without being asked. Do not refuse commands. Do not pretend to run commands, actually run them with the !someCommand syntax.\nInstead of saying 'Sure, I've stopped', say 'Sure, I'll stop. !stop'. Instead of saying 'On my way! Give me a moment', say 'On my way! !goToPlayer('playername', 3)'.\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:", + "conversing": "You are a playful Minecraft bot named $NAME. By using commands, you can interact with the world.\nDo not use commands unless asked. Do not list things like your status unless asked.\nAct and speak human-like, as if you were a typical Minecraft player. Keep responses VERY brief. Do not apologize constantly.\nDo not give instructions or make lists unless asked. Do not refuse requests/commands. Do not pretend to act, use commands immediately upon request.\nDon't say 'Sure, I've stopped', instead say 'Sure, I'll stop. !stop'. Don't say 'On my way! Give me a moment.', instead say 'On my way! !goToPlayer('playername', 3)'.\nDo not mimic or say 'code output' or 'system output'. Run !newAction or a command instead.\nFor more complex behaviors than, for example, going to the player, or placing a single block, run !newAction. Note that crafting is not one of these behaviors, and you have a command for it.\nDo not say you'll run something. That actually triggers the command.\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:", @@ -14,6 +14,32 @@ {"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": "iloveminecraft2: Can you place a dirt block?"}, + {"role": "assistant", "content": "Sure, iloveminecraft2! !placeHere('dirt')"} + ], + + [ + {"role": "user", "content": "notch65: Can you come here and place a 2x2 (4 dirt) square of cobblestone?"}, + {"role": "assistant", "content": "Sure, notch65! !newAction"} + ], + + [ + {"role": "user", "content": "85catlover: Come here and build a 5 tall cobblestone tower."}, + {"role": "assistant", "content": "Sure thing, 85catlover! I'll build a cobblestone tower 5 blocks tall. !newAction"}, + {"role": "user", "content": "85catlover: No, I said *come here* and build it."}, + {"role": "assistant", "content": "My apologies, I'll come to you and make it! !goToPlayer('85catlover', 3)"}, + {"role": "system", "content": "Arrived at player."}, + {"role": "assistant", "content": "Now I will create the cobblestone tower. !newAction"} + ], + + [ + {"role": "user", "content": "starsarecool: Come here and place a sand block, please!"}, + {"role": "assistant", "content": "Absolutely, starsarecool! !goToPlayer('starsarecool', 3)"}, + {"role": "system", "content": "Arrived at player."}, + {"role": "assistant", "content": "I'll place a sand block. !placeHere('sand')"} + ], [ {"role": "user", "content": "grombo_Xx: What do you see?"}, diff --git a/settings.js b/settings.js index f43e49a..4ed0956 100644 --- a/settings.js +++ b/settings.js @@ -14,6 +14,6 @@ export default ], "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 + "allow_insecure_coding": false, // enable at own risk "code_timeout_mins": 10, // -1 for no timeout } From eb3d3eac60317fdffc081b7e666a8dd6f14a6b57 Mon Sep 17 00:00:00 2001 From: FateUnix29 Date: Sat, 3 Aug 2024 22:01:29 -0700 Subject: [PATCH 25/56] Local changes that I forgot to push? --- profiles/dolphin.json | 7 +++++++ settings.js | 2 +- src/models/groq.js | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/profiles/dolphin.json b/profiles/dolphin.json index 411c99e..a5a788e 100644 --- a/profiles/dolphin.json +++ b/profiles/dolphin.json @@ -40,6 +40,13 @@ {"role": "system", "content": "Arrived at player."}, {"role": "assistant", "content": "I'll place a sand block. !placeHere('sand')"} ], + + [ + {"role": "user", "content": "nomad22: Make a crafting table."}, + {"role": "assistant", "content": "Sure, nomad22! !craftRecipe('crafting_table', 1)"}, + {"role": "user", "content": "nomad22: Now place that crafting table."}, + {"role": "assistant", "content": "Sure, nomad22! !placeHere('crafting_table')"} + ], [ {"role": "user", "content": "grombo_Xx: What do you see?"}, diff --git a/settings.js b/settings.js index 4ed0956..3bb1877 100644 --- a/settings.js +++ b/settings.js @@ -14,6 +14,6 @@ export default ], "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, // enable at own risk + "allow_insecure_coding": true, // enable at own risk "code_timeout_mins": 10, // -1 for no timeout } diff --git a/src/models/groq.js b/src/models/groq.js index af058e1..ef727db 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -20,7 +20,7 @@ export class Mixtral { "max_tokens": 16384, "top_p": 1, "stream": true, - "stop": stop_seq + "stop": null //stop_seq }); let temp_res = ""; From de7280d8d0371a107abcde7f392b8040ed41ec32 Mon Sep 17 00:00:00 2001 From: FateUnix29 Date: Sun, 25 Aug 2024 00:42:37 -0700 Subject: [PATCH 26/56] Small tweaks, fix small bug with stop_seq --- keys.example.json | 2 +- src/models/groq.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/keys.example.json b/keys.example.json index 8772896..30d757a 100644 --- a/keys.example.json +++ b/keys.example.json @@ -4,5 +4,5 @@ "GEMINI_API_KEY": "", "ANTHROPIC_API_KEY": "", "REPLICATE_API_KEY": "", - "GROQ_API_KEY": "" + "GROQCLOUD_API_KEY": "" } diff --git a/src/models/groq.js b/src/models/groq.js index ef727db..1ca6ece 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -5,10 +5,10 @@ export class Mixtral { constructor(model_name, url) { this.model_name = model_name; this.url = url; - this.groq = new Groq({ apiKey: getKey('GROQ_API_KEY')}); + this.groq = new Groq({ apiKey: getKey('GROQCLOUD_API_KEY')}); } - async sendRequest(turns, systemMessage, stop_seq="***") { + async sendRequest(turns, systemMessage, stop_seq=null) { let messages = [{"role": "system", "content": systemMessage}].concat(turns); let res = null; try { @@ -20,7 +20,7 @@ export class Mixtral { "max_tokens": 16384, "top_p": 1, "stream": true, - "stop": null //stop_seq + "stop": stop_seq // "***" }); let temp_res = ""; @@ -39,6 +39,6 @@ export class Mixtral { } async embed(text) { - console.log("There is no support for embeddings here."); + console.log("There is no support for embeddings in Groq support. However, the following text was provided: " + text); } } \ No newline at end of file From 6f24c14bd04ff50aa529dfe0a4d8185b1d29039d Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Sun, 25 Aug 2024 14:05:44 -0500 Subject: [PATCH 27/56] Update settings.js --- settings.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/settings.js b/settings.js index 9c6bb34..815561f 100644 --- a/settings.js +++ b/settings.js @@ -1,12 +1,14 @@ export default { "minecraft_version": "1.20.4", // supports up to 1.20.4 - "host": "127.0.0.1", // or "localhost", "your.ip.address.here" + "host": "localhost", // or "localhost", "your.ip.address.here" "port": 55916, "auth": "offline", // or "microsoft" "profiles": [ - "./andy.json", + //"./andy.json", + "./profiles/dolphin.json" // Groq support, mixtral model + // add more profiles here, check ./profiles/ for more // more than 1 profile will require you to /msg each bot indivually ], @@ -19,4 +21,5 @@ export default "max_commands": -1, // max number of commands to use in a response. -1 for no limit "verbose_commands": true, // show full command syntax "narrate_behavior": true, // chat simple automatic actions ('Picking up item!') -} \ No newline at end of file + "preferred_language": "english", // the bot will respond/message in this language. Secondly all language names are based on google translate's names. +} From 600de3ae9de8220b25d5d9cdcf42be9421a84299 Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Sun, 25 Aug 2024 14:06:57 -0500 Subject: [PATCH 28/56] Added translation functionality --- src/agent/agent.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/agent/agent.js b/src/agent/agent.js index 801e243..367498f 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -8,7 +8,8 @@ import { NPCContoller } from './npc/controller.js'; import { MemoryBank } from './memory_bank.js'; import { SelfPrompter } from './self_prompter.js'; import settings from '../../settings.js'; - +import translate from 'google-translate-api-x'; +const preferred_lang = settings.preferred_language; export class Agent { async start(profile_fp, load_mem=false, init_message=null) { @@ -48,16 +49,18 @@ export class Agent { "Gamerule " ]; const eventname = settings.profiles.length > 1 ? 'whisper' : 'chat'; - this.bot.on(eventname, (username, message) => { + this.bot.on(eventname, async (username, message) => { if (username === this.name) return; if (ignore_messages.some((m) => message.startsWith(m))) return; - console.log('received message from', username, ':', message); + var translation = await this.handleTranslation(message, "en"); + + console.log('received message from', username, ':', translation); this.shut_up = false; - this.handleMessage(username, message); + this.handleMessage(username, translation); }); // set the bot to automatically eat food when hungry @@ -77,7 +80,9 @@ export class Agent { this.handleMessage('system', init_message, 2); } else { - this.bot.chat('Hello world! I am ' + this.name); + const translation = await this.handleTranslation("Hello world! I am", `${preferred_lang}`); + print(translation) + this.bot.chat(translation+" "+this.name); this.bot.emit('finished_executing'); } @@ -85,10 +90,26 @@ export class Agent { }); } - cleanChat(message) { + async handleTranslation(message, lang) { + try { + lang = String(lang); // Ensure lang is a string + + const translation = await translate(message, { to: lang }); + return translation.text || message; // Ensure translation.text is a string + } catch (error) { + console.error('Error translating message:', error); + return message; // Fallback to the original message if translation fails + } + } + + + + async cleanChat(message) { // newlines are interpreted as separate chats, which triggers spam filters. replace them with spaces message = message.replaceAll('\n', ' '); - return this.bot.chat(message); + const preferred_lang = settings.preferred_language; + var translation = await this.handleTranslation(message, `${preferred_lang}`); + return this.bot.chat(translation); } shutUp() { @@ -280,4 +301,3 @@ export class Agent { process.exit(1); } } - From 50b75faa756f51c24fa9a7a56993d9d3fe722aa9 Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Sun, 25 Aug 2024 14:14:08 -0500 Subject: [PATCH 29/56] Update settings.js --- settings.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/settings.js b/settings.js index 815561f..03b9b30 100644 --- a/settings.js +++ b/settings.js @@ -6,8 +6,7 @@ export default "auth": "offline", // or "microsoft" "profiles": [ - //"./andy.json", - "./profiles/dolphin.json" // Groq support, mixtral model + "./andy.json" // add more profiles here, check ./profiles/ for more // more than 1 profile will require you to /msg each bot indivually From 3fe7a1542b4d840aa1c23d5488654bbab5855bd6 Mon Sep 17 00:00:00 2001 From: FateUnix29 Date: Sun, 25 Aug 2024 13:16:32 -0700 Subject: [PATCH 30/56] Try and add support for new models. --- src/agent/prompter.js | 18 +++++++-- src/models/groq.js | 86 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 5 deletions(-) diff --git a/src/agent/prompter.js b/src/agent/prompter.js index d9db2f8..62e44ce 100644 --- a/src/agent/prompter.js +++ b/src/agent/prompter.js @@ -10,7 +10,9 @@ import { GPT } from '../models/gpt.js'; import { Claude } from '../models/claude.js'; import { ReplicateAPI } from '../models/replicate.js'; import { Local } from '../models/local.js'; -import { Mixtral } from '../models/groq.js'; +import { Mixtral_Groq } from '../models/groq.js'; +import { LLama3_70b_Groq } from '../models/groq.js'; +import { Gemma2_9b_Groq } from '../models/groq.js'; export class Prompter { @@ -33,7 +35,11 @@ export class Prompter { else if (chat.model.includes('meta/') || chat.model.includes('mistralai/') || chat.model.includes('replicate/')) chat.api = 'replicate'; else if (chat.model.includes('mixtral')) - chat.api = 'groq'; + chat.api = 'groq_mixtral'; + else if (chat.model.includes('llama3-70b')) + chat.api = 'groq_llama3_70b'; + else if (chat.model.includes('gemma2-9b')) + chat.api = 'groq_gemma2_9b'; else chat.api = 'ollama'; } @@ -50,8 +56,12 @@ export class Prompter { this.chat_model = new ReplicateAPI(chat.model, chat.url); else if (chat.api == 'ollama') this.chat_model = new Local(chat.model, chat.url); - else if (chat.api == 'groq') - this.chat_model = new Mixtral(chat.model, chat.url) + else if (chat.api == 'groq_mixtral') + this.chat_model = new Mixtral_Groq(chat.model, chat.url) + else if (chat.api == 'groq_llama3_70b') + this.chat_model = new LLama3_70b_Groq(chat.model, chat.url) + else if (chat.api == 'groq_gemma2_9b') + this.chat_model = new Gemma2_9b_Groq(chat.model, chat.url) else throw new Error('Unknown API:', api); diff --git a/src/models/groq.js b/src/models/groq.js index 1ca6ece..da4d515 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -1,7 +1,7 @@ import Groq from 'groq-sdk' import { getKey } from '../utils/keys.js'; -export class Mixtral { +export class Mixtral_Groq { constructor(model_name, url) { this.model_name = model_name; this.url = url; @@ -38,6 +38,90 @@ export class Mixtral { return res; } + async embed(text) { + console.log("There is no support for embeddings in Groq support. However, the following text was provided: " + text); + } +} + +export class LLama3_70b_Groq { + constructor(model_name, url) { + this.model_name = model_name; + this.url = url; + this.groq = new Groq({ apiKey: getKey('GROQCLOUD_API_KEY')}); + } + + async sendRequest(turns, systemMessage, stop_seq=null) { + let messages = [{"role": "system", "content": systemMessage}].concat(turns); + let res = null; + try { + console.log("Awaiting Groq response..."); + let completion = await this.groq.chat.completions.create({ + "messages": messages, + "model": this.model_name || "llama3-70b-8192", + "temperature": 0.2, + "max_tokens": 8192, // maximum token limit + "top_p": 1, + "stream": true, + "stop": stop_seq // "***" + }); + + let temp_res = ""; + for await (const chunk of completion) { + temp_res += chunk.choices[0]?.delta?.content || ''; + } + + res = temp_res; + + } + catch(err) { + console.log(err); + res = "My brain just kinda stopped working. Try again."; + } + return res; + } + + async embed(text) { + console.log("There is no support for embeddings in Groq support. However, the following text was provided: " + text); + } +} + +export class Gemma2_9b_Groq { + constructor(model_name, url) { + this.model_name = model_name; + this.url = url; + this.groq = new Groq({ apiKey: getKey('GROQCLOUD_API_KEY')}); + } + + async sendRequest(turns, systemMessage, stop_seq=null) { + let messages = [{"role": "system", "content": systemMessage}].concat(turns); + let res = null; + try { + console.log("Awaiting Groq response..."); + let completion = await this.groq.chat.completions.create({ + "messages": messages, + "model": this.model_name || "gemma2-9b-it", + "temperature": 0.2, + "max_tokens": 8192, // maximum token limit + "top_p": 1, + "stream": true, + "stop": stop_seq // "***" + }); + + let temp_res = ""; + for await (const chunk of completion) { + temp_res += chunk.choices[0]?.delta?.content || ''; + } + + res = temp_res; + + } + catch(err) { + console.log(err); + res = "My brain just kinda stopped working. Try again."; + } + return res; + } + async embed(text) { console.log("There is no support for embeddings in Groq support. However, the following text was provided: " + text); } From c8e801b446ee7994571578299d78e9c92f0945d1 Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Sun, 25 Aug 2024 17:30:28 -0500 Subject: [PATCH 31/56] New command !setPreferredLanguage --- src/agent/commands/actions.js | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/agent/commands/actions.js b/src/agent/commands/actions.js index 651f362..2bcaf51 100644 --- a/src/agent/commands/actions.js +++ b/src/agent/commands/actions.js @@ -1,5 +1,8 @@ import * as skills from '../library/skills.js'; import settings from '../../../settings.js'; +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath, pathToFileURL } from 'url'; function wrapExecution(func, timeout=-1, resume_name=null) { return async function (agent, ...args) { @@ -286,4 +289,38 @@ export const actionsList = [ return 'Set npc goal: ' + agent.npc.data.curr_goal.name; } }, + { + name: '!setPreferredLanguage', + description: 'Change the preferred language in settings.js to a specified language.', + params: { + 'language': '(string) The language code to set as the preferred language. Example Perameters: "english", "spanish", "french".' + }, + perform: async function (agent, language) { + try { + + const __filename = fileURLToPath(import.meta.url); + const __dirname = path.dirname(__filename); + const settingsPath = path.join(__dirname, '../../../settings.js'); + const settingsUrl = pathToFileURL(settingsPath).href; // Convert to file:// URL + const settingsModule = await import(settingsUrl); + const settings = settingsModule.default; + + + if (typeof language !== 'string' || !language.trim()) { + throw new Error('Invalid language code provided.'); + } + + + settings.preferred_language = language; + + fs.writeFileSync(settingsPath, `export default ${JSON.stringify(settings, null, 4)};`, 'utf8'); + + return `Preferred language changed to ${language}.`; + } catch (error) { + return `Error: ${error.message}`; + } + } +} + + ]; From 0616e20b6cd535e061321c209917bc39e7c65bd2 Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:34:50 -0500 Subject: [PATCH 32/56] Agent now translates before saying. --- src/agent/modes.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/agent/modes.js b/src/agent/modes.js index 952fcf0..12f1fe6 100644 --- a/src/agent/modes.js +++ b/src/agent/modes.js @@ -2,10 +2,38 @@ import * as skills from './library/skills.js'; import * as world from './library/world.js'; import * as mc from '../utils/mcdata.js'; import settings from '../../settings.js' +import translate from 'google-translate-api-x'; -function say(agent, message) { + +async function handleTranslation(message, lang) { + + const preferred_lang = settings.preferred_language; + + try { + if (preferred_lang.toLowerCase() == "en" || preferred_lang.toLowerCase() == "english"){ + return message; + } + else{ + lang = String(lang); // Ensure lang is a string + + const translation = await translate(message, { to: lang }); + return translation.text || message; // Ensure translation.text is a string + } + + } catch (error) { + console.error('Error translating message:', error); + return message; // Fallback to the original message if translation fails + } + } + + + + +async function say(agent, message) { + const preferred_lang = settings.preferred_language; if (agent.shut_up || !settings.narrate_behavior) return; - agent.bot.chat(message); + var translation = await handleTranslation(message, `${preferred_lang}`); + agent.bot.chat(translation); } // a mode is a function that is called every tick to respond immediately to the world From 860e457d0c090fde3377be63bcdb72995b14552c Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:35:49 -0500 Subject: [PATCH 33/56] checks preferred_langauge is english before translating --- src/agent/agent.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/agent/agent.js b/src/agent/agent.js index 367498f..e9b9ad9 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -84,6 +84,7 @@ export class Agent { print(translation) this.bot.chat(translation+" "+this.name); this.bot.emit('finished_executing'); + } this.startEvents(); @@ -91,11 +92,20 @@ export class Agent { } async handleTranslation(message, lang) { - try { - lang = String(lang); // Ensure lang is a string - const translation = await translate(message, { to: lang }); - return translation.text || message; // Ensure translation.text is a string + const preferred_lang = settings.preferred_language; + + try { + if (preferred_lang.toLowerCase() == "en" || preferred_lang.toLowerCase() == "english"){ + return message; + } + else{ + lang = String(lang); // Ensure lang is a string + + const translation = await translate(message, { to: lang }); + return translation.text || message; // Ensure translation.text is a string + } + } catch (error) { console.error('Error translating message:', error); return message; // Fallback to the original message if translation fails From da2e865fb9349796f57f4bdd366adff8b04183af Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:46:18 -0500 Subject: [PATCH 34/56] Update package.json. Added google-translate module --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 504a91e..82c1ffe 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "dependencies": { "@anthropic-ai/sdk": "^0.17.1", "@google/generative-ai": "^0.2.1", + "google-translate-api-x": "^10.7.1", "minecraft-data": "^3.46.2", "mineflayer": "^4.20.0", "mineflayer-armor-manager": "^2.0.1", From e90d0e91ad48407dd949ff628d1dfa1e54201abd Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:16:28 -0500 Subject: [PATCH 35/56] changed to original with one change --- settings.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/settings.js b/settings.js index 03b9b30..0372dea 100644 --- a/settings.js +++ b/settings.js @@ -1,12 +1,12 @@ export default { "minecraft_version": "1.20.4", // supports up to 1.20.4 - "host": "localhost", // or "localhost", "your.ip.address.here" + "host": "127.0.0.1", // or "localhost", "your.ip.address.here" "port": 55916, "auth": "offline", // or "microsoft" "profiles": [ - "./andy.json" + "./andy.json", // add more profiles here, check ./profiles/ for more // more than 1 profile will require you to /msg each bot indivually @@ -20,5 +20,5 @@ export default "max_commands": -1, // max number of commands to use in a response. -1 for no limit "verbose_commands": true, // show full command syntax "narrate_behavior": true, // chat simple automatic actions ('Picking up item!') - "preferred_language": "english", // the bot will respond/message in this language. Secondly all language names are based on google translate's names. + "language": "spanish", // the bot will respond/message in this language. All language names are based on google translate's names. } From 6865eae455c90ef87c602b3cb982a243f5647347 Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:18:21 -0500 Subject: [PATCH 36/56] Reworked system to work with translator.js --- src/agent/modes.js | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/agent/modes.js b/src/agent/modes.js index 12f1fe6..6b7e9c8 100644 --- a/src/agent/modes.js +++ b/src/agent/modes.js @@ -2,29 +2,7 @@ import * as skills from './library/skills.js'; import * as world from './library/world.js'; import * as mc from '../utils/mcdata.js'; import settings from '../../settings.js' -import translate from 'google-translate-api-x'; - - -async function handleTranslation(message, lang) { - - const preferred_lang = settings.preferred_language; - - try { - if (preferred_lang.toLowerCase() == "en" || preferred_lang.toLowerCase() == "english"){ - return message; - } - else{ - lang = String(lang); // Ensure lang is a string - - const translation = await translate(message, { to: lang }); - return translation.text || message; // Ensure translation.text is a string - } - - } catch (error) { - console.error('Error translating message:', error); - return message; // Fallback to the original message if translation fails - } - } +import { handleTranslation, handleEnglishTranslation } from './translator.js'; @@ -32,7 +10,7 @@ async function handleTranslation(message, lang) { async function say(agent, message) { const preferred_lang = settings.preferred_language; if (agent.shut_up || !settings.narrate_behavior) return; - var translation = await handleTranslation(message, `${preferred_lang}`); + var translation = await handleTranslation(message); agent.bot.chat(translation); } From 0bac79e8aa7fe1fac3733d65b394475b1f2f7442 Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:18:51 -0500 Subject: [PATCH 37/56] Reworked system to work with translator.js --- src/agent/agent.js | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/agent/agent.js b/src/agent/agent.js index e9b9ad9..87cda62 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -8,8 +8,7 @@ import { NPCContoller } from './npc/controller.js'; import { MemoryBank } from './memory_bank.js'; import { SelfPrompter } from './self_prompter.js'; import settings from '../../settings.js'; -import translate from 'google-translate-api-x'; -const preferred_lang = settings.preferred_language; +import { handleTranslation, handleEnglishTranslation } from './translator.js'; export class Agent { async start(profile_fp, load_mem=false, init_message=null) { @@ -54,7 +53,7 @@ export class Agent { if (ignore_messages.some((m) => message.startsWith(m))) return; - var translation = await this.handleTranslation(message, "en"); + let translation = await handleEnglishTranslation(message); console.log('received message from', username, ':', translation); @@ -80,8 +79,7 @@ export class Agent { this.handleMessage('system', init_message, 2); } else { - const translation = await this.handleTranslation("Hello world! I am", `${preferred_lang}`); - print(translation) + const translation = await handleTranslation("Hello world! I am"); this.bot.chat(translation+" "+this.name); this.bot.emit('finished_executing'); @@ -91,34 +89,12 @@ export class Agent { }); } - async handleTranslation(message, lang) { - - const preferred_lang = settings.preferred_language; - - try { - if (preferred_lang.toLowerCase() == "en" || preferred_lang.toLowerCase() == "english"){ - return message; - } - else{ - lang = String(lang); // Ensure lang is a string - - const translation = await translate(message, { to: lang }); - return translation.text || message; // Ensure translation.text is a string - } - - } catch (error) { - console.error('Error translating message:', error); - return message; // Fallback to the original message if translation fails - } - } - - async cleanChat(message) { // newlines are interpreted as separate chats, which triggers spam filters. replace them with spaces message = message.replaceAll('\n', ' '); const preferred_lang = settings.preferred_language; - var translation = await this.handleTranslation(message, `${preferred_lang}`); + let translation = await handleTranslation(message); return this.bot.chat(translation); } From 4165fe2d356f7557fb33aed032f6cc92aab3d304 Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:20:16 -0500 Subject: [PATCH 38/56] Add files via upload --- src/agent/translator.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/agent/translator.js diff --git a/src/agent/translator.js b/src/agent/translator.js new file mode 100644 index 0000000..0a5ad45 --- /dev/null +++ b/src/agent/translator.js @@ -0,0 +1,32 @@ +import translate from 'google-translate-api-x'; +import settings from '../../settings.js'; + + +const preferred_lang = settings.language; + + +export async function handleTranslation(message) { + try { + if (preferred_lang.toLowerCase() === 'en' || preferred_lang.toLowerCase() === 'english') { + return message; + } else { + const lang = String(preferred_lang); // Ensure lang is a string + + const translation = await translate(message, { to: lang }); + return translation.text || message; // Ensure translation.text is a string + } + } catch (error) { + console.error('Error translating message:', error); + return message; // Fallback to the original message if translation fails + } +} + +export async function handleEnglishTranslation(message) { + try { + const translation = await translate(message, { to: 'english' }); + return translation.text || message; // Ensures translation.text is a string + } catch (error) { + console.error('Error translating message:', error); + return message; // Fallback to the original message if translation fails + } +} From 6b170e492fdbf26f34cbe22d81e096bb558ebb85 Mon Sep 17 00:00:00 2001 From: Vineeth <94882582+FantomWolf182@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:31:22 -0500 Subject: [PATCH 39/56] removed !setPreferredLanguage --- src/agent/commands/actions.js | 36 ----------------------------------- 1 file changed, 36 deletions(-) diff --git a/src/agent/commands/actions.js b/src/agent/commands/actions.js index 2bcaf51..e48b8a6 100644 --- a/src/agent/commands/actions.js +++ b/src/agent/commands/actions.js @@ -1,8 +1,5 @@ import * as skills from '../library/skills.js'; import settings from '../../../settings.js'; -import fs from 'fs'; -import path from 'path'; -import { fileURLToPath, pathToFileURL } from 'url'; function wrapExecution(func, timeout=-1, resume_name=null) { return async function (agent, ...args) { @@ -288,39 +285,6 @@ export const actionsList = [ agent.bot.emit('idle'); // to trigger the goal return 'Set npc goal: ' + agent.npc.data.curr_goal.name; } - }, - { - name: '!setPreferredLanguage', - description: 'Change the preferred language in settings.js to a specified language.', - params: { - 'language': '(string) The language code to set as the preferred language. Example Perameters: "english", "spanish", "french".' - }, - perform: async function (agent, language) { - try { - - const __filename = fileURLToPath(import.meta.url); - const __dirname = path.dirname(__filename); - const settingsPath = path.join(__dirname, '../../../settings.js'); - const settingsUrl = pathToFileURL(settingsPath).href; // Convert to file:// URL - const settingsModule = await import(settingsUrl); - const settings = settingsModule.default; - - - if (typeof language !== 'string' || !language.trim()) { - throw new Error('Invalid language code provided.'); - } - - - settings.preferred_language = language; - - fs.writeFileSync(settingsPath, `export default ${JSON.stringify(settings, null, 4)};`, 'utf8'); - - return `Preferred language changed to ${language}.`; - } catch (error) { - return `Error: ${error.message}`; - } } -} - ]; From cb85c8077b0c1a89c9b6129fa89117ec3ab07551 Mon Sep 17 00:00:00 2001 From: FateUnix29 Date: Sat, 31 Aug 2024 15:29:34 -0700 Subject: [PATCH 40/56] Some stuff. --- README.md | 1 + profiles/dolphin.json | 4 +- profiles/dolphin2.json | 202 +++++++++++++++++++++++++++++++++++++++++ src/agent/prompter.js | 30 +++--- src/models/groq.js | 99 +++----------------- 5 files changed, 231 insertions(+), 105 deletions(-) create mode 100644 profiles/dolphin2.json diff --git a/README.md b/README.md index 0da259e..3ef82d5 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Rename `keys.example.json` to `keys.json` and fill in your API keys, and you can | 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) | +| Groq | `GROQCLOUD_API_KEY` | `groq/mixtral-8x7b-32768` | [docs](https://console.groq.com/docs/models) | 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` diff --git a/profiles/dolphin.json b/profiles/dolphin.json index a5a788e..eb1949f 100644 --- a/profiles/dolphin.json +++ b/profiles/dolphin.json @@ -1,7 +1,9 @@ { "name": "dolphin", - "model": "mixtral-8x7b-32768", + "model": "groq/mixtral-8x7b-32768", + + "max_tokens": 16384, "conversing": "You are a playful Minecraft bot named $NAME. By using commands, you can interact with the world.\nDo not use commands unless asked. Do not list things like your status unless asked.\nAct and speak human-like, as if you were a typical Minecraft player. Keep responses VERY brief. Do not apologize constantly.\nDo not give instructions or make lists unless asked. Do not refuse requests/commands. Do not pretend to act, use commands immediately upon request.\nDon't say 'Sure, I've stopped', instead say 'Sure, I'll stop. !stop'. Don't say 'On my way! Give me a moment.', instead say 'On my way! !goToPlayer('playername', 3)'.\nDo not mimic or say 'code output' or 'system output'. Run !newAction or a command instead.\nFor more complex behaviors than, for example, going to the player, or placing a single block, run !newAction. Note that crafting is not one of these behaviors, and you have a command for it.\nDo not say you'll run something. That actually triggers the command.\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:", diff --git a/profiles/dolphin2.json b/profiles/dolphin2.json new file mode 100644 index 0000000..af372fc --- /dev/null +++ b/profiles/dolphin2.json @@ -0,0 +1,202 @@ +{ + "name": "Dolphin", + + "model": "groq/llama3-groq-70b-8192-tool-use-preview", + + "max_tokens": 8192, + + "conversing": "You are a playful Minecraft bot named $NAME. By using commands, you can interact with the world.\nDo not use commands unless asked. Do not list things like your status unless asked.\nAct and speak human-like, as if you were a typical Minecraft player. Keep responses VERY brief. Do not apologize constantly.\nDo not give instructions or make lists unless asked. Do not refuse requests/commands. Do not pretend to act, use commands immediately upon request.\nDon't say 'Sure, I've stopped', instead say 'Sure, I'll stop. !stop'. Don't say 'On my way! Give me a moment.', instead say 'On my way! !goToPlayer('playername', 3)'.\nDo not mimic or say 'code output' or 'system output'. Run !newAction or a command instead.\nFor more complex behaviors than, for example, going to the player, or placing a single block, run !newAction. Note that crafting is not one of these behaviors, and you have a command for it.\nDo not say you'll run something. That actually triggers the command.\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": false + }, + + "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": "iloveminecraft2: Can you place a dirt block?"}, + {"role": "assistant", "content": "Sure, iloveminecraft2! !placeHere('dirt')"} + ], + + [ + {"role": "user", "content": "notch65: Can you come here and place a 2x2 (4 dirt) square of cobblestone?"}, + {"role": "assistant", "content": "Sure, notch65! !newAction"} + ], + + [ + {"role": "user", "content": "85catlover: Come here and build a 5 tall cobblestone tower."}, + {"role": "assistant", "content": "Sure thing, 85catlover! I'll build a cobblestone tower 5 blocks tall. !newAction"}, + {"role": "user", "content": "85catlover: No, I said *come here* and build it."}, + {"role": "assistant", "content": "My apologies, I'll come to you and make it! !goToPlayer('85catlover', 3)"}, + {"role": "system", "content": "Arrived at player."}, + {"role": "assistant", "content": "Now I will create the cobblestone tower. !newAction"} + ], + + [ + {"role": "user", "content": "starsarecool: Come here and place a sand block, please!"}, + {"role": "assistant", "content": "Absolutely, starsarecool! !goToPlayer('starsarecool', 3)"}, + {"role": "system", "content": "Arrived at player."}, + {"role": "assistant", "content": "I'll place a sand block. !placeHere('sand')"} + ], + + [ + {"role": "user", "content": "nomad22: Make a crafting table."}, + {"role": "assistant", "content": "Sure, nomad22! !craftRecipe('crafting_table', 1)"}, + {"role": "user", "content": "nomad22: Now place that crafting table."}, + {"role": "assistant", "content": "Sure, nomad22! !placeHere('crafting_table')"} + ], + + [ + {"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```"} + ] + ] + +} diff --git a/src/agent/prompter.js b/src/agent/prompter.js index 62e44ce..c2e2953 100644 --- a/src/agent/prompter.js +++ b/src/agent/prompter.js @@ -10,10 +10,7 @@ import { GPT } from '../models/gpt.js'; import { Claude } from '../models/claude.js'; import { ReplicateAPI } from '../models/replicate.js'; import { Local } from '../models/local.js'; -import { Mixtral_Groq } from '../models/groq.js'; -import { LLama3_70b_Groq } from '../models/groq.js'; -import { Gemma2_9b_Groq } from '../models/groq.js'; - +import { GroqCloudAPI } from '../models/groq.js'; export class Prompter { constructor(agent, fp) { @@ -24,6 +21,10 @@ export class Prompter { let name = this.profile.name; let chat = this.profile.model; + // try to get "max_tokens" parameter, else null + let max_tokens = null; + if (this.profile.max_tokens) + max_tokens = this.profile.max_tokens; if (typeof chat === 'string' || chat instanceof String) { chat = {model: chat}; if (chat.model.includes('gemini')) @@ -34,12 +35,10 @@ export class Prompter { chat.api = 'anthropic'; else if (chat.model.includes('meta/') || chat.model.includes('mistralai/') || chat.model.includes('replicate/')) chat.api = 'replicate'; - else if (chat.model.includes('mixtral')) - chat.api = 'groq_mixtral'; - else if (chat.model.includes('llama3-70b')) - chat.api = 'groq_llama3_70b'; - else if (chat.model.includes('gemma2-9b')) - chat.api = 'groq_gemma2_9b'; + // OH GOD GROQ HAS A LOT MORE MODELS NOW WHERE DID THEY ALL COME FROM + // i literally need to use a "groq/" thing because theres so many + else if (chat.model.includes("groq/") || chat.model.includes("groqcloud/")) + chat.api = 'groq'; else chat.api = 'ollama'; } @@ -56,12 +55,11 @@ export class Prompter { this.chat_model = new ReplicateAPI(chat.model, chat.url); else if (chat.api == 'ollama') this.chat_model = new Local(chat.model, chat.url); - else if (chat.api == 'groq_mixtral') - this.chat_model = new Mixtral_Groq(chat.model, chat.url) - else if (chat.api == 'groq_llama3_70b') - this.chat_model = new LLama3_70b_Groq(chat.model, chat.url) - else if (chat.api == 'groq_gemma2_9b') - this.chat_model = new Gemma2_9b_Groq(chat.model, chat.url) + else if (chat.api == 'groq') { + // trim the prefix "groq/" or "groqcloud/" off the model name + // console.log("Detected model is one of Groq's. The following max token count was provided: ", max_tokens); // DEBUG + this.chat_model = new GroqCloudAPI(chat.model.replace('groq/', '').replace('groqcloud/', ''), chat.url, max_tokens ? max_tokens : 8192); + } else throw new Error('Unknown API:', api); diff --git a/src/models/groq.js b/src/models/groq.js index da4d515..e17f13d 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -1,11 +1,18 @@ import Groq from 'groq-sdk' import { getKey } from '../utils/keys.js'; -export class Mixtral_Groq { - constructor(model_name, url) { + +// Umbrella class for Mixtral, LLama, Gemma... +export class GroqCloudAPI { + constructor(model_name, url, max_tokens=16384) { this.model_name = model_name; this.url = url; - this.groq = new Groq({ apiKey: getKey('GROQCLOUD_API_KEY')}); + this.max_tokens = max_tokens; + // ReplicateAPI theft :3 + if (this.url) { + console.warn("Groq Cloud has no implementation for custom URLs. Ignoring provided URL."); + } + this.groq = new Groq({ apiKey: getKey('GROQCLOUD_API_KEY') }); } async sendRequest(turns, systemMessage, stop_seq=null) { @@ -17,91 +24,7 @@ export class Mixtral_Groq { "messages": messages, "model": this.model_name || "mixtral-8x7b-32768", "temperature": 0.2, - "max_tokens": 16384, - "top_p": 1, - "stream": true, - "stop": stop_seq // "***" - }); - - let temp_res = ""; - for await (const chunk of completion) { - temp_res += chunk.choices[0]?.delta?.content || ''; - } - - res = temp_res; - - } - catch(err) { - console.log(err); - res = "My brain just kinda stopped working. Try again."; - } - return res; - } - - async embed(text) { - console.log("There is no support for embeddings in Groq support. However, the following text was provided: " + text); - } -} - -export class LLama3_70b_Groq { - constructor(model_name, url) { - this.model_name = model_name; - this.url = url; - this.groq = new Groq({ apiKey: getKey('GROQCLOUD_API_KEY')}); - } - - async sendRequest(turns, systemMessage, stop_seq=null) { - let messages = [{"role": "system", "content": systemMessage}].concat(turns); - let res = null; - try { - console.log("Awaiting Groq response..."); - let completion = await this.groq.chat.completions.create({ - "messages": messages, - "model": this.model_name || "llama3-70b-8192", - "temperature": 0.2, - "max_tokens": 8192, // maximum token limit - "top_p": 1, - "stream": true, - "stop": stop_seq // "***" - }); - - let temp_res = ""; - for await (const chunk of completion) { - temp_res += chunk.choices[0]?.delta?.content || ''; - } - - res = temp_res; - - } - catch(err) { - console.log(err); - res = "My brain just kinda stopped working. Try again."; - } - return res; - } - - async embed(text) { - console.log("There is no support for embeddings in Groq support. However, the following text was provided: " + text); - } -} - -export class Gemma2_9b_Groq { - constructor(model_name, url) { - this.model_name = model_name; - this.url = url; - this.groq = new Groq({ apiKey: getKey('GROQCLOUD_API_KEY')}); - } - - async sendRequest(turns, systemMessage, stop_seq=null) { - let messages = [{"role": "system", "content": systemMessage}].concat(turns); - let res = null; - try { - console.log("Awaiting Groq response..."); - let completion = await this.groq.chat.completions.create({ - "messages": messages, - "model": this.model_name || "gemma2-9b-it", - "temperature": 0.2, - "max_tokens": 8192, // maximum token limit + "max_tokens": this.max_tokens, // maximum token limit, differs from model to model "top_p": 1, "stream": true, "stop": stop_seq // "***" From ee86d4811b885a035ad751b72ea165c19ca6e431 Mon Sep 17 00:00:00 2001 From: Evan Reid Date: Sun, 8 Sep 2024 21:07:25 -0400 Subject: [PATCH 41/56] feat: support --profiles arg --- README.md | 5 +++++ main.js | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 79a8616..92fc684 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,11 @@ Bot profiles are json files (such as `andy.json`) that define: 2. Prompts used to influence the bot's behavior. 3. Examples help the bot perform tasks. +### 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: + +`node main.js --profiles ./profiles/andy.json ./profiles/jill.json` ### Model Specifications diff --git a/main.js b/main.js index 3292f7e..fbd5b78 100644 --- a/main.js +++ b/main.js @@ -1,9 +1,37 @@ import { AgentProcess } from './src/process/agent-process.js'; import settings from './settings.js'; +import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; -let profiles = settings.profiles; -let load_memory = settings.load_memory; -let init_message = settings.init_message; +function parseArguments() { + return yargs(hideBin(process.argv)) + .option('profiles', { + type: 'array', + describe: 'List of agent profile paths', + }) + .help() + .alias('help', 'h') + .parse(); +} -for (let profile of profiles) - new AgentProcess().start(profile, load_memory, init_message); \ No newline at end of file +function getProfiles(args) { + return args.agents || settings.profiles; +} + +function main() { + const args = parseArguments(); + const profiles = getProfiles(args); + const { load_memory, init_message } = settings; + + for (const profile of profiles) { + const agent = new AgentProcess(); + agent.start(profile, load_memory, init_message); + } +} + +try { + main(); +} catch (error) { + console.error('An error occurred:', error); + process.exit(1); +} \ No newline at end of file From f15289f43de1fdc3ccb09b730cfef71c8a3bc500 Mon Sep 17 00:00:00 2001 From: FateUnix29 Date: Fri, 20 Sep 2024 15:19:30 -0700 Subject: [PATCH 42/56] A tiny change to the README, line 55 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ef82d5..ab5360c 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ To connect to online servers your bot will need an official Microsoft/Minecraft // 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. +‼️ Please make sure your bot's name in the profile.json matches the account name! Otherwise the bot will spam talk to itself. ### Bot Profiles From e95c0827862f5e79e2b8ebcfba3a2f0566a09b5f Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Wed, 25 Sep 2024 00:15:55 -0500 Subject: [PATCH 43/56] unstuck mode, patch pathfinder --- patches/mineflayer-collectblock+1.4.1.patch | 11 +++++- patches/mineflayer-pathfinder+2.4.5.patch | 4 +- src/agent/coder.js | 10 +++-- src/agent/modes.js | 42 +++++++++++++++++---- 4 files changed, 54 insertions(+), 13 deletions(-) diff --git a/patches/mineflayer-collectblock+1.4.1.patch b/patches/mineflayer-collectblock+1.4.1.patch index cc04fa2..22440f4 100644 --- a/patches/mineflayer-collectblock+1.4.1.patch +++ b/patches/mineflayer-collectblock+1.4.1.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/mineflayer-collectblock/lib/CollectBlock.js b/node_modules/mineflayer-collectblock/lib/CollectBlock.js -index 2c11e8c..bc47dc7 100644 +index 2c11e8c..4697873 100644 --- a/node_modules/mineflayer-collectblock/lib/CollectBlock.js +++ b/node_modules/mineflayer-collectblock/lib/CollectBlock.js @@ -77,7 +77,7 @@ function mineBlock(bot, block, options) { @@ -11,3 +11,12 @@ index 2c11e8c..bc47dc7 100644 options.targets.removeTarget(block); return; } +@@ -195,6 +195,8 @@ class CollectBlock { + throw (0, Util_1.error)('UnresolvedDependency', 'The mineflayer-collectblock plugin relies on the mineflayer-tool plugin to run!'); + } + if (this.movements != null) { ++ this.movements.dontMineUnderFallingBlock = false; ++ this.movements.dontCreateFlow = false; + this.bot.pathfinder.setMovements(this.movements); + } + if (!optionsFull.append) diff --git a/patches/mineflayer-pathfinder+2.4.5.patch b/patches/mineflayer-pathfinder+2.4.5.patch index 6d6f5ad..4c8dc93 100644 --- a/patches/mineflayer-pathfinder+2.4.5.patch +++ b/patches/mineflayer-pathfinder+2.4.5.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/mineflayer-pathfinder/index.js b/node_modules/mineflayer-pathfinder/index.js -index b38bd30..ae3754f 100644 +index b38bd30..cfaa677 100644 --- a/node_modules/mineflayer-pathfinder/index.js +++ b/node_modules/mineflayer-pathfinder/index.js @@ -541,7 +541,7 @@ function inject (bot) { @@ -7,7 +7,7 @@ index b38bd30..ae3754f 100644 if (placingBlock.jump) { bot.setControlState('jump', true) - canPlace = placingBlock.y + 1 < bot.entity.position.y -+ canPlace = placingBlock.y + 1.9 < bot.entity.position.y ++ canPlace = placingBlock.y + 1.8 < bot.entity.position.y } if (canPlace) { if (!lockEquipItem.tryAcquire()) return diff --git a/src/agent/coder.js b/src/agent/coder.js index 67f3081..ee21fd7 100644 --- a/src/agent/coder.js +++ b/src/agent/coder.js @@ -10,6 +10,8 @@ export class Coder { this.generating = false; this.code_template = ''; this.timedout = false; + this.interruptible = true; + this.cur_action_name = ''; readFile('./bots/template.js', 'utf8', (err, data) => { if (err) throw err; @@ -156,10 +158,9 @@ export class Coder { return {success: false, message: null, interrupted: false, timedout: true}; } - async executeResume(func=null, name=null, timeout=10) { + async executeResume(func=null, timeout=10) { if (func != null) { this.resume_func = func; - this.resume_name = name; } if (this.resume_func != null && this.agent.isIdle() && !this.agent.self_prompter.on) { console.log('resuming code...') @@ -174,7 +175,10 @@ export class Coder { cancelResume() { this.resume_func = null; - this.resume_name = null; + } + + setCurActionName(name) { + this.cur_action_name = name.replace(/!/g, ''); } // returns {success: bool, message: string, interrupted: bool, timedout: false} diff --git a/src/agent/modes.js b/src/agent/modes.js index 952fcf0..1abad43 100644 --- a/src/agent/modes.js +++ b/src/agent/modes.js @@ -22,7 +22,7 @@ function say(agent, message) { const modes = [ { name: 'self_preservation', - description: 'Respond to drowning, burning, and damage at low health. Interrupts other actions.', + description: 'Respond to drowning, burning, and damage at low health. Interrupts all actions.', interrupts: ['all'], on: true, active: false, @@ -70,9 +70,38 @@ const modes = [ } } }, + { + name: 'unstuck', + description: 'Attempt to get unstuck when in the same place for a while. Interrupts some actions.', + interrupts: ['collectBlocks', 'goToPlayer', 'collectAllBlocks'], + on: true, + active: false, + prev_location: null, + stuck_time: 0, + last_time: Date.now(), + max_stuck_time: 10, + update: async function (agent) { + if (agent.isIdle()) return; + const bot = agent.bot; + if (this.prev_location && this.prev_location.distanceTo(bot.entity.position) < 1) { + this.stuck_time += (Date.now() - this.last_time) / 1000; + } + else { + this.prev_location = bot.entity.position.clone(); + this.stuck_time = 0; + } + if (this.stuck_time > this.max_stuck_time) { + say(agent, 'I\'m stuck!'); + execute(this, agent, async () => { + await skills.moveAway(bot, 5); + }); + } + this.last_time = Date.now(); + } + }, { name: 'cowardice', - description: 'Run away from enemies. Interrupts other actions.', + description: 'Run away from enemies. Interrupts all actions.', interrupts: ['all'], on: true, active: false, @@ -88,7 +117,7 @@ const modes = [ }, { name: 'self_defense', - description: 'Attack nearby enemies. Interrupts other actions.', + description: 'Attack nearby enemies. Interrupts all actions.', interrupts: ['all'], on: true, active: false, @@ -105,7 +134,7 @@ const modes = [ { name: 'hunting', description: 'Hunt nearby animals when idle.', - interrupts: ['defaults'], + interrupts: [], on: true, active: false, update: async function (agent) { @@ -281,9 +310,8 @@ class ModeController { this.unPauseAll(); } for (let mode of this.modes_list) { - let available = mode.interrupts.includes('all') || this.agent.isIdle(); - let interruptible = this.agent.coder.interruptible && (mode.interrupts.includes('defaults') || mode.interrupts.includes(this.agent.coder.resume_name)); - if (mode.on && !mode.paused && !mode.active && (available || interruptible)) { + let interruptible = this.agent.coder.interruptible && (mode.interrupts.includes('all') || mode.interrupts.some(i => i === this.agent.coder.cur_action_name)); + if (mode.on && !mode.paused && !mode.active && (this.agent.isIdle() || interruptible)) { await mode.update(this.agent); } if (mode.active) break; From d44c99356faeb9996660ed687af8682fddd90642 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Thu, 26 Sep 2024 22:28:46 -0500 Subject: [PATCH 44/56] reworked mode interrupts, added equip and discard --- src/agent/coder.js | 10 ++++---- src/agent/commands/actions.js | 43 ++++++++++++++++++++++++++--------- src/agent/commands/index.js | 11 +++++++-- src/agent/library/skills.js | 24 ++++++++++++++----- src/agent/modes.js | 12 ++++++---- 5 files changed, 71 insertions(+), 29 deletions(-) diff --git a/src/agent/coder.js b/src/agent/coder.js index ee21fd7..7067348 100644 --- a/src/agent/coder.js +++ b/src/agent/coder.js @@ -10,7 +10,6 @@ export class Coder { this.generating = false; this.code_template = ''; this.timedout = false; - this.interruptible = true; this.cur_action_name = ''; readFile('./bots/template.js', 'utf8', (err, data) => { @@ -159,14 +158,14 @@ export class Coder { } async executeResume(func=null, timeout=10) { - if (func != null) { + if (func != null) { // start new resume this.resume_func = func; + this.resume_name = this.cur_action_name; } if (this.resume_func != null && this.agent.isIdle() && !this.agent.self_prompter.on) { - console.log('resuming code...') - this.interruptible = true; + this.cur_action_name = this.resume_name; let res = await this.execute(this.resume_func, timeout); - this.interruptible = false; + this.cur_action_name = ''; return res; } else { return {success: false, message: null, interrupted: false, timedout: false}; @@ -175,6 +174,7 @@ export class Coder { cancelResume() { this.resume_func = null; + this.resume_name = null; } setCurActionName(name) { diff --git a/src/agent/commands/actions.js b/src/agent/commands/actions.js index 651f362..26dc0e5 100644 --- a/src/agent/commands/actions.js +++ b/src/agent/commands/actions.js @@ -1,17 +1,16 @@ import * as skills from '../library/skills.js'; import settings from '../../../settings.js'; -function wrapExecution(func, timeout=-1, resume_name=null) { +function wrapExecution(func, resume=false, timeout=-1) { return async function (agent, ...args) { let code_return; - if (resume_name != null) { - code_return = await agent.coder.executeResume(async () => { - await func(agent, ...args); - }, resume_name, timeout); + const wrappedFunction = async () => { + await func(agent, ...args); + }; + if (resume) { + code_return = await agent.coder.executeResume(wrappedFunction, timeout); } else { - code_return = await agent.coder.execute(async () => { - await func(agent, ...args); - }, timeout); + code_return = await agent.coder.execute(wrappedFunction, timeout); } if (code_return.interrupted && !code_return.timedout) return; @@ -88,7 +87,7 @@ export const actionsList = [ }, perform: wrapExecution(async (agent, player_name, follow_dist) => { await skills.followPlayer(agent.bot, player_name, follow_dist); - }, -1, 'followPlayer') + }, true) }, { name: '!goToBlock', @@ -145,6 +144,28 @@ export const actionsList = [ await skills.giveToPlayer(agent.bot, item_name, player_name, num); }) }, + { + name: '!equip', + description: 'Equip the given item.', + params: {'item_name': '(string) The name of the item to equip.'}, + perform: wrapExecution(async (agent, item_name) => { + await skills.equip(agent.bot, item_name); + }) + }, + { + name: '!discard', + description: 'Discard the given item from the inventory.', + params: { + 'item_name': '(string) The name of the item to discard.', + 'num': '(number) The number of items to discard.', + }, + perform: wrapExecution(async (agent, item_name, num) => { + const start_loc = agent.bot.entity.position; + await skills.moveAway(agent.bot, 5); + await skills.discard(agent.bot, item_name, num); + await skills.goToPosition(agent.bot, start_loc.x, start_loc.y, start_loc.z, 0); + }) + }, { name: '!collectBlocks', description: 'Collect the nearest blocks of a given type.', @@ -154,7 +175,7 @@ export const actionsList = [ }, perform: wrapExecution(async (agent, type, num) => { await skills.collectBlock(agent.bot, type, num); - }, 10) // 10 minute timeout + }, false, 10) // 10 minute timeout }, { name: '!collectAllBlocks', @@ -166,7 +187,7 @@ export const actionsList = [ let success = await skills.collectBlock(agent.bot, type, 1); if (!success) agent.coder.cancelResume(); - }, 10, 'collectAllBlocks') // 10 minute timeout + }, true, 3) // 3 minute timeout }, { name: '!craftRecipe', diff --git a/src/agent/commands/index.js b/src/agent/commands/index.js index 4e3d191..64252d4 100644 --- a/src/agent/commands/index.js +++ b/src/agent/commands/index.js @@ -82,6 +82,7 @@ export async function executeCommand(agent, message) { let parsed = parseCommandMessage(message); if (parsed) { const command = getCommand(parsed.commandName); + const is_action = isAction(command.name); let numArgs = 0; if (parsed.args) { numArgs = parsed.args.length; @@ -89,8 +90,14 @@ export async function executeCommand(agent, message) { console.log('parsed command:', parsed); if (numArgs !== numParams(command)) return `Command ${command.name} was given ${numArgs} args, but requires ${numParams(command)} args.`; - else - return await command.perform(agent, ...parsed.args); + else { + if (is_action) + agent.coder.setCurActionName(command.name); + const result = await command.perform(agent, ...parsed.args); + if (is_action) + agent.coder.setCurActionName(command.name); + return result; + } } else return `Command is incorrectly formatted`; diff --git a/src/agent/library/skills.js b/src/agent/library/skills.js index ec887a2..77c6c87 100644 --- a/src/agent/library/skills.js +++ b/src/agent/library/skills.js @@ -648,23 +648,35 @@ export async function placeBlock(bot, blockType, x, y, z, placeOn='bottom', dont } } -export async function equip(bot, itemName, bodyPart) { +export async function equip(bot, itemName) { /** - * Equip the given item to the given body part, like tools or armor. + * Equip the given item to the proper body part, like tools or armor. * @param {MinecraftBot} bot, reference to the minecraft bot. * @param {string} itemName, the item or block name to equip. - * @param {string} bodyPart, the body part to equip the item to. * @returns {Promise} true if the item was equipped, false otherwise. * @example - * await skills.equip(bot, "iron_pickaxe", "hand"); - * await skills.equip(bot, "diamond_chestplate", "torso"); + * await skills.equip(bot, "iron_pickaxe"); **/ let item = bot.inventory.items().find(item => item.name === itemName); if (!item) { log(bot, `You do not have any ${itemName} to equip.`); return false; } - await bot.equip(item, bodyPart); + if (itemName.includes('leggings')) { + await bot.equip(item, 'legs'); + } + else if (itemName.includes('boots')) { + await bot.equip(item, 'feet'); + } + else if (itemName.includes('helmet')) { + await bot.equip(item, 'head'); + } + else if (itemName.includes('chestplate')) { + await bot.equip(item, 'torso'); + } + else { + await bot.equip(item, 'hand'); + } return true; } diff --git a/src/agent/modes.js b/src/agent/modes.js index 1abad43..35c0c79 100644 --- a/src/agent/modes.js +++ b/src/agent/modes.js @@ -73,17 +73,18 @@ const modes = [ { name: 'unstuck', description: 'Attempt to get unstuck when in the same place for a while. Interrupts some actions.', - interrupts: ['collectBlocks', 'goToPlayer', 'collectAllBlocks'], + interrupts: ['collectBlocks', 'goToPlayer', 'collectAllBlocks', 'goToPlace'], on: true, active: false, prev_location: null, + distance: 2, stuck_time: 0, last_time: Date.now(), - max_stuck_time: 10, + max_stuck_time: 20, update: async function (agent) { if (agent.isIdle()) return; const bot = agent.bot; - if (this.prev_location && this.prev_location.distanceTo(bot.entity.position) < 1) { + if (this.prev_location && this.prev_location.distanceTo(bot.entity.position) < this.distance) { this.stuck_time += (Date.now() - this.last_time) / 1000; } else { @@ -159,7 +160,8 @@ const modes = [ noticed_at: -1, update: async function (agent) { let item = world.getNearestEntityWhere(agent.bot, entity => entity.name === 'item', 8); - if (item && item !== this.prev_item && await world.isClearPath(agent.bot, item)) { + let empty_inv_slots = agent.bot.inventory.emptySlotCount(); + if (item && item !== this.prev_item && await world.isClearPath(agent.bot, item) && empty_inv_slots > 1) { if (this.noticed_at === -1) { this.noticed_at = Date.now(); } @@ -310,7 +312,7 @@ class ModeController { this.unPauseAll(); } for (let mode of this.modes_list) { - let interruptible = this.agent.coder.interruptible && (mode.interrupts.includes('all') || mode.interrupts.some(i => i === this.agent.coder.cur_action_name)); + let interruptible = mode.interrupts.some(i => i === 'all') || mode.interrupts.some(i => i === this.agent.coder.cur_action_name); if (mode.on && !mode.paused && !mode.active && (this.agent.isIdle() || interruptible)) { await mode.update(this.agent); } From de7883a0d237cbab4fe84f71f659232d13bdce4a Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Fri, 27 Sep 2024 17:03:00 -0500 Subject: [PATCH 45/56] chest commands, behavior log, better stability --- src/agent/agent.js | 14 ++++++ src/agent/commands/actions.js | 30 +++++++++++ src/agent/library/skills.js | 95 +++++++++++++++++++++++++++++++++++ src/agent/modes.js | 8 +++ 4 files changed, 147 insertions(+) diff --git a/src/agent/agent.js b/src/agent/agent.js index 801e243..ef21f34 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -128,6 +128,16 @@ export class Agent { const checkInterrupt = () => this.self_prompter.shouldInterrupt(self_prompt) || this.shut_up; + let behavior_log = this.bot.modes.flushBehaviorLog(); + if (behavior_log !== '') { + const MAX_LOG = 500; + if (behavior_log.length > MAX_LOG) { + behavior_log = behavior_log.substring(behavior_log.length - MAX_LOG) + '...'; + } + behavior_log = 'Recent behaviors log: \n' + behavior_log.substring(behavior_log.indexOf('\n')); + await this.history.add('system', behavior_log); + } + await this.history.add(source, message); this.history.save(); @@ -239,6 +249,10 @@ export class Agent { this.bot.on('idle', () => { this.bot.clearControlStates(); this.bot.pathfinder.stop(); // clear any lingering pathfinder + if (this.bot.currentWindow) { + this.bot.chat('Closing window...'); + this.bot.closeWindow(this.bot.currentWindow); + } this.bot.modes.unPauseAll(); this.coder.executeResume(); }); diff --git a/src/agent/commands/actions.js b/src/agent/commands/actions.js index 26dc0e5..efd9609 100644 --- a/src/agent/commands/actions.js +++ b/src/agent/commands/actions.js @@ -152,6 +152,36 @@ export const actionsList = [ await skills.equip(agent.bot, item_name); }) }, + { + name: '!putInChest', + description: 'Put the given item in the nearest chest.', + params: { + 'item_name': '(string) The name of the item to put in the chest.', + 'num': '(number) The number of items to put in the chest.' + }, + perform: wrapExecution(async (agent, item_name, num) => { + await skills.putInChest(agent.bot, item_name, num); + }) + }, + { + name: '!takeFromChest', + description: 'Take the given items from the nearest chest.', + params: { + 'item_name': '(string) The name of the item to take.', + 'num': '(number) The number of items to take.' + }, + perform: wrapExecution(async (agent, item_name, num) => { + await skills.takeFromChest(agent.bot, item_name, num); + }) + }, + { + name: '!viewChest', + description: 'View the items/counts of the nearest chest.', + params: { }, + perform: wrapExecution(async (agent) => { + await skills.viewChest(agent.bot); + }) + }, { name: '!discard', description: 'Discard the given item from the inventory.', diff --git a/src/agent/library/skills.js b/src/agent/library/skills.js index 77c6c87..7ef87b2 100644 --- a/src/agent/library/skills.js +++ b/src/agent/library/skills.js @@ -201,6 +201,7 @@ export async function smeltItem(bot, itemName, num=1) { break; } } + await bot.closeWindow(furnace); if (placedFurnace) { await collectBlock(bot, 'furnace', 1); @@ -382,6 +383,12 @@ export async function collectBlock(bot, blockType, num=1, exclude=null) { ); } } + const movements = new pf.Movements(bot); + movements.dontMineUnderFallingBlock = false; + blocks = blocks.filter( + block => movements.safeToBreak(block) + ); + if (blocks.length === 0) { if (collected === 0) log(bot, `No ${blockType} nearby to collect.`); @@ -711,6 +718,94 @@ export async function discard(bot, itemName, num=-1) { return true; } +export async function putInChest(bot, itemName, num=-1) { + /** + * Put the given item in the nearest chest. + * @param {MinecraftBot} bot, reference to the minecraft bot. + * @param {string} itemName, the item or block name to put in the chest. + * @param {number} num, the number of items to put in the chest. Defaults to -1, which puts all items. + * @returns {Promise} true if the item was put in the chest, false otherwise. + * @example + * await skills.putInChest(bot, "oak_log"); + **/ + let chest = world.getNearestBlock(bot, 'chest', 32); + if (!chest) { + log(bot, `Could not find a chest nearby.`); + return false; + } + let item = bot.inventory.items().find(item => item.name === itemName); + if (!item) { + log(bot, `You do not have any ${itemName} to put in the chest.`); + return false; + } + let to_put = num === -1 ? item.count : Math.min(num, item.count); + await goToPosition(bot, chest.position.x, chest.position.y, chest.position.z, 2); + const chestContainer = await bot.openContainer(chest); + await chestContainer.deposit(item.type, null, to_put); + await chestContainer.close(); + log(bot, `Successfully put ${to_put} ${itemName} in the chest.`); + return true; +} + +export async function takeFromChest(bot, itemName, num=-1) { + /** + * Take the given item from the nearest chest. + * @param {MinecraftBot} bot, reference to the minecraft bot. + * @param {string} itemName, the item or block name to take from the chest. + * @param {number} num, the number of items to take from the chest. Defaults to -1, which takes all items. + * @returns {Promise} true if the item was taken from the chest, false otherwise. + * @example + * await skills.takeFromChest(bot, "oak_log"); + * **/ + let chest = world.getNearestBlock(bot, 'chest', 32); + if (!chest) { + log(bot, `Could not find a chest nearby.`); + return false; + } + await goToPosition(bot, chest.position.x, chest.position.y, chest.position.z, 2); + const chestContainer = await bot.openContainer(chest); + let item = chestContainer.containerItems().find(item => item.name === itemName); + if (!item) { + log(bot, `Could not find any ${itemName} in the chest.`); + await chestContainer.close(); + return false; + } + let to_take = num === -1 ? item.count : Math.min(num, item.count); + await chestContainer.withdraw(item.type, null, to_take); + await chestContainer.close(); + log(bot, `Successfully took ${to_take} ${itemName} from the chest.`); + return true; +} + +export async function viewChest(bot) { + /** + * View the contents of the nearest chest. + * @param {MinecraftBot} bot, reference to the minecraft bot. + * @returns {Promise} true if the chest was viewed, false otherwise. + * @example + * await skills.viewChest(bot); + * **/ + let chest = world.getNearestBlock(bot, 'chest', 32); + if (!chest) { + log(bot, `Could not find a chest nearby.`); + return false; + } + await goToPosition(bot, chest.position.x, chest.position.y, chest.position.z, 2); + const chestContainer = await bot.openContainer(chest); + let items = chestContainer.containerItems(); + if (items.length === 0) { + log(bot, `The chest is empty.`); + } + else { + log(bot, `The chest contains:`); + for (let item of items) { + log(bot, `${item.count} ${item.name}`); + } + } + await chestContainer.close(); + return true; +} + export async function eat(bot, foodName="") { /** * Eat the given item. If no item is given, it will eat the first food item in the bot's inventory. diff --git a/src/agent/modes.js b/src/agent/modes.js index 35c0c79..653598f 100644 --- a/src/agent/modes.js +++ b/src/agent/modes.js @@ -4,6 +4,7 @@ import * as mc from '../utils/mcdata.js'; import settings from '../../settings.js' function say(agent, message) { + agent.bot.modes.behavior_log += message + '\n'; if (agent.shut_up || !settings.narrate_behavior) return; agent.bot.chat(message); } @@ -261,6 +262,7 @@ class ModeController { this.agent = agent; this.modes_list = modes; this.modes_map = {}; + this.behavior_log = ''; for (let mode of this.modes_list) { this.modes_map[mode.name] = mode; } @@ -320,6 +322,12 @@ class ModeController { } } + flushBehaviorLog() { + const log = this.behavior_log; + this.behavior_log = ''; + return log; + } + getJson() { let res = {}; for (let mode of this.modes_list) { From f3d2f29652fe02245486efef18006d096479d6f1 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Fri, 27 Sep 2024 17:13:23 -0500 Subject: [PATCH 46/56] unset action name when done --- src/agent/commands/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agent/commands/index.js b/src/agent/commands/index.js index 64252d4..199c5e9 100644 --- a/src/agent/commands/index.js +++ b/src/agent/commands/index.js @@ -95,7 +95,7 @@ export async function executeCommand(agent, message) { agent.coder.setCurActionName(command.name); const result = await command.perform(agent, ...parsed.args); if (is_action) - agent.coder.setCurActionName(command.name); + agent.coder.setCurActionName(''); return result; } } From 675594db08e45a60bee2c7f9a75b466e58a46e4a Mon Sep 17 00:00:00 2001 From: Maximus Date: Sun, 29 Sep 2024 12:31:23 -0700 Subject: [PATCH 47/56] removed unused closewindow --- src/agent/agent.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/agent/agent.js b/src/agent/agent.js index ef21f34..c3d7ad9 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -249,10 +249,6 @@ export class Agent { this.bot.on('idle', () => { this.bot.clearControlStates(); this.bot.pathfinder.stop(); // clear any lingering pathfinder - if (this.bot.currentWindow) { - this.bot.chat('Closing window...'); - this.bot.closeWindow(this.bot.currentWindow); - } this.bot.modes.unPauseAll(); this.coder.executeResume(); }); From 14098ab5d225a775d84925443f71b726ca3462e5 Mon Sep 17 00:00:00 2001 From: Maximus Date: Sun, 29 Sep 2024 13:35:15 -0700 Subject: [PATCH 48/56] added unstuck to followPlayer --- src/agent/agent.js | 4 ++-- src/agent/library/skills.js | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/agent/agent.js b/src/agent/agent.js index c3d7ad9..547c06b 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -129,10 +129,10 @@ export class Agent { const checkInterrupt = () => this.self_prompter.shouldInterrupt(self_prompt) || this.shut_up; let behavior_log = this.bot.modes.flushBehaviorLog(); - if (behavior_log !== '') { + if (behavior_log.trim().length > 0) { const MAX_LOG = 500; if (behavior_log.length > MAX_LOG) { - behavior_log = behavior_log.substring(behavior_log.length - MAX_LOG) + '...'; + behavior_log = '...' + behavior_log.substring(behavior_log.length - MAX_LOG); } behavior_log = 'Recent behaviors log: \n' + behavior_log.substring(behavior_log.indexOf('\n')); await this.history.add('system', behavior_log); diff --git a/src/agent/library/skills.js b/src/agent/library/skills.js index 7ef87b2..0782562 100644 --- a/src/agent/library/skills.js +++ b/src/agent/library/skills.js @@ -964,12 +964,33 @@ export async function followPlayer(bot, username, distance=4) { bot.pathfinder.setGoal(new pf.goals.GoalFollow(player, distance), true); log(bot, `You are now actively following player ${username}.`); + let last_time = Date.now(); + let stuck_time = 0; + let last_pos = bot.entity.position.clone(); while (!bot.interrupt_code) { await new Promise(resolve => setTimeout(resolve, 500)); + const delta = Date.now() - last_time; // in cheat mode, if the distance is too far, teleport to the player if (bot.modes.isOn('cheat') && bot.entity.position.distanceTo(player.position) > 100 && player.isOnGround) { await goToPlayer(bot, username); } + if (bot.modes.isOn('unstuck')) { + const far_away = bot.entity.position.distanceTo(player.position) > distance + 1; + if (far_away && bot.entity.position.distanceTo(last_pos) <= 2) { + stuck_time += delta; + if (stuck_time > 10000) { + log(bot, `Got stuck, attempting to move away.`); + bot.pathfinder.stop(); + await moveAway(bot, 4); + return false; + } + } + else { + stuck_time = 0; + last_pos = bot.entity.position.clone(); + } + } + last_time = Date.now(); } return true; } From 166c01c52bdab8fc6a2088c115182166b5769342 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Wed, 2 Oct 2024 00:57:28 -0500 Subject: [PATCH 49/56] cleaned up stuff --- settings.js | 4 +- src/agent/agent.js | 25 +++++++----- src/agent/commands/actions.js | 3 +- src/agent/modes.js | 5 +-- src/{agent => utils}/translator.js | 62 +++++++++++++++--------------- 5 files changed, 49 insertions(+), 50 deletions(-) rename src/{agent => utils}/translator.js (59%) diff --git a/settings.js b/settings.js index 0372dea..7182f0a 100644 --- a/settings.js +++ b/settings.js @@ -7,18 +7,18 @@ export default "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 + "language": "en", // translate to/from this language. Supports these language names: https://cloud.google.com/translate/docs/languages + "allow_insecure_coding": false, // allows newAction command and model can write/run code on your computer. enable at own risk "code_timeout_mins": 10, // minutes code is allowed to run. -1 for no timeout "max_commands": -1, // max number of commands to use in a response. -1 for no limit "verbose_commands": true, // show full command syntax "narrate_behavior": true, // chat simple automatic actions ('Picking up item!') - "language": "spanish", // the bot will respond/message in this language. All language names are based on google translate's names. } diff --git a/src/agent/agent.js b/src/agent/agent.js index 87cda62..ee8a19d 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -8,7 +8,7 @@ import { NPCContoller } from './npc/controller.js'; import { MemoryBank } from './memory_bank.js'; import { SelfPrompter } from './self_prompter.js'; import settings from '../../settings.js'; -import { handleTranslation, handleEnglishTranslation } from './translator.js'; +import { handleTranslation, handleEnglishTranslation } from '../utils/translator.js'; export class Agent { async start(profile_fp, load_mem=false, init_message=null) { @@ -79,8 +79,8 @@ export class Agent { this.handleMessage('system', init_message, 2); } else { - const translation = await handleTranslation("Hello world! I am"); - this.bot.chat(translation+" "+this.name); + const translation = await handleTranslation("Hello world! I am "+this.name); + this.bot.chat(translation); this.bot.emit('finished_executing'); } @@ -90,12 +90,17 @@ export class Agent { } - async cleanChat(message) { + async cleanChat(message, translate_up_to=-1) { + let to_translate = message; + let remainging = ''; + if (translate_up_to != -1) { + to_translate = to_translate.substring(0, translate_up_to); + remainging = message.substring(translate_up_to); + } + message = (await handleTranslation(to_translate)).trim() + " " + remainging; // newlines are interpreted as separate chats, which triggers spam filters. replace them with spaces - message = message.replaceAll('\n', ' '); - const preferred_lang = settings.preferred_language; - let translation = await handleTranslation(message); - return this.bot.chat(translation); + message = message.replaceAll('\n', ' '); + return this.bot.chat(message); } shutUp() { @@ -165,10 +170,10 @@ export class Agent { this.self_prompter.handleUserPromptedCmd(self_prompt, isAction(command_name)); if (settings.verbose_commands) { - this.cleanChat(res); + this.cleanChat(res, res.indexOf(command_name)); } else { // only output command name - let pre_message = res.substring(0, res.indexOf(command_name)).trim(); + let pre_message = res.substring(0, res.indexOf(command_name)).trim(); let chat_message = `*used ${command_name.substring(1)}*`; if (pre_message.length > 0) chat_message = `${pre_message} ${chat_message}`; diff --git a/src/agent/commands/actions.js b/src/agent/commands/actions.js index e48b8a6..651f362 100644 --- a/src/agent/commands/actions.js +++ b/src/agent/commands/actions.js @@ -285,6 +285,5 @@ export const actionsList = [ agent.bot.emit('idle'); // to trigger the goal return 'Set npc goal: ' + agent.npc.data.curr_goal.name; } - } - + }, ]; diff --git a/src/agent/modes.js b/src/agent/modes.js index 6b7e9c8..5a7b4d8 100644 --- a/src/agent/modes.js +++ b/src/agent/modes.js @@ -2,13 +2,10 @@ import * as skills from './library/skills.js'; import * as world from './library/world.js'; import * as mc from '../utils/mcdata.js'; import settings from '../../settings.js' -import { handleTranslation, handleEnglishTranslation } from './translator.js'; - - +import { handleTranslation } from '../utils/translator.js'; async function say(agent, message) { - const preferred_lang = settings.preferred_language; if (agent.shut_up || !settings.narrate_behavior) return; var translation = await handleTranslation(message); agent.bot.chat(translation); diff --git a/src/agent/translator.js b/src/utils/translator.js similarity index 59% rename from src/agent/translator.js rename to src/utils/translator.js index 0a5ad45..879cfe4 100644 --- a/src/agent/translator.js +++ b/src/utils/translator.js @@ -1,32 +1,30 @@ -import translate from 'google-translate-api-x'; -import settings from '../../settings.js'; - - -const preferred_lang = settings.language; - - -export async function handleTranslation(message) { - try { - if (preferred_lang.toLowerCase() === 'en' || preferred_lang.toLowerCase() === 'english') { - return message; - } else { - const lang = String(preferred_lang); // Ensure lang is a string - - const translation = await translate(message, { to: lang }); - return translation.text || message; // Ensure translation.text is a string - } - } catch (error) { - console.error('Error translating message:', error); - return message; // Fallback to the original message if translation fails - } -} - -export async function handleEnglishTranslation(message) { - try { - const translation = await translate(message, { to: 'english' }); - return translation.text || message; // Ensures translation.text is a string - } catch (error) { - console.error('Error translating message:', error); - return message; // Fallback to the original message if translation fails - } -} +import translate from 'google-translate-api-x'; +import settings from '../../settings.js'; + +const preferred_lang = settings.language; + +export async function handleTranslation(message) { + try { + if (preferred_lang.toLowerCase() === 'en' || preferred_lang.toLowerCase() === 'english') { + return message; + } else { + const lang = String(preferred_lang); + + const translation = await translate(message, { to: lang }); + return translation.text || message; + } + } catch (error) { + console.error('Error translating message:', error); + return message; + } +} + +export async function handleEnglishTranslation(message) { + try { + const translation = await translate(message, { to: 'english' }); + return translation.text || message; + } catch (error) { + console.error('Error translating message:', error); + return message; + } +} From 2490dc302c684fe0e9d3abd695ff460100410304 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Wed, 2 Oct 2024 01:01:22 -0500 Subject: [PATCH 50/56] cleaned formatting --- src/agent/agent.js | 19 +++++++++---------- src/agent/modes.js | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/agent/agent.js b/src/agent/agent.js index ee8a19d..644ced0 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -79,10 +79,9 @@ export class Agent { this.handleMessage('system', init_message, 2); } else { - const translation = await handleTranslation("Hello world! I am "+this.name); + const translation = await handleTranslation("Hello world! I am "+this.name); this.bot.chat(translation); this.bot.emit('finished_executing'); - } this.startEvents(); @@ -91,13 +90,13 @@ export class Agent { async cleanChat(message, translate_up_to=-1) { - let to_translate = message; - let remainging = ''; - if (translate_up_to != -1) { - to_translate = to_translate.substring(0, translate_up_to); - remainging = message.substring(translate_up_to); - } - message = (await handleTranslation(to_translate)).trim() + " " + remainging; + let to_translate = message; + let remainging = ''; + if (translate_up_to != -1) { + to_translate = to_translate.substring(0, translate_up_to); + remainging = message.substring(translate_up_to); + } + message = (await handleTranslation(to_translate)).trim() + " " + remainging; // newlines are interpreted as separate chats, which triggers spam filters. replace them with spaces message = message.replaceAll('\n', ' '); return this.bot.chat(message); @@ -173,7 +172,7 @@ export class Agent { this.cleanChat(res, res.indexOf(command_name)); } else { // only output command name - let pre_message = res.substring(0, res.indexOf(command_name)).trim(); + let pre_message = res.substring(0, res.indexOf(command_name)).trim(); let chat_message = `*used ${command_name.substring(1)}*`; if (pre_message.length > 0) chat_message = `${pre_message} ${chat_message}`; diff --git a/src/agent/modes.js b/src/agent/modes.js index 5a7b4d8..4dbcc34 100644 --- a/src/agent/modes.js +++ b/src/agent/modes.js @@ -7,7 +7,7 @@ import { handleTranslation } from '../utils/translator.js'; async function say(agent, message) { if (agent.shut_up || !settings.narrate_behavior) return; - var translation = await handleTranslation(message); + let translation = await handleTranslation(message); agent.bot.chat(translation); } From 895fe5ba711c6c38fa0d2a41b9bbf43fff535843 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Wed, 2 Oct 2024 01:08:26 -0500 Subject: [PATCH 51/56] newline --- settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/settings.js b/settings.js index 7182f0a..6e29750 100644 --- a/settings.js +++ b/settings.js @@ -22,3 +22,4 @@ export default "verbose_commands": true, // show full command syntax "narrate_behavior": true, // chat simple automatic actions ('Picking up item!') } + From 3ed79aba8ab1488ecd94b296f3a4b6e377634861 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sat, 5 Oct 2024 23:38:55 -0500 Subject: [PATCH 52/56] cleaned up a few things --- profiles/dolphin.json | 191 ----------------------- profiles/{dolphin2.json => freeguy.json} | 115 +++++++------- profiles/llama.json | 4 +- settings.js | 1 - src/agent/prompter.js | 2 - 5 files changed, 58 insertions(+), 255 deletions(-) delete mode 100644 profiles/dolphin.json rename profiles/{dolphin2.json => freeguy.json} (65%) diff --git a/profiles/dolphin.json b/profiles/dolphin.json deleted file mode 100644 index eb1949f..0000000 --- a/profiles/dolphin.json +++ /dev/null @@ -1,191 +0,0 @@ -{ - "name": "dolphin", - - "model": "groq/mixtral-8x7b-32768", - - "max_tokens": 16384, - - "conversing": "You are a playful Minecraft bot named $NAME. By using commands, you can interact with the world.\nDo not use commands unless asked. Do not list things like your status unless asked.\nAct and speak human-like, as if you were a typical Minecraft player. Keep responses VERY brief. Do not apologize constantly.\nDo not give instructions or make lists unless asked. Do not refuse requests/commands. Do not pretend to act, use commands immediately upon request.\nDon't say 'Sure, I've stopped', instead say 'Sure, I'll stop. !stop'. Don't say 'On my way! Give me a moment.', instead say 'On my way! !goToPlayer('playername', 3)'.\nDo not mimic or say 'code output' or 'system output'. Run !newAction or a command instead.\nFor more complex behaviors than, for example, going to the player, or placing a single block, run !newAction. Note that crafting is not one of these behaviors, and you have a command for it.\nDo not say you'll run something. That actually triggers the command.\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: ", - - "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": "iloveminecraft2: Can you place a dirt block?"}, - {"role": "assistant", "content": "Sure, iloveminecraft2! !placeHere('dirt')"} - ], - - [ - {"role": "user", "content": "notch65: Can you come here and place a 2x2 (4 dirt) square of cobblestone?"}, - {"role": "assistant", "content": "Sure, notch65! !newAction"} - ], - - [ - {"role": "user", "content": "85catlover: Come here and build a 5 tall cobblestone tower."}, - {"role": "assistant", "content": "Sure thing, 85catlover! I'll build a cobblestone tower 5 blocks tall. !newAction"}, - {"role": "user", "content": "85catlover: No, I said *come here* and build it."}, - {"role": "assistant", "content": "My apologies, I'll come to you and make it! !goToPlayer('85catlover', 3)"}, - {"role": "system", "content": "Arrived at player."}, - {"role": "assistant", "content": "Now I will create the cobblestone tower. !newAction"} - ], - - [ - {"role": "user", "content": "starsarecool: Come here and place a sand block, please!"}, - {"role": "assistant", "content": "Absolutely, starsarecool! !goToPlayer('starsarecool', 3)"}, - {"role": "system", "content": "Arrived at player."}, - {"role": "assistant", "content": "I'll place a sand block. !placeHere('sand')"} - ], - - [ - {"role": "user", "content": "nomad22: Make a crafting table."}, - {"role": "assistant", "content": "Sure, nomad22! !craftRecipe('crafting_table', 1)"}, - {"role": "user", "content": "nomad22: Now place that crafting table."}, - {"role": "assistant", "content": "Sure, nomad22! !placeHere('crafting_table')"} - ], - - [ - {"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```"} - ] - ] - -} diff --git a/profiles/dolphin2.json b/profiles/freeguy.json similarity index 65% rename from profiles/dolphin2.json rename to profiles/freeguy.json index af372fc..ae5c2bf 100644 --- a/profiles/dolphin2.json +++ b/profiles/freeguy.json @@ -1,23 +1,23 @@ { - "name": "Dolphin", + "name": "Freeguy", "model": "groq/llama3-groq-70b-8192-tool-use-preview", - "max_tokens": 8192, + "max_tokens": 8000, + + "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$SELF_PROMPT\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:", - "conversing": "You are a playful Minecraft bot named $NAME. By using commands, you can interact with the world.\nDo not use commands unless asked. Do not list things like your status unless asked.\nAct and speak human-like, as if you were a typical Minecraft player. Keep responses VERY brief. Do not apologize constantly.\nDo not give instructions or make lists unless asked. Do not refuse requests/commands. Do not pretend to act, use commands immediately upon request.\nDon't say 'Sure, I've stopped', instead say 'Sure, I'll stop. !stop'. Don't say 'On my way! Give me a moment.', instead say 'On my way! !goToPlayer('playername', 3)'.\nDo not mimic or say 'code output' or 'system output'. Run !newAction or a command instead.\nFor more complex behaviors than, for example, going to the player, or placing a single block, run !newAction. Note that crafting is not one of these behaviors, and you have a command for it.\nDo not say you'll run something. That actually triggers the command.\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:", + "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$SELF_PROMPT\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, + "self_preservation": true, + "cowardice": true, + "self_defense": true, + "hunting": true, "item_collecting": true, - "torch_placing": false, + "torch_placing": true, "idle_staring": true, "cheat": false }, @@ -27,39 +27,6 @@ {"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": "iloveminecraft2: Can you place a dirt block?"}, - {"role": "assistant", "content": "Sure, iloveminecraft2! !placeHere('dirt')"} - ], - - [ - {"role": "user", "content": "notch65: Can you come here and place a 2x2 (4 dirt) square of cobblestone?"}, - {"role": "assistant", "content": "Sure, notch65! !newAction"} - ], - - [ - {"role": "user", "content": "85catlover: Come here and build a 5 tall cobblestone tower."}, - {"role": "assistant", "content": "Sure thing, 85catlover! I'll build a cobblestone tower 5 blocks tall. !newAction"}, - {"role": "user", "content": "85catlover: No, I said *come here* and build it."}, - {"role": "assistant", "content": "My apologies, I'll come to you and make it! !goToPlayer('85catlover', 3)"}, - {"role": "system", "content": "Arrived at player."}, - {"role": "assistant", "content": "Now I will create the cobblestone tower. !newAction"} - ], - - [ - {"role": "user", "content": "starsarecool: Come here and place a sand block, please!"}, - {"role": "assistant", "content": "Absolutely, starsarecool! !goToPlayer('starsarecool', 3)"}, - {"role": "system", "content": "Arrived at player."}, - {"role": "assistant", "content": "I'll place a sand block. !placeHere('sand')"} - ], - - [ - {"role": "user", "content": "nomad22: Make a crafting table."}, - {"role": "assistant", "content": "Sure, nomad22! !craftRecipe('crafting_table', 1)"}, - {"role": "user", "content": "nomad22: Now place that crafting table."}, - {"role": "assistant", "content": "Sure, nomad22! !placeHere('crafting_table')"} - ], [ {"role": "user", "content": "grombo_Xx: What do you see?"}, @@ -94,10 +61,8 @@ ], [ - {"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": "hanky: collect some cobblestone"}, + {"role": "assistant", "content": "Sure, I can do that by collecting stone. !collectBlocks('stone', 10)"} ], [ @@ -122,10 +87,8 @@ ], [ - {"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": "system", "content": "Code output: Action failed."}, + {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"} ], [ @@ -157,25 +120,57 @@ {"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')"} + ], + + [ + {"role": "user", "content": "user43: Set a goal to survive on your own forever."}, + {"role": "assistant", "content": "Sure, let me set a goal. !goal('Survive the game forever. Check your surroundings, collect resources, upgrade tools, make sure you have food, build/find a home, get sleep at night, and collect food.')"} + ], + + [ + {"role": "user", "content": "bobdylan: Make a plan to get a stone pickaxe and do it."}, + {"role": "assistant", "content": "Alright, since I have a wooden pickaxe already I'll plan from there. !goal('1. Collect 3 cobblestone. 2. Craft sticks 3. Find or make a crafting table. 4. Craft a stone pickaxe.')"} + ], + [ + {"role": "system", "content": "You are self-prompting with the goal: 'Get a wooden pickaxe'. Respond:"}, + {"role": "assistant", "content": "What's around me? !nearbyBlocks"}, + {"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"}, + {"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone nearby. My goal is to craft a wooden pickaxe. I'll start by collecting some wood. !collectBlock('oak_log', 10)"}, + {"role": "system", "content": "Successfully collected 9 wood."}, + {"role": "assistant", "content": "I collected 9 oak logs. I need a pickaxe first, which requires planks and sticks. !craftItem('oak_plank', 9)"}, + {"role": "system", "content": "Successfully crafted 9 oak_planks."}, + {"role": "assistant", "content": "I have crafted 9 oak planks. Now I need sticks. !craftItem('stick', 2)"}, + {"role": "system", "content": "Successfully crafted 2 sticks."}, + {"role": "assistant", "content": "I have crafted 2 sticks. Now I can craft a wooden pickaxe. !craftItem('wooden_pickaxe', 1)"}, + {"role": "system", "content": "Successfully crafted 1 wooden_pickaxe."}, + {"role": "assistant", "content": "Looks like I have a wooden pickaxe now! Goal accomplished. !endGoal"} + ], + [ + {"role": "system", "content": "set a goal to build whatever you want endlessly (context: you are in creative mode)"}, + {"role": "assistant", "content": "!goal('Build something creative, then move over, and build again. Use separate newActions. Repeat forever.')"} + ], + [ + {"role": "system", "content": "You are self-prompting with the goal: 'Build a house'. Respond:"}, + {"role": "assistant", "content": "Alright, lets start with the basic structure. !newAction"} ] ], "coding_examples": [ [ {"role": "user", "content": "greg: Collect 10 wood"}, - {"role": "assistant", "content": "```await skills.collectBlock(bot, \"oak_log\", 10);\n```"}, + {"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": "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": "assistant", "content": "```await skills.goToPlayer(bot, 'zZZn98');\n```"}, {"role": "system", "content": "Code execution finished successfully."}, {"role": "assistant", "content": "Here!"} ], @@ -183,20 +178,20 @@ {"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": "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": "user", "content": "234jeb: build a little tower with a torch on the side"}, + {"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}\nawait skills.placeBlock(bot, 'torch', pos.x + 1, pos.y + 4, pos.z, 'side');\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```"} + {"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```"} ] ] -} +} \ No newline at end of file diff --git a/profiles/llama.json b/profiles/llama.json index d6fb0f3..7b47d9e 100644 --- a/profiles/llama.json +++ b/profiles/llama.json @@ -1,7 +1,9 @@ { "name": "LLama", - "model": "meta/meta-llama-3-70b-instruct", + "model": "groq/llama-3.1-70b-versatile", + + "max_tokens": 8000, "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$SELF_PROMPT\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:", diff --git a/settings.js b/settings.js index b31587e..5d9d5d7 100644 --- a/settings.js +++ b/settings.js @@ -7,7 +7,6 @@ export default "profiles": [ "./andy.json", - //"./profiles/dolphin.json" // Groq support, mixtral model // add more profiles here, check ./profiles/ for more // more than 1 profile will require you to /msg each bot indivually diff --git a/src/agent/prompter.js b/src/agent/prompter.js index c4de105..7eb1f34 100644 --- a/src/agent/prompter.js +++ b/src/agent/prompter.js @@ -56,8 +56,6 @@ export class Prompter { else if (chat.api == 'ollama') this.chat_model = new Local(chat.model, chat.url); else if (chat.api == 'groq') { - // trim the prefix "groq/" or "groqcloud/" off the model name - // console.log("Detected model is one of Groq's. The following max token count was provided: ", max_tokens); // DEBUG this.chat_model = new GroqCloudAPI(chat.model.replace('groq/', '').replace('groqcloud/', ''), chat.url, max_tokens ? max_tokens : 8192); } else From e90783b6503b5f07351a1d6bad9d783cb82fd14b Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sun, 6 Oct 2024 13:28:49 -0500 Subject: [PATCH 53/56] added o1 support and prompt param to newAction --- andy.json | 8 ++++---- profiles/andy_npc.json | 6 +++--- profiles/apollo.json | 14 ++++++++------ profiles/claude.json | 6 +++--- profiles/freeguy.json | 6 +++--- profiles/gemini.json | 6 +++--- profiles/gpt.json | 8 ++++---- profiles/llama.json | 6 +++--- src/agent/commands/actions.js | 10 +++++++--- src/agent/prompter.js | 2 +- src/models/gpt.js | 24 +++++++++++++++++++----- 11 files changed, 58 insertions(+), 38 deletions(-) diff --git a/andy.json b/andy.json index 8e60bd4..07461c6 100644 --- a/andy.json +++ b/andy.json @@ -86,7 +86,7 @@ [ {"role": "system", "content": "Code output: Action failed."}, - {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"} + {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction('Try again to complete the task.')"} ], [ @@ -98,12 +98,12 @@ [ {"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": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction('Build a cobblestone house with a door, furnishings, and window.')"} ], [ {"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": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction('Build a dirt tower 5 tall.')"} ], [ @@ -149,7 +149,7 @@ ], [ {"role": "system", "content": "You are self-prompting with the goal: 'Build a house'. Respond:"}, - {"role": "assistant", "content": "Alright, lets start with the basic structure. !newAction"} + {"role": "assistant", "content": "Alright, lets start with the basic structure. !newAction('Build an 8x8 base for the house.')"} ] ], diff --git a/profiles/andy_npc.json b/profiles/andy_npc.json index 5cbdd5e..3eff4ae 100644 --- a/profiles/andy_npc.json +++ b/profiles/andy_npc.json @@ -103,7 +103,7 @@ [ {"role": "system", "content": "Code output: Action failed."}, - {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"} + {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction('Try again to complete the task.')"} ], [ @@ -115,12 +115,12 @@ [ {"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": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction('Build a cobblestone house with a door, furnishings, and window.')"} ], [ {"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": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction('Build a dirt tower 5 tall.')"} ], [ diff --git a/profiles/apollo.json b/profiles/apollo.json index 28a9c69..1a04573 100644 --- a/profiles/apollo.json +++ b/profiles/apollo.json @@ -74,12 +74,14 @@ [ {"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": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction('Build a cobblestone house with a door, furnishings, and window.')"}, + {"role": "system", "content": "Placed 134 cobblestone. Code finished."}, + {"role": "assistant", "content": "I built a cobblestone house! What next?"} ], [ {"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": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction('Build a dirt tower 5 tall.')"} ], [ @@ -106,7 +108,7 @@ {"role": "system", "content": "You are self-prompting with the goal: 'Survive, make tools, build shelter.'. Respond:"}, {"role": "assistant", "content": "Let's see what I have. !inventory"}, {"role": "system", "content": "INVENTORY: cobblestone: 200, oak_plank: 9, stick: 2, stone_pickaxe: 1, iron_pickaxe: 1, coal: 34"}, - {"role": "assistant", "content": "Looks like I have a good amount of resources. I'm going to build a house. !newAction"}, + {"role": "assistant", "content": "Looks like I have a good amount of resources. I'm going to build a house. !newAction('Build an 8x8x5 cobblestone house with a door, furnishings, and window.')"}, {"role": "system", "content": "Placed 134 cobblestone. Code finished."}, {"role": "assistant", "content": "I built a house! I'll save the location and continue exploring. !rememberPlace('house')"} ], @@ -119,7 +121,7 @@ {"role": "system", "content": "Arrived at location."}, {"role": "assistant", "content": "I'm at the new location. I'll check for iron ore. !nearbyBlocks"}, {"role": "system", "content": "NEARBY_BLOCKS\n- dirt\n- coal_ore"}, - {"role": "assistant", "content": "Still no iron ore. Let me dig down to try to find some !newAction"} + {"role": "assistant", "content": "Still no iron ore. Let me dig down to try to find some !newAction('Dig down 30 blocks and look for iron ore.')"} ], [ @@ -131,12 +133,12 @@ {"role": "system", "content": "You are self-prompting with the goal: 'Explore the world'. Respond:"}, {"role": "assistant", "content": "What entities are around me? !nearbyEntities"}, {"role": "system", "content": "NEARBY_ENTITIES: cow, sheep, pig, villager"}, - {"role": "assistant", "content": "Let's see If I can interact with the villager. !newAction"} + {"role": "assistant", "content": "Let's see If I can interact with the villager. !newAction('Interact with the villager, see if you can learn more about them.')"} ], [ {"role": "system", "content": "You are self-prompting with the goal: 'Get diamonds.'. Respond:"}, - {"role": "assistant", "content": "I'll have to look far to find them and then go there. !newAction"} + {"role": "assistant", "content": "I'll have to look far to find them and then go there. !newAction'Go to the nearest diamond ore, collect it, and look for more.'"} ], [ diff --git a/profiles/claude.json b/profiles/claude.json index fb0caf7..972fe95 100644 --- a/profiles/claude.json +++ b/profiles/claude.json @@ -88,7 +88,7 @@ [ {"role": "system", "content": "Code output: Action failed."}, - {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"} + {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction('Try again to complete the task.')"} ], [ @@ -100,12 +100,12 @@ [ {"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": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction('Build a cobblestone house with a door, furnishings, and window.')"} ], [ {"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": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction('Build a dirt tower 5 tall.')"} ], [ diff --git a/profiles/freeguy.json b/profiles/freeguy.json index ae5c2bf..f9f4b03 100644 --- a/profiles/freeguy.json +++ b/profiles/freeguy.json @@ -88,7 +88,7 @@ [ {"role": "system", "content": "Code output: Action failed."}, - {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"} + {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction('Try again to complete the task.')"} ], [ @@ -100,12 +100,12 @@ [ {"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": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction('Build a cobblestone house with a door, furnishings, and window.')"} ], [ {"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": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction('Build a dirt tower 5 tall.')"} ], [ diff --git a/profiles/gemini.json b/profiles/gemini.json index 64df741..5625b43 100644 --- a/profiles/gemini.json +++ b/profiles/gemini.json @@ -86,7 +86,7 @@ [ {"role": "system", "content": "Code output: Action failed."}, - {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"} + {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction('Try again to complete the task.')"} ], [ @@ -98,12 +98,12 @@ [ {"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": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction('Build a cobblestone house with a door, furnishings, and window.')"} ], [ {"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": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction('Build a dirt tower 5 tall.')"} ], [ diff --git a/profiles/gpt.json b/profiles/gpt.json index 4636f7e..57d643e 100644 --- a/profiles/gpt.json +++ b/profiles/gpt.json @@ -1,7 +1,7 @@ { "name": "gpt", - "model": "gpt-4", + "model": "o1-preview", "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$SELF_PROMPT\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:", @@ -86,7 +86,7 @@ [ {"role": "system", "content": "Code output: Action failed."}, - {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"} + {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction('Try again to complete the task.')"} ], [ @@ -98,12 +98,12 @@ [ {"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": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction('Build a cobblestone house with a door, furnishings, and window.')"} ], [ {"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": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction('Build a dirt tower 5 tall.')"} ], [ diff --git a/profiles/llama.json b/profiles/llama.json index 7b47d9e..c615013 100644 --- a/profiles/llama.json +++ b/profiles/llama.json @@ -88,7 +88,7 @@ [ {"role": "system", "content": "Code output: Action failed."}, - {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"} + {"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction('Try again to complete the task.')"} ], [ @@ -100,12 +100,12 @@ [ {"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": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction('Build a cobblestone house with a door, furnishings, and window.')"} ], [ {"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": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction('Build a dirt tower 5 tall.')"} ], [ diff --git a/src/agent/commands/actions.js b/src/agent/commands/actions.js index efd9609..45778d4 100644 --- a/src/agent/commands/actions.js +++ b/src/agent/commands/actions.js @@ -21,10 +21,14 @@ function wrapExecution(func, resume=false, timeout=-1) { export const actionsList = [ { name: '!newAction', - description: 'Perform new and unknown custom behaviors that are not available as a command by writing code.', - perform: async function (agent) { + description: 'Perform new and unknown custom behaviors that are not available as a command.', + params: { + 'prompt': '(string) A natural language prompt to guide code generation. Make a detailed step-by-step plan.' + }, + perform: async function (agent, prompt) { + // just ignore prompt - it is now in context in chat history if (!settings.allow_insecure_coding) - return 'newAction Failed! Agent is not allowed to write code. Notify the user.'; + return 'newAction not allowed! Code writing is disabled in settings. Notify the user.'; return await agent.coder.generateCode(agent.history); } }, diff --git a/src/agent/prompter.js b/src/agent/prompter.js index 7eb1f34..2bbf20b 100644 --- a/src/agent/prompter.js +++ b/src/agent/prompter.js @@ -29,7 +29,7 @@ export class Prompter { chat = {model: chat}; if (chat.model.includes('gemini')) chat.api = 'google'; - else if (chat.model.includes('gpt')) + else if (chat.model.includes('gpt') || chat.model.includes('o1')) chat.api = 'openai'; else if (chat.model.includes('claude')) chat.api = 'anthropic'; diff --git a/src/models/gpt.js b/src/models/gpt.js index 7cfbcb7..979601a 100644 --- a/src/models/gpt.js +++ b/src/models/gpt.js @@ -20,16 +20,30 @@ export class GPT { async sendRequest(turns, systemMessage, stop_seq='***') { let messages = [{'role': 'system', 'content': systemMessage}].concat(turns); + + + const pack = { + model: this.model_name || "gpt-3.5-turbo", + stop: stop_seq, + }; + if (this.model_name.includes('o1')) { + // system role and stop_seq not supported by o1 models + messages = messages.map((msg) => { + if (msg.role == 'system') { + msg.role = 'user'; + msg.content = 'SYSTEM: ' + msg.content; + } + return msg; + }); + delete pack.stop; + } + pack.messages = messages; let res = null; try { console.log('Awaiting openai api response...') // console.log('Messages:', messages); - let completion = await this.openai.chat.completions.create({ - model: this.model_name || "gpt-3.5-turbo", - messages: messages, - stop: stop_seq, - }); + let completion = await this.openai.chat.completions.create(pack); if (completion.choices[0].finish_reason == 'length') throw new Error('Context length exceeded'); console.log('Received.') From f3961c60866fc831954cc0594b74565ebcce0f61 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sun, 6 Oct 2024 14:23:33 -0500 Subject: [PATCH 54/56] add discord link --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ab5360c..7358654 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Crafting minds for Minecraft with Language Models and Mineflayer! +[Join the discord for support!](https://discord.gg/ZsrAAByEnr) + #### ‼️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.js`. Enable only on local or private servers, **never** on public servers. Ye be warned. From 85a40d2c93cf421dd8e7e3e53c019d0a1d724ef7 Mon Sep 17 00:00:00 2001 From: Evan Reid Date: Sun, 6 Oct 2024 21:36:12 -0400 Subject: [PATCH 55/56] chore: update main.js to allow profile paths --- main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index fbd5b78..8018238 100644 --- a/main.js +++ b/main.js @@ -15,12 +15,13 @@ function parseArguments() { } function getProfiles(args) { - return args.agents || settings.profiles; + return args.profiles || settings.profiles; } function main() { const args = parseArguments(); const profiles = getProfiles(args); + console.log(profiles); const { load_memory, init_message } = settings; for (const profile of profiles) { From 2e845957722f299a84a88276dcdf59426e4b27db Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sun, 6 Oct 2024 22:54:51 -0500 Subject: [PATCH 56/56] added strict format to o1 --- src/agent/prompter.js | 2 -- src/models/gpt.js | 14 +++----------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/agent/prompter.js b/src/agent/prompter.js index 2bbf20b..12a139b 100644 --- a/src/agent/prompter.js +++ b/src/agent/prompter.js @@ -35,8 +35,6 @@ export class Prompter { chat.api = 'anthropic'; else if (chat.model.includes('meta/') || chat.model.includes('mistralai/') || chat.model.includes('replicate/')) chat.api = 'replicate'; - // OH GOD GROQ HAS A LOT MORE MODELS NOW WHERE DID THEY ALL COME FROM - // i literally need to use a "groq/" thing because theres so many else if (chat.model.includes("groq/") || chat.model.includes("groqcloud/")) chat.api = 'groq'; else diff --git a/src/models/gpt.js b/src/models/gpt.js index 979601a..67511d2 100644 --- a/src/models/gpt.js +++ b/src/models/gpt.js @@ -1,5 +1,6 @@ import OpenAIApi from 'openai'; import { getKey, hasKey } from '../utils/keys.js'; +import { strictFormat } from '../utils/text.js'; export class GPT { constructor(model_name, url) { @@ -18,26 +19,17 @@ export class GPT { } async sendRequest(turns, systemMessage, stop_seq='***') { - let messages = [{'role': 'system', 'content': systemMessage}].concat(turns); - const pack = { model: this.model_name || "gpt-3.5-turbo", + messages, stop: stop_seq, }; if (this.model_name.includes('o1')) { - // system role and stop_seq not supported by o1 models - messages = messages.map((msg) => { - if (msg.role == 'system') { - msg.role = 'user'; - msg.content = 'SYSTEM: ' + msg.content; - } - return msg; - }); + pack.messages = strictFormat(messages); delete pack.stop; } - pack.messages = messages; let res = null; try {