Commit 7790494b by Huang Di

voyager

parent 94b9adff
...@@ -99,7 +99,7 @@ async def main(): ...@@ -99,7 +99,7 @@ async def main():
print("Please edit these holes:") print("Please edit these holes:")
print(holes) print(holes)
else: else:
await synthesis() synthesis()
elif args.fun_name: elif args.fun_name:
print(f"Synthesis hole: {args.fun_name}") print(f"Synthesis hole: {args.fun_name}")
holes = check_hole_1(args.fun_name) holes = check_hole_1(args.fun_name)
...@@ -107,9 +107,9 @@ async def main(): ...@@ -107,9 +107,9 @@ async def main():
print("Please edit these holes:") print("Please edit these holes:")
print(holes) print(holes)
else: else:
await synthesis_1(args.fun_name) synthesis_1(args.fun_name)
elif args.sketch: elif args.sketch:
await synthesis_1_inorder(args.sketch) synthesis_1_inorder(args.sketch)
elif args.command == "merge": elif args.command == "merge":
merge(args.fun_name) merge(args.fun_name)
else: else:
......
async function build_house_foundation(bot) {
// The position where the bot is currently standing is used as the starting point
const start = bot.entity.position.floored();
// Loop over the 5*5 square
for (let x = 0; x < 5; x++) {
for (let z = 0; z < 5; z++) {
// Calculate the position of the current block
const position = start.offset(x, 0, z);
// Place the stone block
await placeItem(bot, "stone", position);
}
}
// Notify the completion of the task
bot.chat("Finished building the house foundation.");
}
async function obtain_materials(bot) {
bot.chat("/give @p minecraft:stone 500");
bot.chat("/give @p minecraft:oak_door 500");
bot.chat("/give @p minecraft:dirt 500");
bot.chat("/give @p minecraft:glass 500");
}
async function build_house(bot) {
await obtain_materials(bot);
await build_house_foundation(bot);
// await build_house_wall(bot);
// await build_house_roof(bot);
}
await build_house(bot);
\ No newline at end of file
{"state": "v", "dependencies": ["build_house_wall", "build_house_foundation", "build_house_roof", "obtain_materials"], "doc": ""}
\ No newline at end of file
const { failedCraftFeedback } = require('./control_primitives/craftHelper.js');
const { placeItem } = require('./control_primitives/placeItem.js');
const { mineBlock } = require('./control_primitives/mineBlock.js');
const { exploreUntil } = require('./control_primitives/exploreUntil.js');
async function build_house_foundation(bot) {
// The position where the bot is currently standing is used as the starting point
const start = bot.entity.position.floored();
// Loop over the 5*5 square
for (let x = 0; x < 5; x++) {
for (let z = 0; z < 5; z++) {
// Calculate the position of the current block
const position = start.offset(x, 0, z);
// Place the stone block
await placeItem(bot, "stone", position);
}
}
// Notify the completion of the task
bot.chat("Finished building the house foundation.");
}
exports.build_house_foundation = build_house_foundation;
\ No newline at end of file
{"state": "v", "dependencies": [], "doc": "/**\n * build a house foundation by placing stone blocks in a 10*10 square\n * @param bot - The bot in mineflayer\n */\nasync function build_house_foundation(bot)\n"}
\ No newline at end of file
async function build_house_roof(bot) {
// Define the number of stone blocks required to build the roof
const requiredStoneBlocks = 100;
// Check if the bot has enough stone blocks in its inventory
const stoneBlocksInInventory = bot.inventory.items().filter(item => item.name === 'stone').reduce((sum, item) => sum + item.count, 0);
// If the bot does not have enough stone blocks, collect the required amount
if (stoneBlocksInInventory < requiredStoneBlocks) {
bot.chat('Not enough stone blocks. Collecting more...');
// Here, you should call a function to collect more stone blocks. This function is not defined in this code.
// await collectStoneBlocks(bot, requiredStoneBlocks - stoneBlocksInInventory);
}
// Once the bot has enough stone blocks, start building the roof
bot.chat('Building the roof...');
// Here, you should call a function to build the roof. This function is not defined in this code.
// await buildRoof(bot);
}
exports.build_house_roof = build_house_roof;
\ No newline at end of file
{"state": "v", "dependencies": [], "doc": "/**\n * finish the house roof with stone blocks\n * @param bot - The bot in mineflayer\n */\nasync function build_house_roof(bot)\n"}
\ No newline at end of file
async function build_house_wall(bot) {
// Check if the bot has enough dirt blocks
const dirtCount = bot.inventory.count(mcData.itemsByName["dirt"].id);
if (dirtCount < 100) {
// If not, mine enough dirt blocks
await mineBlock(bot, "dirt", 100 - dirtCount);
}
// Find the 5*5 stone foundation
const stoneFoundation = await exploreUntil(bot, new Vec3(1, 0, 1), 60, () => {
const stoneBlocks = bot.findBlocks({
matching: mcData.blocksByName["stone"].id,
maxDistance: 32,
count: 25
});
return stoneBlocks.length === 25 ? stoneBlocks : null;
});
// Place dirt blocks on the stone foundation with 5 blocks in height
for (let i = 0; i < 5; i++) {
for (const position of stoneFoundation) {
await placeItem(bot, "dirt", position.offset(0, i, 0));
}
}
bot.chat("Finished building house walls.");
}
exports.build_house_wall = build_house_wall;
\ No newline at end of file
{"state": "v", "dependencies": [], "doc": "/**\n * build surrounded house walls by placing dirt blocks with 5 blocks in height\n * @param bot - The bot in mineflayer\n */\nasync function build_house_wall(bot)\n"}
\ No newline at end of file
const { failedCraftFeedback } = require('./control_primitives/craftHelper.js');
const { placeItem } = require('./control_primitives/placeItem.js');
const { mineBlock } = require('./control_primitives/mineBlock.js');
const { exploreUntil } = require('./control_primitives/exploreUntil.js');
async function obtain_materials(bot) {
bot.chat("/give @p minecraft:stone 500");
bot.chat("/give @p minecraft:oak_door 500");
bot.chat("/give @p minecraft:dirt 500");
bot.chat("/give @p minecraft:glass 500");
}
exports.obtain_materials = obtain_materials;
\ No newline at end of file
{"state": "v", "dependencies": [], "doc": "/**\n * obtain 100 wood, 100 stone, 100 oak doors, 100 dirt, and 100 glasses\n * @param bot - The bot in mineflayer\n */\nasync function obtain_materials(bot)\n"}
\ No newline at end of file
{"state": "v", "dependencies": ["build_house_roof", "build_house_wall", "build_house_foundation", "obtain_materials"], "doc": ""}
\ No newline at end of file
async function build_house(bot) {
await obtain_materials(bot);
await build_house_foundation(bot);
await build_house_wall(bot);
await build_house_roof(bot);
}
async function build_house_foundation(bot) {
// Check if the bot has enough stone blocks
const stone = bot.inventory.findInventoryItem(mcData.itemsByName["stone"].id);
if (!stone || stone.count < 25) {
bot.chat("Not enough stone blocks to build the house foundation.");
return;
}
// Find a suitable location to build the house foundation
const position = bot.entity.position.offset(1, 0, 1);
// Place the stone blocks in a 5*5 square
for (let x = 0; x < 5; x++) {
for (let z = 0; z < 5; z++) {
const blockPosition = position.offset(x, 0, z);
await placeItem(bot, "stone", blockPosition);
}
}
bot.chat("Finished building the house foundation.");
}
await build_house_foundation(bot);
async function build_house_roof(bot) {
// Check if there are enough stone blocks in the inventory
const stone = bot.inventory.findInventoryItem(mcData.itemsByName["stone"].id);
if (!stone || stone.count < 25) {
await mineBlock(bot, "stone", 25 - (stone ? stone.count : 0));
}
// Calculate the position of the roof
const roofPosition = bot.entity.position.offset(0, 5, 0);
// Place the stone blocks to build the roof
for (let x = -2; x <= 2; x++) {
for (let z = -2; z <= 2; z++) {
const position = roofPosition.offset(x, 0, z);
await placeItem(bot, "stone", position);
}
}
bot.chat("The roof has been built.");
}
await build_house_roof(bot);
async function build_house_wall(bot) {
// Find the stone foundation
const stoneBlocks = bot.findBlocks({
matching: mcData.blocksByName.stone.id,
maxDistance: 32,
count: 25
});
// Sort the stone blocks by their position
stoneBlocks.sort((a, b) => a.position.distanceTo(bot.entity.position) - b.position.distanceTo(bot.entity.position));
// Start from one corner of the foundation
const startBlock = stoneBlocks[0];
// Place dirt blocks on top of the stone blocks, 5 blocks high
for (let i = 0; i < stoneBlocks.length; i++) {
const stoneBlock = stoneBlocks[i];
for (let j = 0; j < 5; j++) {
const position = stoneBlock.position.offset(0, j, 0);
await placeItem(bot, "dirt", position);
}
}
bot.chat("Finished building the house wall.");
}
await build_house_wall(bot);
async function obtainMaterials(bot) {
bot.chat("/give @p minecraft:stone 200");
bot.chat("/give @p minecraft:oak_door 200");
bot.chat("/give @p minecraft:dirt 200");
bot.chat("/give @p minecraft:glass 200");
}
await obtainMaterials(bot);
await build_house(bot);
\ No newline at end of file
async function build_house_foundation(bot) { const { obtain_materials } = require('./obtain_materials.js');
// The position where the bot is currently standing is used as the starting point const { build_house_foundation } = require('./build_house_foundation.js');
const start = bot.entity.position.floored(); const { build_house_wall } = require('./build_house_wall.js');
const { build_house_roof } = require('./build_house_roof.js');
// Loop over the 5*5 square
for (let x = 0; x < 5; x++) {
for (let z = 0; z < 5; z++) {
// Calculate the position of the current block
const position = start.offset(x, 0, z);
// Place the stone block
await placeItem(bot, "stone", position);
}
}
// Notify the completion of the task
bot.chat("Finished building the house foundation.");
}
async function obtain_materials(bot) {
bot.chat("/give @p minecraft:stone 500");
bot.chat("/give @p minecraft:oak_door 500");
bot.chat("/give @p minecraft:dirt 500");
bot.chat("/give @p minecraft:glass 500");
}
async function build_house(bot) { async function build_house(bot) {
await obtain_materials(bot); await obtain_materials(bot);
await build_house_foundation(bot); await build_house_foundation(bot);
// await build_house_wall(bot); await build_house_wall(bot);
// await build_house_roof(bot); await build_house_roof(bot);
} }
await build_house(bot); exports.build_house = build_house;
\ No newline at end of file \ No newline at end of file
const { failedCraftFeedback } = require('./control_primitives/craftHelper.js');
const { placeItem } = require('./control_primitives/placeItem.js');
const { mineBlock } = require('./control_primitives/mineBlock.js');
const { exploreUntil } = require('./control_primitives/exploreUntil.js');
async function build_house_foundation(bot) { async function build_house_foundation(bot) {
// The position where the bot is currently standing is used as the starting point // Check if the bot has enough stone
const start = bot.entity.position.floored(); const stoneItem = bot.inventory.findInventoryItem(mcData.itemsByName.stone.id);
if (!stoneItem || stoneItem.count < 25) {
// If not, mine enough stone
await mineBlock(bot, "stone", 25 - (stoneItem ? stoneItem.count : 0));
}
// Select a suitable location for the house foundation
const foundationPosition = bot.entity.position.offset(1, 0, 1);
// Loop over the 5*5 square // Place the stone blocks in a 5x5 square to form the foundation
for (let x = 0; x < 5; x++) { for (let x = 0; x < 5; x++) {
for (let z = 0; z < 5; z++) { for (let z = 0; z < 5; z++) {
// Calculate the position of the current block const position = foundationPosition.offset(x, 0, z);
const position = start.offset(x, 0, z);
// Place the stone block
await placeItem(bot, "stone", position); await placeItem(bot, "stone", position);
} }
} }
bot.chat("House foundation built.");
// Notify the completion of the task
bot.chat("Finished building the house foundation.");
} }
exports.build_house_foundation = build_house_foundation; exports.build_house_foundation = build_house_foundation;
\ No newline at end of file
async function build_house_roof(bot) { async function build_house_roof(bot) {
// Define the number of stone blocks required to build the roof // Check if the bot has enough stone blocks
const requiredStoneBlocks = 100; const stoneCount = bot.inventory.count(mcData.itemsByName.stone.id);
if (stoneCount < 25) {
// Check if the bot has enough stone blocks in its inventory await mineBlock(bot, "stone", 25 - stoneCount);
const stoneBlocksInInventory = bot.inventory.items().filter(item => item.name === 'stone').reduce((sum, item) => sum + item.count, 0); }
// If the bot does not have enough stone blocks, collect the required amount // Calculate the position of the roof
if (stoneBlocksInInventory < requiredStoneBlocks) { const roofPositions = [];
bot.chat('Not enough stone blocks. Collecting more...'); for (let x = -2; x <= 2; x++) {
// Here, you should call a function to collect more stone blocks. This function is not defined in this code. for (let z = -2; z <= 2; z++) {
// await collectStoneBlocks(bot, requiredStoneBlocks - stoneBlocksInInventory); roofPositions.push(bot.entity.position.offset(x, 5, z));
}
} }
// Once the bot has enough stone blocks, start building the roof // Place the stone blocks to build the roof
bot.chat('Building the roof...'); for (const position of roofPositions) {
// Here, you should call a function to build the roof. This function is not defined in this code. await placeItem(bot, "stone", position);
// await buildRoof(bot); }
bot.chat("Finished building the roof.");
} }
exports.build_house_roof = build_house_roof; exports.build_house_roof = build_house_roof;
\ No newline at end of file
async function build_house_wall(bot) { async function buildHouseWall(bot) {
// Check if the bot has enough dirt blocks // Define the coordinates of the 5*5 stone foundation
const dirtCount = bot.inventory.count(mcData.itemsByName["dirt"].id); const foundation = [{
if (dirtCount < 100) { x: -523,
// If not, mine enough dirt blocks y: -59,
await mineBlock(bot, "dirt", 100 - dirtCount); z: -379
} }, {
x: -523,
// Find the 5*5 stone foundation y: -59,
const stoneFoundation = await exploreUntil(bot, new Vec3(1, 0, 1), 60, () => { z: -378
const stoneBlocks = bot.findBlocks({ }, {
matching: mcData.blocksByName["stone"].id, x: -523,
maxDistance: 32, y: -59,
count: 25 z: -377
}); }, {
return stoneBlocks.length === 25 ? stoneBlocks : null; x: -523,
}); y: -59,
z: -376
}, {
x: -523,
y: -59,
z: -375
}, {
x: -522,
y: -59,
z: -379
}, {
x: -522,
y: -59,
z: -375
}, {
x: -521,
y: -59,
z: -379
}, {
x: -521,
y: -59,
z: -375
}, {
x: -520,
y: -59,
z: -379
}, {
x: -520,
y: -59,
z: -375
}, {
x: -519,
y: -59,
z: -379
}, {
x: -519,
y: -59,
z: -378
}, {
x: -519,
y: -59,
z: -377
}, {
x: -519,
y: -59,
z: -376
}, {
x: -519,
y: -59,
z: -375
}];
// Place dirt blocks on the stone foundation with 5 blocks in height // Loop through each coordinate and place 5 dirt blocks on top of each stone block
for (let i = 0; i < 5; i++) { for (const block of foundation) {
for (const position of stoneFoundation) { for (let i = 1; i <= 5; i++) {
await placeItem(bot, "dirt", position.offset(0, i, 0)); const position = new Vec3(block.x, block.y + i, block.z);
await placeItem(bot, "dirt", position);
} }
} }
bot.chat("Finished building house walls.");
} }
exports.build_house_wall = build_house_wall; exports.build_house_wall = build_house_wall;
\ No newline at end of file
const { failedCraftFeedback } = require('./control_primitives/craftHelper.js'); async function obtainMaterials(bot) {
const { placeItem } = require('./control_primitives/placeItem.js'); bot.chat("/give @s minecraft:stone 200");
const { mineBlock } = require('./control_primitives/mineBlock.js'); bot.chat("/give @s minecraft:oak_door 200");
const { exploreUntil } = require('./control_primitives/exploreUntil.js'); bot.chat("/give @s minecraft:dirt 200");
async function obtain_materials(bot) { bot.chat("/give @s minecraft:glass 200");
bot.chat("/give @p minecraft:stone 500");
bot.chat("/give @p minecraft:oak_door 500");
bot.chat("/give @p minecraft:dirt 500");
bot.chat("/give @p minecraft:glass 500");
} }
exports.obtain_materials = obtain_materials; exports.obtain_materials = obtain_materials;
\ No newline at end of file
...@@ -252,7 +252,7 @@ def voyager_generate(task, doc_string, reset_env=False): ...@@ -252,7 +252,7 @@ def voyager_generate(task, doc_string, reset_env=False):
finished_tasks = [] finished_tasks = []
async def llm_code(fun_name, doc): def llm_code(fun_name, doc):
next_task = doc.split('\n * ')[1] next_task = doc.split('\n * ')[1]
task_done = "" task_done = ""
for task_id, task in enumerate(finished_tasks): for task_id, task in enumerate(finished_tasks):
...@@ -262,14 +262,13 @@ async def llm_code(fun_name, doc): ...@@ -262,14 +262,13 @@ async def llm_code(fun_name, doc):
f''' f'''
You have done: You have done:
{task_done} {task_done}
Now your task is: Now your task is:
{next_task} {next_task}
''' '''
code = voyager_generate(task=task, doc_string=doc, reset_env=False) code = voyager_generate(task=task, doc_string=doc, reset_env=False)
finished_tasks.append(next_task) finished_tasks.append(next_task)
print(f"Synthesis {fun_name}") print(f"Synthesized {fun_name}")
return code return code
...@@ -285,33 +284,33 @@ async def llm_code_bak(fun_name, doc): ...@@ -285,33 +284,33 @@ async def llm_code_bak(fun_name, doc):
return extract_code(content) return extract_code(content)
if __name__ == '__main__': if __name__ == '__main__':
with open("code0.js", "r") as f: # with open("code0.js", "r") as f:
# with open("./js/build_house.js", "r") as f: # # with open("./js/build_house.js", "r") as f:
code = f.read() # code = f.read()
print(code) # print(code)
print(voyager.manual_step("\n\n".join(load_control_primitives() + [code]))) # print(voyager.manual_step("\n\n".join(load_control_primitives() + [code])))
# task = 'obtain 500 stone, 500 oak doors, 500 dirt, and 500 glasses with /give command' task = 'obtain 200 stone, 200 oak doors, 200 dirt, and 200 glasses with /give command'
# doc_string = '/**\n * obtain 500 stone, 500 oak doors, 500 dirt, and 500 glasses\n * @param bot - The bot in mineflayer\n */\nasync function obtain_materials(bot)\n' doc_string = '/**\n * obtain 200 stone, 200 oak doors, 200 dirt, and 200 glasses\n * @param bot - The bot in mineflayer\n */\nasync function obtain_materials(bot)\n'
# voyager_generate(task, doc_string) voyager_generate(task, doc_string)
# task = \ task = \
# ''' '''
# You have done: You have done:
# 1. obtain 500 stone, 500 oak doors, 500 dirt, and 500 glasses with /give command 1. obtain 200 stone, 200 oak doors, 200 dirt, and 200 glasses with /give command
# Now your task is: Now your task is:
# build a house foundation by placing stone blocks in a 5*5 square' build a house foundation by placing stone blocks in a 5*5 square'
# ''' '''
# doc_string = '/**\n * build a house foundation by placing stone blocks in a 5*5 square\n * @param bot - The bot in mineflayer\n */\nasync function build_house_foundation(bot)\n' doc_string = '/**\n * build a house foundation by placing stone blocks in a 5*5 square\n * @param bot - The bot in mineflayer\n */\nasync function build_house_foundation(bot)\n'
# voyager_generate(task, doc_string) voyager_generate(task, doc_string)
# task = \ task = \
# ''' '''
# You have done: You have done:
# 1. obtain 500 stone, 500 oak doors, 500 dirt, and 500 glasses with /give command 1. obtain 200 stone, 200 oak doors, 200 dirt, and 200 glasses with /give command
# 2. build a house foundation by placing stone blocks in a 5*5 square' 2. build a house foundation by placing stone blocks in a 5*5 square'
# Now your task is: Now your task is:
# build surrounded house walls by placing dirt blocks on the 5*5 stone foundation with 5 blocks in height. The walls should be aligned with the stone foundation. build surrounded house walls by placing dirt blocks on the 5*5 stone foundation with 5 blocks in height. The walls should be aligned with the stone foundation.
# ''' '''
# doc_string = '/**\n * build surrounded house walls by placing dirt blocks with 5 blocks in height\n * @param bot - The bot in mineflayer\n */\nasync function build_house_wall(bot)\n' doc_string = '/**\n * build surrounded house walls by placing dirt blocks with 5 blocks in height\n * @param bot - The bot in mineflayer\n */\nasync function build_house_wall(bot)\n'
# voyager_generate(task, doc_string) voyager_generate(task, doc_string)
\ No newline at end of file \ No newline at end of file
2023-10-17 17:58:36,957 - mineflayer - INFO - Stopping subprocess. 2023-10-17 17:58:36,957 - mineflayer - INFO - Stopping subprocess.
2023-10-17 17:58:37,962 - mineflayer - INFO - Starting subprocess with commands: ['node', 'd:\\workspace\\minecraft\\voyager\\voyager\\env\\mineflayer/index.js', '3000']
2023-10-17 17:58:38,893 - mineflayer - INFO - Server started on port 3000
2023-10-17 17:58:38,893 - mineflayer - INFO - Subprocess is ready.
2023-10-17 17:58:38,934 - mineflayer - INFO - {
2023-10-17 17:58:38,934 - mineflayer - INFO - host: 'localhost',
2023-10-17 17:58:38,934 - mineflayer - INFO - port: 52633,
2023-10-17 17:58:38,934 - mineflayer - INFO - username: 'bot',
2023-10-17 17:58:38,935 - mineflayer - INFO - reset: 'hard',
2023-10-17 17:58:38,935 - mineflayer - INFO - inventory: {},
2023-10-17 17:58:38,938 - mineflayer - INFO - equipment: [],
2023-10-17 17:58:38,938 - mineflayer - INFO - spread: false,
2023-10-17 17:58:38,938 - mineflayer - INFO - waitTicks: 20,
2023-10-17 17:58:38,938 - mineflayer - INFO - position: null
2023-10-17 17:58:38,938 - mineflayer - INFO - }
2023-10-17 17:58:51,700 - mineflayer - INFO - Stopping subprocess.
2023-10-17 17:58:52,749 - mineflayer - INFO - Starting subprocess with commands: ['node', 'd:\\workspace\\minecraft\\voyager\\voyager\\env\\mineflayer/index.js', '3000']
2023-10-17 17:58:53,649 - mineflayer - INFO - Server started on port 3000
2023-10-17 17:58:53,649 - mineflayer - INFO - Subprocess is ready.
2023-10-17 17:58:53,708 - mineflayer - INFO - {
2023-10-17 17:58:53,708 - mineflayer - INFO - host: 'localhost',
2023-10-17 17:58:53,708 - mineflayer - INFO - port: 52633,
2023-10-17 17:58:53,708 - mineflayer - INFO - username: 'bot',
2023-10-17 17:58:53,708 - mineflayer - INFO - reset: 'hard',
2023-10-17 17:58:53,708 - mineflayer - INFO - inventory: {},
2023-10-17 17:58:53,708 - mineflayer - INFO - equipment: [],
2023-10-17 17:58:53,708 - mineflayer - INFO - spread: false,
2023-10-17 17:58:53,708 - mineflayer - INFO - waitTicks: 20,
2023-10-17 17:58:53,708 - mineflayer - INFO - position: null
2023-10-17 17:58:53,708 - mineflayer - INFO - }
2023-10-17 18:10:43,443 - mineflayer - INFO - Stopping subprocess.
2023-10-17 18:10:44,449 - mineflayer - INFO - Starting subprocess with commands: ['node', 'd:\\workspace\\minecraft\\voyager\\voyager\\env\\mineflayer/index.js', '3000']
2023-10-17 18:10:45,388 - mineflayer - INFO - Server started on port 3000
2023-10-17 18:10:45,389 - mineflayer - INFO - Subprocess is ready.
2023-10-17 18:10:45,413 - mineflayer - INFO - {
2023-10-17 18:10:45,413 - mineflayer - INFO - host: 'localhost',
2023-10-17 18:10:45,413 - mineflayer - INFO - port: 52633,
2023-10-17 18:10:45,413 - mineflayer - INFO - username: 'bot',
2023-10-17 18:10:45,413 - mineflayer - INFO - reset: 'hard',
2023-10-17 18:10:45,414 - mineflayer - INFO - inventory: {},
2023-10-17 18:10:45,418 - mineflayer - INFO - equipment: [],
2023-10-17 18:10:45,418 - mineflayer - INFO - spread: false,
2023-10-17 18:10:45,418 - mineflayer - INFO - waitTicks: 20,
2023-10-17 18:10:45,418 - mineflayer - INFO - position: null
2023-10-17 18:10:45,418 - mineflayer - INFO - }
2023-10-17 18:16:58,031 - mineflayer - INFO - Stopping subprocess.
2023-10-17 18:16:59,033 - mineflayer - INFO - Starting subprocess with commands: ['node', 'd:\\workspace\\minecraft\\voyager\\voyager\\env\\mineflayer/index.js', '3000']
2023-10-17 18:17:00,058 - mineflayer - INFO - Server started on port 3000
2023-10-17 18:17:00,058 - mineflayer - INFO - Subprocess is ready.
2023-10-17 18:17:00,081 - mineflayer - INFO - {
2023-10-17 18:17:00,081 - mineflayer - INFO - host: 'localhost',
2023-10-17 18:17:00,081 - mineflayer - INFO - port: 52633,
2023-10-17 18:17:00,081 - mineflayer - INFO - username: 'bot',
2023-10-17 18:17:00,081 - mineflayer - INFO - reset: 'hard',
2023-10-17 18:17:00,081 - mineflayer - INFO - inventory: {},
2023-10-17 18:17:00,086 - mineflayer - INFO - equipment: [],
2023-10-17 18:17:00,086 - mineflayer - INFO - spread: false,
2023-10-17 18:17:00,086 - mineflayer - INFO - waitTicks: 20,
2023-10-17 18:17:00,086 - mineflayer - INFO - position: null
2023-10-17 18:17:00,087 - mineflayer - INFO - }
2023-10-17 18:19:42,308 - mineflayer - INFO - TypeError: Cannot read properties of undefined (reading 'distanceTo')
2023-10-17 18:19:42,308 - mineflayer - INFO - at eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:748:41)
2023-10-17 18:19:42,308 - mineflayer - INFO - at Array.sort (<anonymous>)
2023-10-17 18:19:42,308 - mineflayer - INFO - at build_house_wall (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:748:15)
2023-10-17 18:19:42,308 - mineflayer - INFO - at eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:763:7)
2023-10-17 18:19:42,308 - mineflayer - INFO - at eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:763:31)
2023-10-17 18:19:42,309 - mineflayer - INFO - at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19)
2023-10-17 18:19:42,309 - mineflayer - INFO - at d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:239:21
2023-10-17 18:19:42,309 - mineflayer - INFO - Your code:10
2023-10-17 18:19:42,309 - mineflayer - INFO - stoneBlocks.sort((a, b) => a.position.distanceTo(bot.entity.position) - b.position.distanceTo(bot.entity.position));
2023-10-17 18:19:42,309 - mineflayer - INFO - Cannot read properties of undefined (reading 'distanceTo')
2023-10-17 18:19:42,309 - mineflayer - INFO -
2023-10-17 18:20:21,314 - mineflayer - INFO - Error: placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:20:21,314 - mineflayer - INFO - at placeItem (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:375:19)
2023-10-17 18:20:21,314 - mineflayer - INFO - at build_house_roof (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:753:13)
2023-10-17 18:20:21,315 - mineflayer - INFO - at async eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:758:1)
2023-10-17 18:20:21,315 - mineflayer - INFO - at async evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:13)
2023-10-17 18:20:21,315 - mineflayer - INFO - at async d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:239:15
2023-10-17 18:20:21,315 - mineflayer - INFO - In your program code: throw new Error(
2023-10-17 18:20:21,315 - mineflayer - INFO - placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:20:21,315 - mineflayer - INFO - at line 15:await placeItem(bot, "stone", position); in your code
2023-10-17 18:30:50,473 - mineflayer - INFO - Stopping subprocess.
2023-10-17 18:30:51,481 - mineflayer - INFO - Starting subprocess with commands: ['node', 'd:\\workspace\\minecraft\\voyager\\voyager\\env\\mineflayer/index.js', '3000']
2023-10-17 18:30:52,562 - mineflayer - INFO - Server started on port 3000
2023-10-17 18:30:52,562 - mineflayer - INFO - Subprocess is ready.
2023-10-17 18:30:52,618 - mineflayer - INFO - {
2023-10-17 18:30:52,618 - mineflayer - INFO - host: 'localhost',
2023-10-17 18:30:52,618 - mineflayer - INFO - port: 52633,
2023-10-17 18:30:52,618 - mineflayer - INFO - username: 'bot',
2023-10-17 18:30:52,618 - mineflayer - INFO - reset: 'hard',
2023-10-17 18:30:52,618 - mineflayer - INFO - inventory: {},
2023-10-17 18:30:52,624 - mineflayer - INFO - equipment: [],
2023-10-17 18:30:52,624 - mineflayer - INFO - spread: false,
2023-10-17 18:30:52,624 - mineflayer - INFO - waitTicks: 20,
2023-10-17 18:30:52,624 - mineflayer - INFO - position: null
2023-10-17 18:30:52,624 - mineflayer - INFO - }
2023-10-17 18:32:59,397 - mineflayer - INFO - TypeError: Cannot read properties of undefined (reading 'offset')
2023-10-17 18:32:59,397 - mineflayer - INFO - at buildHouseWall (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:769:44)
2023-10-17 18:32:59,397 - mineflayer - INFO - at async eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:774:1)
2023-10-17 18:32:59,398 - mineflayer - INFO - at async evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:13)
2023-10-17 18:32:59,398 - mineflayer - INFO - at async d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:239:15
2023-10-17 18:32:59,398 - mineflayer - INFO - Your code:31
2023-10-17 18:32:59,398 - mineflayer - INFO - const position = stoneBlock.position.offset(0, y, 0);
2023-10-17 18:32:59,398 - mineflayer - INFO - Cannot read properties of undefined (reading 'offset')
2023-10-17 18:32:59,398 - mineflayer - INFO -
2023-10-17 18:33:36,331 - mineflayer - INFO - Error: placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:33:36,331 - mineflayer - INFO - at placeItem (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:375:19)
2023-10-17 18:33:36,331 - mineflayer - INFO - at build_house_roof (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:756:11)
2023-10-17 18:33:36,331 - mineflayer - INFO - at async eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:760:1)
2023-10-17 18:33:36,331 - mineflayer - INFO - at async evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:13)
2023-10-17 18:33:36,331 - mineflayer - INFO - at async d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:239:15
2023-10-17 18:33:36,331 - mineflayer - INFO - In your program code: throw new Error(
2023-10-17 18:33:36,331 - mineflayer - INFO - placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:33:36,331 - mineflayer - INFO - at line 18:await placeItem(bot, "stone", position); in your code
2023-10-17 18:38:37,372 - mineflayer - INFO - Stopping subprocess.
2023-10-17 18:38:38,388 - mineflayer - INFO - Starting subprocess with commands: ['node', 'd:\\workspace\\minecraft\\voyager\\voyager\\env\\mineflayer/index.js', '3000']
2023-10-17 18:38:39,390 - mineflayer - INFO - Server started on port 3000
2023-10-17 18:38:39,390 - mineflayer - INFO - Subprocess is ready.
2023-10-17 18:38:39,416 - mineflayer - INFO - {
2023-10-17 18:38:39,417 - mineflayer - INFO - host: 'localhost',
2023-10-17 18:38:39,417 - mineflayer - INFO - port: 52633,
2023-10-17 18:38:39,417 - mineflayer - INFO - username: 'bot',
2023-10-17 18:38:39,417 - mineflayer - INFO - reset: 'hard',
2023-10-17 18:38:39,417 - mineflayer - INFO - inventory: {},
2023-10-17 18:38:39,421 - mineflayer - INFO - equipment: [],
2023-10-17 18:38:39,422 - mineflayer - INFO - spread: false,
2023-10-17 18:38:39,422 - mineflayer - INFO - waitTicks: 20,
2023-10-17 18:38:39,422 - mineflayer - INFO - position: null
2023-10-17 18:38:39,422 - mineflayer - INFO - }
2023-10-17 18:40:50,375 - mineflayer - INFO - Error: placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:40:50,376 - mineflayer - INFO - at placeItem (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:375:19)
2023-10-17 18:40:50,376 - mineflayer - INFO - at buildHouseWall (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:745:15)
2023-10-17 18:40:50,376 - mineflayer - INFO - at async eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:751:1)
2023-10-17 18:40:50,376 - mineflayer - INFO - at async evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:13)
2023-10-17 18:40:50,376 - mineflayer - INFO - at async d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:239:15
2023-10-17 18:40:50,376 - mineflayer - INFO - In your program code: throw new Error(
2023-10-17 18:40:50,376 - mineflayer - INFO - placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:40:50,376 - mineflayer - INFO - at line 7:await placeItem(bot, "dirt", position.offset(0, y, 0)); in your code
2023-10-17 18:41:38,261 - mineflayer - INFO - Error: placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:41:38,261 - mineflayer - INFO - at placeItem (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:375:19)
2023-10-17 18:41:38,261 - mineflayer - INFO - at build_house_roof (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:754:13)
2023-10-17 18:41:38,261 - mineflayer - INFO - at async eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:770:1)
2023-10-17 18:41:38,261 - mineflayer - INFO - at async evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:13)
2023-10-17 18:41:38,261 - mineflayer - INFO - at async d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:239:15
2023-10-17 18:41:38,261 - mineflayer - INFO - In your program code: throw new Error(
2023-10-17 18:41:38,261 - mineflayer - INFO - placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:41:38,261 - mineflayer - INFO - at line 16:await placeItem(bot, "stone", position); in your code
2023-10-17 18:44:40,669 - mineflayer - INFO - Stopping subprocess.
2023-10-17 18:44:41,691 - mineflayer - INFO - Starting subprocess with commands: ['node', 'd:\\workspace\\minecraft\\voyager\\voyager\\env\\mineflayer/index.js', '3000']
2023-10-17 18:44:42,726 - mineflayer - INFO - Server started on port 3000
2023-10-17 18:44:42,726 - mineflayer - INFO - Subprocess is ready.
2023-10-17 18:44:42,761 - mineflayer - INFO - {
2023-10-17 18:44:42,761 - mineflayer - INFO - host: 'localhost',
2023-10-17 18:44:42,761 - mineflayer - INFO - port: 52633,
2023-10-17 18:44:42,761 - mineflayer - INFO - username: 'bot',
2023-10-17 18:44:42,761 - mineflayer - INFO - reset: 'hard',
2023-10-17 18:44:42,761 - mineflayer - INFO - inventory: {},
2023-10-17 18:44:42,765 - mineflayer - INFO - equipment: [],
2023-10-17 18:44:42,765 - mineflayer - INFO - spread: false,
2023-10-17 18:44:42,765 - mineflayer - INFO - waitTicks: 20,
2023-10-17 18:44:42,765 - mineflayer - INFO - position: null
2023-10-17 18:44:42,765 - mineflayer - INFO - }
2023-10-17 18:52:10,585 - mineflayer - INFO - Stopping subprocess.
2023-10-17 18:52:11,596 - mineflayer - INFO - Starting subprocess with commands: ['node', 'd:\\workspace\\minecraft\\voyager\\voyager\\env\\mineflayer/index.js', '3000']
2023-10-17 18:52:12,605 - mineflayer - INFO - Server started on port 3000
2023-10-17 18:52:12,606 - mineflayer - INFO - Subprocess is ready.
2023-10-17 18:52:12,633 - mineflayer - INFO - {
2023-10-17 18:52:12,633 - mineflayer - INFO - host: 'localhost',
2023-10-17 18:52:12,633 - mineflayer - INFO - port: 52633,
2023-10-17 18:52:12,633 - mineflayer - INFO - username: 'bot',
2023-10-17 18:52:12,633 - mineflayer - INFO - reset: 'hard',
2023-10-17 18:52:12,633 - mineflayer - INFO - inventory: {},
2023-10-17 18:52:12,637 - mineflayer - INFO - equipment: [],
2023-10-17 18:52:12,637 - mineflayer - INFO - spread: false,
2023-10-17 18:52:12,637 - mineflayer - INFO - waitTicks: 20,
2023-10-17 18:52:12,637 - mineflayer - INFO - position: null
2023-10-17 18:52:12,637 - mineflayer - INFO - }
2023-10-17 18:55:33,204 - mineflayer - INFO - Error: placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:55:33,204 - mineflayer - INFO - at placeItem (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:375:19)
2023-10-17 18:55:33,204 - mineflayer - INFO - at build_house_roof (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:754:13)
2023-10-17 18:55:33,204 - mineflayer - INFO - at async eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:759:1)
2023-10-17 18:55:33,204 - mineflayer - INFO - at async evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:13)
2023-10-17 18:55:33,204 - mineflayer - INFO - at async d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:239:15
2023-10-17 18:55:33,204 - mineflayer - INFO - In your program code: throw new Error(
2023-10-17 18:55:33,204 - mineflayer - INFO - placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:55:33,204 - mineflayer - INFO - at line 16:await placeItem(bot, "stone", position); in your code
2023-10-17 18:57:04,904 - mineflayer - INFO - Stopping subprocess.
2023-10-17 18:57:05,918 - mineflayer - INFO - Starting subprocess with commands: ['node', 'd:\\workspace\\minecraft\\voyager\\voyager\\env\\mineflayer/index.js', '3000']
2023-10-17 18:57:06,845 - mineflayer - INFO - Server started on port 3000
2023-10-17 18:57:06,845 - mineflayer - INFO - Subprocess is ready.
2023-10-17 18:57:06,874 - mineflayer - INFO - {
2023-10-17 18:57:06,874 - mineflayer - INFO - host: 'localhost',
2023-10-17 18:57:06,874 - mineflayer - INFO - port: 52633,
2023-10-17 18:57:06,874 - mineflayer - INFO - username: 'bot',
2023-10-17 18:57:06,874 - mineflayer - INFO - reset: 'hard',
2023-10-17 18:57:06,874 - mineflayer - INFO - inventory: {},
2023-10-17 18:57:06,879 - mineflayer - INFO - equipment: [],
2023-10-17 18:57:06,879 - mineflayer - INFO - spread: false,
2023-10-17 18:57:06,879 - mineflayer - INFO - waitTicks: 20,
2023-10-17 18:57:06,879 - mineflayer - INFO - position: null
2023-10-17 18:57:06,879 - mineflayer - INFO - }
2023-10-17 18:59:22,317 - mineflayer - INFO - Error: placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:59:22,317 - mineflayer - INFO - at placeItem (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:375:19)
2023-10-17 18:59:22,317 - mineflayer - INFO - at buildHouseWall (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:811:13)
2023-10-17 18:59:22,317 - mineflayer - INFO - at async eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:815:1)
2023-10-17 18:59:22,317 - mineflayer - INFO - at async evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:13)
2023-10-17 18:59:22,317 - mineflayer - INFO - at async d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:239:15
2023-10-17 18:59:22,318 - mineflayer - INFO - In your program code: throw new Error(
2023-10-17 18:59:22,318 - mineflayer - INFO - placeItem failed too many times. You cannot place a floating block.
2023-10-17 18:59:22,318 - mineflayer - INFO - at line 73:await placeItem(bot, "dirt", position); in your code
2023-10-17 19:00:01,700 - mineflayer - INFO - Error: placeItem failed too many times. You cannot place a floating block.
2023-10-17 19:00:01,700 - mineflayer - INFO - at placeItem (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:375:19)
2023-10-17 19:00:01,700 - mineflayer - INFO - at build_house_roof (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:756:11)
2023-10-17 19:00:01,700 - mineflayer - INFO - at async eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:760:1)
2023-10-17 19:00:01,700 - mineflayer - INFO - at async evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:13)
2023-10-17 19:00:01,700 - mineflayer - INFO - at async d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:239:15
2023-10-17 19:00:01,700 - mineflayer - INFO - In your program code: throw new Error(
2023-10-17 19:00:01,701 - mineflayer - INFO - placeItem failed too many times. You cannot place a floating block.
2023-10-17 19:00:01,701 - mineflayer - INFO - at line 18:await placeItem(bot, "stone", position); in your code
2023-10-17 19:02:56,344 - mineflayer - INFO - Stopping subprocess.
2023-10-17 19:02:57,352 - mineflayer - INFO - Starting subprocess with commands: ['node', 'd:\\workspace\\minecraft\\voyager\\voyager\\env\\mineflayer/index.js', '3000']
2023-10-17 19:02:58,296 - mineflayer - INFO - Server started on port 3000
2023-10-17 19:02:58,296 - mineflayer - INFO - Subprocess is ready.
2023-10-17 19:02:58,326 - mineflayer - INFO - {
2023-10-17 19:02:58,326 - mineflayer - INFO - host: 'localhost',
2023-10-17 19:02:58,326 - mineflayer - INFO - port: 52633,
2023-10-17 19:02:58,326 - mineflayer - INFO - username: 'bot',
2023-10-17 19:02:58,326 - mineflayer - INFO - reset: 'hard',
2023-10-17 19:02:58,326 - mineflayer - INFO - inventory: {},
2023-10-17 19:02:58,330 - mineflayer - INFO - equipment: [],
2023-10-17 19:02:58,330 - mineflayer - INFO - spread: false,
2023-10-17 19:02:58,330 - mineflayer - INFO - waitTicks: 20,
2023-10-17 19:02:58,330 - mineflayer - INFO - position: null
2023-10-17 19:02:58,330 - mineflayer - INFO - }
2023-10-17 19:05:12,548 - mineflayer - INFO - Error: placeItem failed too many times, please find another position to place.
2023-10-17 19:05:12,548 - mineflayer - INFO - at placeItem (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:399:23)
2023-10-17 19:05:12,548 - mineflayer - INFO - at async build_house_foundation (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:754:7)
2023-10-17 19:05:12,548 - mineflayer - INFO - at async eval (eval at evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:19), <anonymous>:759:1)
2023-10-17 19:05:12,548 - mineflayer - INFO - at async evaluateCode (d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:256:13)
2023-10-17 19:05:12,548 - mineflayer - INFO - at async d:\workspace\minecraft\voyager\voyager\env\mineflayer\index.js:239:15
2023-10-17 19:05:12,550 - mineflayer - INFO - In your program code: throw new Error(
2023-10-17 19:05:12,550 - mineflayer - INFO - placeItem failed too many times, please find another position to place.
2023-10-17 19:05:12,550 - mineflayer - INFO - at line 16:await placeItem(bot, "stone", position); in your code
from llm import llm_code
from pathlib import Path from pathlib import Path
import json import json
import asyncio import asyncio
...@@ -6,14 +5,17 @@ import asyncio ...@@ -6,14 +5,17 @@ import asyncio
dest_lib = Path("./descriptions") dest_lib = Path("./descriptions")
fun_lib = Path("./js") fun_lib = Path("./js")
async def synthesis_1(fun_name): def synthesis_1(fun_name):
from llm import llm_code
dest_path = dest_lib / f"{fun_name}.json" dest_path = dest_lib / f"{fun_name}.json"
fun_path = fun_lib / f"{fun_name}.js" fun_path = fun_lib / f"{fun_name}.js"
with open(dest_path, "r") as f: with open(dest_path, "r") as f:
dest = json.load(f) dest = json.load(f)
if dest["state"] == "x": # modified to True by hd
code = await llm_code(fun_name, dest["doc"]) if dest["state"] == "x" or True:
code = llm_code(fun_name, dest["doc"])
code = '\n'.join(code.split('\n')[:-1])
code += f"\nexports.{fun_name} = {fun_name};" code += f"\nexports.{fun_name} = {fun_name};"
with open(fun_path, "w") as f: with open(fun_path, "w") as f:
f.write(code) f.write(code)
...@@ -23,20 +25,20 @@ async def synthesis_1(fun_name): ...@@ -23,20 +25,20 @@ async def synthesis_1(fun_name):
else: else:
print(f"{fun_name} has already been completed.") print(f"{fun_name} has already been completed.")
async def synthesis(): def synthesis():
names = [] names = []
for dest_path in dest_lib.glob("*.json"): for dest_path in dest_lib.glob("*.json"):
with open(dest_path, "r") as f: with open(dest_path, "r") as f:
dest = json.load(f) dest = json.load(f)
if dest["state"] == "x": if dest["state"] == "x":
names.append(dest_path.stem) names.append(dest_path.stem)
await asyncio.gather(*[synthesis_1(fun) for fun in names]) [synthesis_1(fun) for fun in names]
async def synthesis_1_inorder(fun_name): def synthesis_1_inorder(fun_name):
dest_path = dest_lib / f"{fun_name}.json" dest_path = dest_lib / f"{fun_name}.json"
with open(dest_path, "r") as f: with open(dest_path, "r") as f:
dependencies = json.load(f)["dependencies"] dependencies = json.load(f)["dependencies"]
for name in dependencies: for name in dependencies:
print(f"I am synthesizing {name}") print(f"I am synthesizing {name}")
await synthesis_1(name) synthesis_1(name)
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment