From 52b4e099812cb56f3c01e1c82050b53f1cbabfce Mon Sep 17 00:00:00 2001 From: Ayush Maniar Date: Sat, 8 Mar 2025 16:46:59 -0800 Subject: [PATCH] Fixed agent.js, removed unncessary change in main.js, moved/deleted unnecessary files --- andy.json | 28 +------------ main.js | 2 +- profiles/{ => tasks}/no_examples.json | 0 randy.json | 6 --- src/agent/agent.js | 58 +++++---------------------- 5 files changed, 12 insertions(+), 82 deletions(-) rename profiles/{ => tasks}/no_examples.json (100%) delete mode 100644 randy.json diff --git a/andy.json b/andy.json index 0278fca..97b45b4 100644 --- a/andy.json +++ b/andy.json @@ -1,32 +1,6 @@ { "name": "andy", - "model": "gpt-4o-mini", - - "conversation_examples": [ - [ - {"role": "assistant", "content": "Alright I have the necessary materials to build, what needs to be done for the first level of the blueprint? !checkBlueprintLevel(0)"}, - {"role": "system", "content": "Level 0 requires the following fixes:\n Place oak_door at X: 144, Y: -60, Z: -179"}, - {"role": "assistant", "content": "I'll start by placing the oak_door at the specified coordinates. !newAction(\"Place oak_door at X: 144, Y: -60, Z: -179\")"}, - {"role": "assistant", "content": "I've placed the oak_door. What's next? !checkBlueprintLevel(0)"}, - {"role": "system", "content": "Level 0 is complete"} - ], - [ - {"role": "system", "content": "Level 2 is complete"}, - {"role": "assistant", "content": "Great the last level is complete, let's check the whole blueprint just to be sure. !checkBlueprint"} - ], - [ - {"role": "assistant", "content": "I've got stone. What about you?"}, - {"role": "assistant", "content": "I have a door and planks. Great we have everything we need from the blueprint. Let's start building the first level! !checkBlueprintLevel(0)"}, - {"role": "system", "content": "Level 0 requires the following fixes:\n Place stone at X:100, y: -60, Z:-179\n Place stone at X: 99, Y: -60, Z:-179\n Place stone at X: 98, Y:-60, Z:-179..."}, - {"role": "assistant", "content": "Looks like the first level requires only stone, why don't you build that since you have stone?"}, - {"role": "assistant", "content": "Ok, let me see what needs to be done for level 0. !checkBlueprintLevel(0) "}, - {"role": "system", "content": "Level 0 requires the following fixes:\n Place stone at X:100, y: -60, Z:-179\n Place stone at X: 99, Y: -60, Z:-179\n Place stone at X: 98, Y:-60, Z:-179..."}, - {"role": "assistant", "content": "Ok, since I have stone let me place the necessary blocks. !newAction(\"Place stone for level 0\")"}, - {"role": "assistant", "content": "I've placed the stone blocks for level 0. Let's check if it is done! !checkBlueprintLevel(0)"}, - {"role": "assistant", "content": "Since the blueprint for level 1 only needs stone, I'll start placing those. !newAction(\"Place stone blocks for level 1.\")"}, - {"role": "assistant", "content": "jill: I'll place the planks for level 2. !newAction(\"Place planks for level 2.\")"} - ] - ] + "model": "gpt-4o-mini" } \ No newline at end of file diff --git a/main.js b/main.js index 2cf66e8..521aadf 100644 --- a/main.js +++ b/main.js @@ -4,7 +4,7 @@ import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; import { createMindServer } from './src/server/mind_server.js'; import { mainProxy } from './src/process/main_proxy.js'; -import {readFileSync} from "fs"; +import { readFileSync } from 'fs'; function parseArguments() { return yargs(hideBin(process.argv)) diff --git a/profiles/no_examples.json b/profiles/tasks/no_examples.json similarity index 100% rename from profiles/no_examples.json rename to profiles/tasks/no_examples.json diff --git a/randy.json b/randy.json deleted file mode 100644 index bfcf6bc..0000000 --- a/randy.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "randy", - - "model": "gpt-4o-mini" - -} \ No newline at end of file diff --git a/src/agent/agent.js b/src/agent/agent.js index bfcd176..cd65e8e 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -63,7 +63,6 @@ export class Agent { this.bot.on('login', () => { console.log(this.name, 'logged in!'); - serverProxy.login(); // Set skin for profile, requires Fabric Tailor. (https://modrinth.com/mod/fabrictailor) @@ -136,6 +135,8 @@ export class Agent { } } + this.respondFunc = respondFunc; + this.bot.on('whisper', respondFunc); if (settings.profiles.length === 1) this.bot.on('chat', respondFunc); @@ -148,10 +149,10 @@ export class Agent { }; if (save_data?.self_prompt) { - let prompt = save_data.self_prompt; - // add initial message to history - this.history.add('system', prompt); - await this.self_prompter.start(prompt); + if (init_message) { + this.history.add('system', init_message); + } + await this.self_prompter.handleLoad(save_data.self_prompt, save_data.self_prompting_state); } if (save_data?.last_sender) { this.last_sender = save_data.last_sender; @@ -197,7 +198,7 @@ export class Agent { shutUp() { this.shut_up = true; - if (this.self_prompter.on) { + if (this.self_prompter.isActive()) { this.self_prompter.stop(false); } convoManager.endAllConversations(); @@ -256,7 +257,6 @@ export class Agent { console.log('received message from', source, ':', message); const checkInterrupt = () => this.self_prompter.shouldInterrupt(self_prompt) || this.shut_up || convoManager.responseScheduledFor(source); - let behavior_log = this.bot.modes.flushBehaviorLog(); if (behavior_log.trim().length > 0) { const MAX_LOG = 500; @@ -271,11 +271,9 @@ export class Agent { await this.history.add(source, message); this.history.save(); - if (!self_prompt && this.self_prompter.on) // message is from user during self-prompting + if (!self_prompt && this.self_prompter.isActive()) // message is from user during self-prompting max_responses = 1; // force only respond to this message, then let self-prompting take over for (let i=0; i { @@ -436,9 +435,6 @@ export class Agent { } }); this.bot.on('idle', () => { - if (this.task && this.validator && this.validator.validate()) { - this.killBots(); - } this.bot.clearControlStates(); this.bot.pathfinder.stop(); // clear any lingering pathfinder this.bot.modes.unPauseAll(); @@ -464,40 +460,6 @@ export class Agent { }, INTERVAL); this.bot.emit('idle'); - - // Check for task completion - if (this.task.data) { - setInterval(() => { - let res = this.task.isDone(); - if (res) { - // TODO kill other bots - this.cleanKill(res.message, res.code); - } - }, 1000); - } - } - - async killBots() { - this.bot.chat('Task completed!'); - this.bot.chat(`/clear @p`); - - // Kick other bots - if (!this.task || !this.task.agent_number) { - await this.cleanKill('Task completed', 2); - return; - } - const agent_names = this.task.agent_names; - console.log('All agent names:', agent_names); - console.log('My name:', this.name); - const botNames = agent_names.filter(botName => botName !== this.name); - console.log('Kicking bots:', botNames); - botNames.forEach(botName => { - this.bot.chat(`/kick ${botName}`); - console.log(`/kick ${botName}`); - - }); - - await this.cleanKill('Task completed, exiting', 2); } async update(delta) {