add modes to profile

This commit is contained in:
MaxRobinsonTheGreat 2024-06-03 18:23:29 -05:00
parent af8252cd95
commit 25c4f68be7
3 changed files with 28 additions and 13 deletions

View file

@ -8,6 +8,17 @@
"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$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": true,
"cowardice": true,
"self_defense": true,
"hunting": true,
"item_collecting": true,
"torch_placing": true,
"idle_staring": true,
"cheat": false
},
"conversation_examples": [
[

View file

@ -11,7 +11,7 @@ import * as mc from '../../utils/mcdata.js';
export class NPCContoller {
constructor(agent) {
this.agent = agent;
this.data = NPCData.fromObject(agent.prompter.prompts.npc);
this.data = NPCData.fromObject(agent.prompter.profile.npc);
this.temp_goals = [];
this.item_goal = new ItemGoal(agent, this.data);
this.build_goal = new BuildGoal(agent);

View file

@ -15,12 +15,12 @@ import { Local } from '../models/local.js';
export class Prompter {
constructor(agent, fp) {
this.agent = agent;
this.prompts = JSON.parse(readFileSync(fp, 'utf8'));
this.profile = JSON.parse(readFileSync(fp, 'utf8'));
this.convo_examples = null;
this.coding_examples = null;
let name = this.prompts.name;
let chat = this.prompts.model;
let name = this.profile.name;
let chat = this.profile.model;
if (typeof chat === 'string' || chat instanceof String) {
chat = {model: chat};
if (chat.model.includes('gemini'))
@ -50,7 +50,7 @@ export class Prompter {
else
throw new Error('Unknown API:', api);
let embedding = this.prompts.embedding;
let embedding = this.profile.embedding;
if (embedding === undefined) {
if (chat.api !== 'ollama')
embedding = {api: chat.api};
@ -76,7 +76,7 @@ export class Prompter {
}
mkdirSync(`./bots/${name}`, { recursive: true });
writeFileSync(`./bots/${name}/last_profile.json`, JSON.stringify(this.prompts, null, 4), (err) => {
writeFileSync(`./bots/${name}/last_profile.json`, JSON.stringify(this.profile, null, 4), (err) => {
if (err) {
throw err;
}
@ -85,15 +85,19 @@ export class Prompter {
}
getName() {
return this.prompts.name;
return this.profile.name;
}
getInitModes() {
return this.profile.modes;
}
async initExamples() {
console.log('Loading examples...')
this.convo_examples = new Examples(this.embedding_model);
await this.convo_examples.load(this.prompts.conversation_examples);
await this.convo_examples.load(this.profile.conversation_examples);
this.coding_examples = new Examples(this.embedding_model);
await this.coding_examples.load(this.prompts.coding_examples);
await this.coding_examples.load(this.profile.coding_examples);
console.log('Examples loaded.');
}
@ -149,25 +153,25 @@ export class Prompter {
}
async promptConvo(messages) {
let prompt = this.prompts.conversing;
let prompt = this.profile.conversing;
prompt = await this.replaceStrings(prompt, messages, this.convo_examples);
return await this.chat_model.sendRequest(messages, prompt);
}
async promptCoding(messages) {
let prompt = this.prompts.coding;
let prompt = this.profile.coding;
prompt = await this.replaceStrings(prompt, messages, this.coding_examples);
return await this.chat_model.sendRequest(messages, prompt);
}
async promptMemSaving(prev_mem, to_summarize) {
let prompt = this.prompts.saving_memory;
let prompt = this.profile.saving_memory;
prompt = await this.replaceStrings(prompt, null, null, prev_mem, to_summarize);
return await this.chat_model.sendRequest([], prompt);
}
async promptGoalSetting(messages, last_goals) {
let system_message = this.prompts.goal_setting;
let system_message = this.profile.goal_setting;
system_message = await this.replaceStrings(system_message, messages);
let user_message = 'Use the below info to determine what goal to target next\n\n';