mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-04-29 19:44:53 +02:00
add modes to profile
This commit is contained in:
parent
af8252cd95
commit
25c4f68be7
3 changed files with 28 additions and 13 deletions
11
andy.json
11
andy.json
|
@ -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:",
|
"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: ",
|
"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": [
|
"conversation_examples": [
|
||||||
[
|
[
|
||||||
|
|
|
@ -11,7 +11,7 @@ import * as mc from '../../utils/mcdata.js';
|
||||||
export class NPCContoller {
|
export class NPCContoller {
|
||||||
constructor(agent) {
|
constructor(agent) {
|
||||||
this.agent = agent;
|
this.agent = agent;
|
||||||
this.data = NPCData.fromObject(agent.prompter.prompts.npc);
|
this.data = NPCData.fromObject(agent.prompter.profile.npc);
|
||||||
this.temp_goals = [];
|
this.temp_goals = [];
|
||||||
this.item_goal = new ItemGoal(agent, this.data);
|
this.item_goal = new ItemGoal(agent, this.data);
|
||||||
this.build_goal = new BuildGoal(agent);
|
this.build_goal = new BuildGoal(agent);
|
||||||
|
|
|
@ -15,12 +15,12 @@ import { Local } from '../models/local.js';
|
||||||
export class Prompter {
|
export class Prompter {
|
||||||
constructor(agent, fp) {
|
constructor(agent, fp) {
|
||||||
this.agent = agent;
|
this.agent = agent;
|
||||||
this.prompts = JSON.parse(readFileSync(fp, 'utf8'));
|
this.profile = JSON.parse(readFileSync(fp, 'utf8'));
|
||||||
this.convo_examples = null;
|
this.convo_examples = null;
|
||||||
this.coding_examples = null;
|
this.coding_examples = null;
|
||||||
|
|
||||||
let name = this.prompts.name;
|
let name = this.profile.name;
|
||||||
let chat = this.prompts.model;
|
let chat = this.profile.model;
|
||||||
if (typeof chat === 'string' || chat instanceof String) {
|
if (typeof chat === 'string' || chat instanceof String) {
|
||||||
chat = {model: chat};
|
chat = {model: chat};
|
||||||
if (chat.model.includes('gemini'))
|
if (chat.model.includes('gemini'))
|
||||||
|
@ -50,7 +50,7 @@ export class Prompter {
|
||||||
else
|
else
|
||||||
throw new Error('Unknown API:', api);
|
throw new Error('Unknown API:', api);
|
||||||
|
|
||||||
let embedding = this.prompts.embedding;
|
let embedding = this.profile.embedding;
|
||||||
if (embedding === undefined) {
|
if (embedding === undefined) {
|
||||||
if (chat.api !== 'ollama')
|
if (chat.api !== 'ollama')
|
||||||
embedding = {api: chat.api};
|
embedding = {api: chat.api};
|
||||||
|
@ -76,7 +76,7 @@ export class Prompter {
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdirSync(`./bots/${name}`, { recursive: true });
|
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) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -85,15 +85,19 @@ export class Prompter {
|
||||||
}
|
}
|
||||||
|
|
||||||
getName() {
|
getName() {
|
||||||
return this.prompts.name;
|
return this.profile.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
getInitModes() {
|
||||||
|
return this.profile.modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
async initExamples() {
|
async initExamples() {
|
||||||
console.log('Loading examples...')
|
console.log('Loading examples...')
|
||||||
this.convo_examples = new Examples(this.embedding_model);
|
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);
|
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.');
|
console.log('Examples loaded.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,25 +153,25 @@ export class Prompter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async promptConvo(messages) {
|
async promptConvo(messages) {
|
||||||
let prompt = this.prompts.conversing;
|
let prompt = this.profile.conversing;
|
||||||
prompt = await this.replaceStrings(prompt, messages, this.convo_examples);
|
prompt = await this.replaceStrings(prompt, messages, this.convo_examples);
|
||||||
return await this.chat_model.sendRequest(messages, prompt);
|
return await this.chat_model.sendRequest(messages, prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
async promptCoding(messages) {
|
async promptCoding(messages) {
|
||||||
let prompt = this.prompts.coding;
|
let prompt = this.profile.coding;
|
||||||
prompt = await this.replaceStrings(prompt, messages, this.coding_examples);
|
prompt = await this.replaceStrings(prompt, messages, this.coding_examples);
|
||||||
return await this.chat_model.sendRequest(messages, prompt);
|
return await this.chat_model.sendRequest(messages, prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
async promptMemSaving(prev_mem, to_summarize) {
|
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);
|
prompt = await this.replaceStrings(prompt, null, null, prev_mem, to_summarize);
|
||||||
return await this.chat_model.sendRequest([], prompt);
|
return await this.chat_model.sendRequest([], prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
async promptGoalSetting(messages, last_goals) {
|
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);
|
system_message = await this.replaceStrings(system_message, messages);
|
||||||
|
|
||||||
let user_message = 'Use the below info to determine what goal to target next\n\n';
|
let user_message = 'Use the below info to determine what goal to target next\n\n';
|
||||||
|
|
Loading…
Add table
Reference in a new issue