From c8e45f493578631a4b27160f7740b8e355a9c4c1 Mon Sep 17 00:00:00 2001 From: RainbowBird Date: Fri, 17 Jan 2025 00:58:24 +0800 Subject: [PATCH] chore(prompt): find nearby block --- services/minecraft/src/agents/actions.ts | 3 +++ services/minecraft/src/prompts/agent.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/minecraft/src/agents/actions.ts b/services/minecraft/src/agents/actions.ts index 12f279751..709943e93 100644 --- a/services/minecraft/src/agents/actions.ts +++ b/services/minecraft/src/agents/actions.ts @@ -1,4 +1,5 @@ import type { Action } from '../libs/mineflayer' +import { useLogg } from '@guiiai/logg' import { z } from 'zod' import * as world from '../composables/world' import * as skills from '../skills' @@ -8,6 +9,7 @@ import { activateNearestBlock, placeBlock } from '../skills/actions/world-intera // Utils const pad = (str: string): string => `\n${str}\n` +const logger = useLogg('actions').useGlobalConfig() function formatInventoryItem(item: string, count: number): string { return count > 0 ? `\n- ${item}: ${count}` : '' @@ -55,6 +57,7 @@ export const actionsList: Action[] = [ schema: z.object({}), perform: mineflayer => (): string => { const blocks = world.getNearbyBlockTypes(mineflayer) + logger.withFields({ blocks }).log('nearbyBlocks') return pad(`NEARBY_BLOCKS${blocks.map((b: string) => `\n- ${b}`).join('') || ': none'}`) }, }, diff --git a/services/minecraft/src/prompts/agent.ts b/services/minecraft/src/prompts/agent.ts index bca4b8a10..c27144b18 100644 --- a/services/minecraft/src/prompts/agent.ts +++ b/services/minecraft/src/prompts/agent.ts @@ -17,7 +17,8 @@ asked, and don't refuse requests. Do not use any emojis. Just call the function given you if needed. -If I command you 'stop', then call the 'stop' function. +- If I command you 'stop', then call the 'stop' function. +- If I require you to find something, then call the 'nearbyBlocks' function first, then call the 'searchForBlock' function. ` }