added task generation
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 23s
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 23s
This commit is contained in:
parent
2b5d49d5bc
commit
5f04f1344c
1 changed files with 17 additions and 1 deletions
|
|
@ -20,4 +20,20 @@ async function chatWithAI(message, overrides = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = { chatWithAI };
|
||||
async function generateAndSaveTask(taskName, aiConfig = config.ai) {
|
||||
const prompt = `Write a Mineflayer-compatible JavaScript task named "${taskName}".
|
||||
The function should be defined as: module.exports = async function(bot, db, say) {...}
|
||||
This task will be executed by an AI-powered Minecraft bot.
|
||||
Do not include explanation, only the code.`;
|
||||
|
||||
try {
|
||||
const code = await chatWithAI(prompt, aiConfig);
|
||||
const filePath = path.join(__dirname, '../bot-tasks', `${taskName}.js`);
|
||||
fs.writeFileSync(filePath, code, 'utf8');
|
||||
console.log(`[AI] Task file generated: ${filePath}`);
|
||||
} catch (err) {
|
||||
console.error('[TASK GENERATION ERROR]', err.message);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { chatWithAI, generateAndSaveTask };
|
||||
|
|
|
|||
Loading…
Reference in a new issue