mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-11 09:45:33 +02:00
added conversation examples and fixed an issue with the validation function
This commit is contained in:
parent
3f728957c4
commit
9e7ead7e0c
3 changed files with 29 additions and 15 deletions
|
@ -4,6 +4,13 @@
|
||||||
"model": "gpt-4o",
|
"model": "gpt-4o",
|
||||||
|
|
||||||
"conversation_examples": [
|
"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": "assistant", "content": "I've got stone. What about you jack?"},
|
{"role": "assistant", "content": "I've got stone. What about you jack?"},
|
||||||
{"role": "assistant", "content": "I have a door and planks. Great we have everything we need from the blueprint. Let's start building!"},
|
{"role": "assistant", "content": "I have a door and planks. Great we have everything we need from the blueprint. Let's start building!"},
|
||||||
|
|
|
@ -170,7 +170,7 @@ export const queryList = [
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '!checkLevelComplete',
|
name: '!checkBlueprintLevel',
|
||||||
description: 'Check if the level is complete and what blocks still need to be placed for the blueprint',
|
description: 'Check if the level is complete and what blocks still need to be placed for the blueprint',
|
||||||
params: {
|
params: {
|
||||||
'levelNum': { type: 'int', description: 'The level number to check.', domain: [0, Number.MAX_SAFE_INTEGER] }
|
'levelNum': { type: 'int', description: 'The level number to check.', domain: [0, Number.MAX_SAFE_INTEGER] }
|
||||||
|
|
|
@ -49,7 +49,7 @@ export class ConstructionTaskValidator {
|
||||||
console.log('Validating task...');
|
console.log('Validating task...');
|
||||||
let valid = false;
|
let valid = false;
|
||||||
let score = 0;
|
let score = 0;
|
||||||
this.blueprint.check(this.agent.bot).then((result) => {
|
let result = this.blueprint.check(this.agent.bot);
|
||||||
if (result.mismatches.length === 0) {
|
if (result.mismatches.length === 0) {
|
||||||
valid = true;
|
valid = true;
|
||||||
console.log('Task is complete');
|
console.log('Task is complete');
|
||||||
|
@ -57,7 +57,6 @@ export class ConstructionTaskValidator {
|
||||||
let total_blocks = result.mismatches.length + result.matches.length;
|
let total_blocks = result.mismatches.length + result.matches.length;
|
||||||
score = (result.matches.length / total_blocks) * 100;
|
score = (result.matches.length / total_blocks) * 100;
|
||||||
console.log(`Task is ${score}% complete`);
|
console.log(`Task is ${score}% complete`);
|
||||||
});
|
|
||||||
return valid;
|
return valid;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error validating task:', error);
|
console.error('Error validating task:', error);
|
||||||
|
@ -143,18 +142,26 @@ export class Blueprint {
|
||||||
const levelData = this.data.levels[levelNum];
|
const levelData = this.data.levels[levelNum];
|
||||||
|
|
||||||
if (mismatches.length === 0) {
|
if (mismatches.length === 0) {
|
||||||
return `Level ${levelData.level} is correct`;
|
return `Level ${levelData.level} is complete`;
|
||||||
}
|
}
|
||||||
var explanation = `Level ${levelData.level} `;
|
var explanation = `Level ${levelData.level} `;
|
||||||
// explanation += `at coordinates X: ${levelData.coordinates[0]}, Y: ${levelData.coordinates[1]}, Z: ${levelData.coordinates[2]}`;
|
// explanation += `at coordinates X: ${levelData.coordinates[0]}, Y: ${levelData.coordinates[1]}, Z: ${levelData.coordinates[2]}`;
|
||||||
explanation += " has the following mismatches:\n";
|
explanation += " requires the following fixes:\n";
|
||||||
for (let item of mismatches) {
|
for (let item of mismatches) {
|
||||||
explanation += `At coordinates X: ${item.coordinates[0]}, Y: ${item.coordinates[1]}, Z: ${item.coordinates[2]} `;
|
if (item.actual === 'air') {
|
||||||
explanation += `expected ${item.expected}, but found ${item.actual}\n`;
|
explanation += `Place ${item.expected} at coordinates X: ${item.coordinates[0]}, Y: ${item.coordinates[1]}, Z: ${item.coordinates[2]}\n`;
|
||||||
|
} else if (item.expected === 'air') {
|
||||||
|
explanation += `Remove the ${item.actual} at coordinates X: ${item.coordinates[0]}, Y: ${item.coordinates[1]}, Z: ${item.coordinates[2]}\n`;
|
||||||
|
} else {
|
||||||
|
explanation += `Replace the ${item.actual} with a ${item.expected} at coordinates X: ${item.coordinates[0]}, Y: ${item.coordinates[1]}, Z: ${item.coordinates[2]} \n`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return explanation;
|
return explanation;
|
||||||
}
|
}
|
||||||
check(bot) {
|
check(bot) {
|
||||||
|
if (!bot || typeof bot !== 'object' || !bot.hasOwnProperty('blockAt')) {
|
||||||
|
throw new Error('Invalid bot object. Expected a mineflayer bot.');
|
||||||
|
}
|
||||||
const levels = this.data.levels;
|
const levels = this.data.levels;
|
||||||
const mismatches = [];
|
const mismatches = [];
|
||||||
const matches = [];
|
const matches = [];
|
||||||
|
|
Loading…
Add table
Reference in a new issue