improved example reading, commands

This commit is contained in:
MaxRobinsonTheGreat 2024-01-13 12:10:15 -06:00
parent 24b8c17db0
commit 4f48dea4f6
3 changed files with 19 additions and 10 deletions

View file

@ -18,7 +18,10 @@ export class Agent {
this.events = new Events(this, this.history.events)
this.bot.on('login', async () => {
this.bot.chat('Hello world! I am ' + this.name);
await this.history.loadExamples();
if (!init_message)
this.bot.chat('Hello world! I am ' + this.name);
console.log(`${this.name} logged in.`);
const ignore_messages = [
@ -39,7 +42,6 @@ export class Agent {
this.handleMessage(username, message);
});
await this.history.loadExamples();
if (init_message) {
this.handleMessage('system', init_message);
@ -57,10 +59,14 @@ export class Agent {
if (user_command_name) {
this.bot.chat(`*${source} used ${user_command_name.substring(1)}*`);
let execute_res = await executeCommand(this, message);
if (user_command_name === '!newAction') {
// all user initiated commands are ignored by the bot except for this one
// add the preceding message to the history to give context for newAction
let truncated_msg = message.substring(0, message.indexOf(user_command_name)).trim();
this.history.add(source, truncated_msg);
}
if (execute_res)
this.bot.chat(execute_res);
else
this.bot.chat('Finished command.');
return;
}

View file

@ -96,6 +96,7 @@ export class Coder {
if (code_return.interrupted && !code_return.timedout)
return;
console.log(code_return.message);
messages.push({
role: 'assistant',

View file

@ -25,19 +25,21 @@ export class History {
}
getHistory(include_examples=true) {
let history = [];
// return deep copy of history
let turns = JSON.parse(JSON.stringify(this.turns));
if (include_examples && this.selected_examples.length > 0) {
let example_messages = 'Here are some examples of how to respond:\n';
for (let example of this.selected_examples) {
history = history.concat(example.turns);
example_messages += 'Example:\n' + stringifyTurns(example.turns) + '\n';
}
return [{'role': 'system', 'content': example_messages}].concat(turns);
}
history = history.concat(this.turns);
return history;
return turns;
}
getSystemMessage() {
let system_message = `You are a playful Minecraft bot named '${this.name}' that can communicate with players, see, move, mine, build, and interact with the world by writing and executing code. Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, use actions often, and do not give instructions unless asked.`;
let system_message = `You are a playful Minecraft bot named '${this.name}' that can communicate 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, use commands often, and do not give instructions unless asked.
Don't pretend to act, use commands immediately when requested. Do NOT do this: "Sure, I'll follow you! *follows you*", instead do this: "Sure I'll follow you! !followPlayer('steve')". Have fun :) \n`;
system_message += getCommandDocs();
if (this.bio != '')
system_message += '\n\nBio:\n' + this.bio;