Fixed agent.js, removed unncessary change in main.js, moved/deleted unnecessary files

This commit is contained in:
Ayush Maniar 2025-03-08 16:46:59 -08:00
parent d871cd93af
commit 52b4e09981
5 changed files with 12 additions and 82 deletions

View file

@ -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"
}

View file

@ -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))

View file

@ -1,6 +0,0 @@
{
"name": "randy",
"model": "gpt-4o-mini"
}

View file

@ -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<max_responses; i++) {
if (checkInterrupt()) break;
let history = this.history.getHistory();
let res = await this.prompter.promptConvo(history);
@ -336,6 +334,7 @@ export class Agent {
}
async routeResponse(to_player, message) {
if (this.shut_up) return;
let self_prompt = to_player === 'system' || to_player === this.name;
if (self_prompt && this.last_sender) {
// this is for when the agent is prompted by system while still in conversation
@ -377,7 +376,7 @@ export class Agent {
}
}
async startEvents() {
startEvents() {
// Custom events
// this.bot.on('spawn', () => {
@ -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) {