mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-04-22 06:02:07 +02:00
added code exception example
This commit is contained in:
parent
c36fb02c9e
commit
6f25a2ea5f
3 changed files with 12 additions and 5 deletions
|
@ -40,5 +40,12 @@
|
||||||
[
|
[
|
||||||
{"role": "user", "content": "billybob: stop"},
|
{"role": "user", "content": "billybob: stop"},
|
||||||
{"role": "assistant", "content": "```\n// I am going to write empty code to stop whatever I am doing\n```"}
|
{"role": "assistant", "content": "```\n// I am going to write empty code to stop whatever I am doing\n```"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "maya: go to the nearest oak log"},
|
||||||
|
{"role": "assistant", "content": "```\n// I am navigating to the nearest oak log.\nawait skills.goToPosition(bot, nearestOakLog.x, nearestOakLog.y, nearestOakLog.z);\n```"},
|
||||||
|
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
||||||
|
{"role": "assistant", "content": "Apologies, I made an error. Let me try that again.```\n// I am navigating to the nearest oak log.\nlet position = world.getNearestBlock(bot, 'oak_log', 20);\nawait skills.goToPosition(bot, position.x, position.y, position.z);\n```"}
|
||||||
]
|
]
|
||||||
]
|
]
|
|
@ -63,7 +63,7 @@ export class History {
|
||||||
if (this.memory != '') {
|
if (this.memory != '') {
|
||||||
memory_prompt += ' Include information from your previous memory if it is still relevant. Your output will replace your previous memory.';
|
memory_prompt += ' Include information from your previous memory if it is still relevant. Your output will replace your previous memory.';
|
||||||
}
|
}
|
||||||
memory_prompt += ' Your output should use one of the following formats:\n';
|
memory_prompt += ' Your output should be a brief list of things you have learned using the following formats:\n';
|
||||||
memory_prompt += '- When the player... output...\n';
|
memory_prompt += '- When the player... output...\n';
|
||||||
memory_prompt += '- I learned that player [name]...\n';
|
memory_prompt += '- I learned that player [name]...\n';
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ export class History {
|
||||||
for (let example of examples) {
|
for (let example of examples) {
|
||||||
let messages = '';
|
let messages = '';
|
||||||
for (let turn of example) {
|
for (let turn of example) {
|
||||||
if (turn.role == 'user')
|
if (turn.role != 'assistant')
|
||||||
messages += turn.content.substring(turn.content.indexOf(':')+1).trim() + '\n';
|
messages += turn.content.substring(turn.content.indexOf(':')+1).trim() + '\n';
|
||||||
}
|
}
|
||||||
messages = messages.trim();
|
messages = messages.trim();
|
||||||
|
@ -97,7 +97,7 @@ export class History {
|
||||||
async setExamples() {
|
async setExamples() {
|
||||||
let messages = '';
|
let messages = '';
|
||||||
for (let turn of this.turns) {
|
for (let turn of this.turns) {
|
||||||
if (turn.role == 'user')
|
if (turn.role != 'assistant')
|
||||||
messages += turn.content.substring(turn.content.indexOf(':')+1).trim() + '\n';
|
messages += turn.content.substring(turn.content.indexOf(':')+1).trim() + '\n';
|
||||||
}
|
}
|
||||||
messages = messages.trim();
|
messages = messages.trim();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAllBlockIds, getAllBlocks, getAllItems } from './mcdata.js';
|
import { getAllBlockIds } from './mcdata.js';
|
||||||
|
|
||||||
|
|
||||||
export function getNearestBlock(bot, block_type, distance=16) {
|
export function getNearestBlock(bot, block_type, distance=16) {
|
||||||
|
@ -6,7 +6,7 @@ export function getNearestBlock(bot, block_type, distance=16) {
|
||||||
* Get the position of the nearest block of the given type.
|
* Get the position of the nearest block of the given type.
|
||||||
* @param {Bot} bot - The bot to get the nearest block for.
|
* @param {Bot} bot - The bot to get the nearest block for.
|
||||||
* @param {string} block_type - The name of the block to search for.
|
* @param {string} block_type - The name of the block to search for.
|
||||||
* @param {number} distance - The maximum distance to search.
|
* @param {number} distance - The maximum distance to search, default 16.
|
||||||
* @returns {Block} - The nearest block of the given type.
|
* @returns {Block} - The nearest block of the given type.
|
||||||
* @example
|
* @example
|
||||||
* let coalBlock = world.getNearestBlock(bot, 'coal_ore', 16);
|
* let coalBlock = world.getNearestBlock(bot, 'coal_ore', 16);
|
||||||
|
|
Loading…
Add table
Reference in a new issue