This commit is contained in:
parent
1e239ef9ff
commit
643e039bd8
1 changed files with 10 additions and 10 deletions
|
|
@ -15,21 +15,21 @@ async function chatWithAI(prompt, aiConfig) {
|
|||
|
||||
async function generateAndSaveTask(taskName, aiConfig) {
|
||||
const prompt = `
|
||||
You are an AI assistant in a Minecraft world. The player wants a new bot task called "${taskName}".
|
||||
Return only the Node.js code for a module that exports an async function with this signature:
|
||||
\`\`\`js
|
||||
module.exports = async function(bot, db, say) {
|
||||
// Implement the logic here
|
||||
};
|
||||
\`\`\`
|
||||
Only return valid JavaScript. Do not include explanation or extra text.
|
||||
`.trim();
|
||||
You are generating a Minecraft Mineflayer bot task. The task name is: "${taskName}".
|
||||
|
||||
You must return only a valid Node.js module that:
|
||||
- Exports: \`module.exports = async function(bot, db, say) { ... }\`
|
||||
- Uses only valid Mineflayer API methods.
|
||||
- Do NOT use \`bot.inventory.find()\`. Use \`bot.inventory.items().find(...)\` instead.
|
||||
- If accessing blocks, use \`bot.findBlock()\`, \`bot.blockAt()\`, or \`bot.openBlock()\`.
|
||||
- Only respond with valid JavaScript code. No comments or markdown.
|
||||
`.trim();
|
||||
|
||||
try {
|
||||
const response = await chatWithAI(prompt, aiConfig);
|
||||
let taskCode = response.trim();
|
||||
|
||||
// Strip surrounding triple backticks if present
|
||||
// Remove wrapping backticks if present
|
||||
if (taskCode.startsWith('```')) {
|
||||
taskCode = taskCode.replace(/```[a-z]*\n?/i, '').replace(/```$/, '').trim();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue