diff --git a/README.md b/README.md index da11ecb..d7d1d94 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. 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..12a139b 100644 --- a/src/agent/prompter.js +++ b/src/agent/prompter.js @@ -29,14 +29,12 @@ 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'; 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 7cfbcb7..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,18 +19,23 @@ 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')) { + pack.messages = strictFormat(messages); + delete pack.stop; + } + 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.')