style: import

This commit is contained in:
RainbowBird
2025-01-18 19:08:07 +08:00
parent 8f74b65873
commit a550722aef
25 changed files with 33 additions and 8 deletions
@@ -1,5 +1,6 @@
import { messages, system, user } from 'neuri/openai'
import { beforeAll, describe, expect, it } from 'vitest'
import { initBot, useBot } from '../composables/bot'
import { botConfig, initEnv } from '../composables/config'
import { genActionAgentPrompt, genQueryAgentPrompt } from '../prompts/agent'
@@ -25,7 +26,6 @@ describe('actions agent', { timeout: 0 }, () => {
user('What\'s your status?'),
), async (c) => {
const completion = await c.reroute('query', c.messages, { model: 'openai/gpt-4o-mini' })
console.log(JSON.stringify(completion, null, 2))
return await completion?.firstContent()
})
@@ -48,16 +48,11 @@ describe('actions agent', { timeout: 0 }, () => {
system(genActionAgentPrompt(bot)),
user('goToPlayer: luoling8192'),
), async (c) => {
console.log(JSON.stringify(c, null, 2))
const completion = await c.reroute('action', c.messages, { model: 'openai/gpt-4o-mini' })
console.log(JSON.stringify(completion, null, 2))
return await completion?.firstContent()
})
console.log(JSON.stringify(text, null, 2))
expect(text?.toLowerCase()).toContain('goToPlayer')
await sleep(10000)
resolve()
+2
View File
@@ -1,6 +1,8 @@
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'
import { collectBlock } from '../skills/actions/collect-block'
@@ -1,5 +1,6 @@
import { messages, system, user } from 'neuri/openai'
import { beforeAll, describe, expect, it } from 'vitest'
import { initBot, useBot } from '../composables/bot'
import { botConfig, initEnv } from '../composables/config'
import { genSystemBasicPrompt } from '../prompts/agent'
+2
View File
@@ -1,7 +1,9 @@
import type { Agent, Neuri } from 'neuri'
import type { Mineflayer } from '../libs/mineflayer'
import { useLogg } from '@guiiai/logg'
import { agent, neuri } from 'neuri'
import { openaiConfig } from '../composables/config'
import { actionsList } from './actions'
@@ -1,4 +1,5 @@
import type { Agent } from './agent'
import { useLogg } from '@guiiai/logg'
type Fn = (...args: any[]) => void
@@ -1,4 +1,5 @@
import type { BotOptions } from 'mineflayer'
import { env } from 'node:process'
import { useLogg } from '@guiiai/logg'
@@ -1,4 +1,5 @@
import type { Agent } from './agent'
import { useLogg } from '@guiiai/logg'
let self_prompter_paused = false
@@ -3,7 +3,9 @@ import type { Entity } from 'prismarine-entity'
import type { Item } from 'prismarine-item'
import type { Vec3 } from 'vec3'
import type { Mineflayer } from '../libs/mineflayer'
import pf from 'mineflayer-pathfinder'
import * as mc from '../utils/mcdata'
export function getNearestFreeSpace(
@@ -1,9 +1,11 @@
import type { Bot, BotOptions } from 'mineflayer'
import type { MineflayerPlugin } from './plugin'
import type { EventHandlers, EventsHandler } from './types'
import { type Logg, useLogg } from '@guiiai/logg'
import EventEmitter from 'eventemitter3'
import mineflayer from 'mineflayer'
import { parseCommand } from './command'
import { Components } from './components'
import { Health } from './health'
-1
View File
@@ -1,5 +1,4 @@
import process, { exit } from 'node:process'
import { useLogg } from '@guiiai/logg'
import { Client } from '@proj-airi/server-sdk'
import MineflayerArmorManager from 'mineflayer-armor-manager'
@@ -1,6 +1,7 @@
import type { MineflayerPlugin } from '../libs/mineflayer/plugin'
import { useLogg } from '@guiiai/logg'
import { formBotChat } from '../libs/mineflayer/message'
export function Echo(): MineflayerPlugin {
@@ -1,4 +1,5 @@
import type { MineflayerPlugin } from '../libs/mineflayer/plugin'
import { useLogg } from '@guiiai/logg'
import pathfinderModel from 'mineflayer-pathfinder'
@@ -1,6 +1,7 @@
import type { Client } from '@proj-airi/server-sdk'
import type { Neuri, NeuriContext } from 'neuri'
import type { MineflayerPlugin } from '../libs/mineflayer/plugin'
import { useLogg } from '@guiiai/logg'
import { assistant, system, user } from 'neuri/openai'
@@ -1,4 +1,5 @@
import type { MineflayerPlugin } from '../libs/mineflayer/plugin'
import { useLogg } from '@guiiai/logg'
export function Status(): MineflayerPlugin {
+1
View File
@@ -1,4 +1,5 @@
import type { Mineflayer } from '../libs/mineflayer'
import { listInventory } from '../skills/actions/inventory'
export function genSystemBasicPrompt(botName: string): string {
@@ -1,7 +1,9 @@
import type { Block } from 'prismarine-block'
import type { Mineflayer } from '../../libs/mineflayer'
import { useLogg } from '@guiiai/logg'
import pathfinder from 'mineflayer-pathfinder'
import { getNearestBlocks } from '../../composables/world'
import { breakBlockAt } from '../blocks'
import { ensurePickaxe } from './ensure'
@@ -1,5 +1,7 @@
import type { Mineflayer } from '../../libs/mineflayer'
import { useLogg } from '@guiiai/logg'
import { getItemId } from '../../utils/mcdata'
import { craftRecipe } from '../crafting'
import { moveAway } from '../movement'
@@ -1,5 +1,7 @@
import type { Mineflayer } from '../../libs/mineflayer'
import { useLogg } from '@guiiai/logg'
import { getNearestBlocks } from '../../composables/world'
import { sleep } from '../../utils/helper'
import { breakBlockAt } from '../blocks'
@@ -2,6 +2,7 @@ import type { Item } from 'prismarine-item'
import type { Mineflayer } from '../../libs/mineflayer'
import { useLogg } from '@guiiai/logg'
import { getNearestBlock } from '../../composables/world'
import { goToPlayer, goToPosition } from '../movement'
@@ -1,9 +1,11 @@
import type { Bot } from 'mineflayer'
import type { Block } from 'prismarine-block'
import type { Mineflayer } from '../../libs/mineflayer'
import { useLogg } from '@guiiai/logg'
import pathfinder from 'mineflayer-pathfinder'
import { Vec3 } from 'vec3'
import { sleep } from '../../utils/helper'
import { getNearestBlock, makeItem } from '../../utils/mcdata'
import { goToPosition } from '../movement'
+1
View File
@@ -1,4 +1,5 @@
import type { Mineflayer } from '../libs/mineflayer'
import { useLogg } from '@guiiai/logg'
const logger = useLogg('skills').useGlobalConfig()
+1
View File
@@ -3,6 +3,7 @@ import type { BlockFace } from './base'
import pathfinderModel, { type SafeBlock } from 'mineflayer-pathfinder'
import { Vec3 } from 'vec3'
import { getNearestBlock, getNearestBlocks, getPosition, shouldPlaceTorch } from '../composables/world'
import { getBlockId, makeItem } from '../utils/mcdata'
import { log } from './base'
@@ -1,4 +1,5 @@
import type { Mineflayer } from '../libs/mineflayer'
import { getNearestBlock } from '../composables/world'
import { log } from './base'
import { goToPlayer, goToPosition } from './movement'
@@ -5,6 +5,7 @@ import { useLogg } from '@guiiai/logg'
import { randomInt } from 'es-toolkit'
import pathfinder from 'mineflayer-pathfinder'
import { Vec3 } from 'vec3'
import { getNearestBlock, getNearestEntityWhere } from '../composables/world'
import { sleep } from '../utils/helper'
import { log } from './base'
+1
View File
@@ -2,6 +2,7 @@
import type { Bot } from 'mineflayer'
import type { Entity } from 'prismarine-entity'
import minecraftData, {
type Biome,
type ShapedRecipe,