diff --git a/services/minecraft/src/agents/action/llm-handler.test.ts b/services/minecraft/src/agents/action/llm-handler.test.ts index 8568e1033..08c9cf303 100644 --- a/services/minecraft/src/agents/action/llm-handler.test.ts +++ b/services/minecraft/src/agents/action/llm-handler.test.ts @@ -5,7 +5,7 @@ import { initBot, useBot } from '../../composables/bot' import { botConfig, initEnv, openaiConfig } from '../../composables/config' import { createNeuriAgent } from '../../composables/neuri' import { initLogger } from '../../utils/logger' -import { generateSystemBasicPrompt } from '../prompt/llm-agent.plugin' +import { generateSystemBasicPrompt } from '../prompt/llm-agent' describe('openAI agent', { timeout: 0 }, () => { beforeAll(() => { diff --git a/services/minecraft/src/agents/action/llm-handler.ts b/services/minecraft/src/agents/action/llm-handler.ts index 1cdf7474f..a104eb04d 100644 --- a/services/minecraft/src/agents/action/llm-handler.ts +++ b/services/minecraft/src/agents/action/llm-handler.ts @@ -7,7 +7,7 @@ import { useLogg } from '@guiiai/logg' import { agent } from 'neuri' import { system, user } from 'neuri/openai' -import { BaseLLMHandler } from '../../libs/llm/base' +import { BaseLLMHandler } from '../../libs/llm-agent/handler' import { actionsList } from './tools' export async function createActionNeuriAgent(mineflayer: Mineflayer): Promise { diff --git a/services/minecraft/src/agents/action/tools.test.ts b/services/minecraft/src/agents/action/tools.test.ts index fe166a6e1..1f6add120 100644 --- a/services/minecraft/src/agents/action/tools.test.ts +++ b/services/minecraft/src/agents/action/tools.test.ts @@ -6,7 +6,7 @@ import { botConfig, initEnv, openaiConfig } from '../../composables/config' import { createNeuriAgent } from '../../composables/neuri' import { sleep } from '../../utils/helper' import { initLogger } from '../../utils/logger' -import { generateActionAgentPrompt } from '../prompt/llm-agent.plugin' +import { generateActionAgentPrompt } from '../prompt/llm-agent' describe('actions agent', { timeout: 0 }, () => { beforeAll(() => { diff --git a/services/minecraft/src/agents/chat/llm-handler.ts b/services/minecraft/src/agents/chat/llm-handler.ts index 7743a8fed..2803c2938 100644 --- a/services/minecraft/src/agents/chat/llm-handler.ts +++ b/services/minecraft/src/agents/chat/llm-handler.ts @@ -2,7 +2,7 @@ import type { ChatHistory } from './types' import { system, user } from 'neuri/openai' -import { BaseLLMHandler } from '../../libs/llm/base' +import { BaseLLMHandler } from '../../libs/llm-agent/handler' import { genChatAgentPrompt } from '../prompt/chat' export class ChatLLMHandler extends BaseLLMHandler { diff --git a/services/minecraft/src/agents/planning/llm-handler.ts b/services/minecraft/src/agents/planning/llm-handler.ts index 81d9a4e68..01be58d54 100644 --- a/services/minecraft/src/agents/planning/llm-handler.ts +++ b/services/minecraft/src/agents/planning/llm-handler.ts @@ -4,7 +4,7 @@ import type { Action } from '../../libs/mineflayer/action' import { agent } from 'neuri' import { system, user } from 'neuri/openai' -import { BaseLLMHandler } from '../../libs/llm/base' +import { BaseLLMHandler } from '../../libs/llm-agent/handler' import { generatePlanningAgentSystemPrompt, generatePlanningAgentUserPrompt } from '../prompt/planning' export async function createPlanningNeuriAgent(): Promise { diff --git a/services/minecraft/src/agents/prompt/llm-agent.plugin.ts b/services/minecraft/src/agents/prompt/llm-agent.ts similarity index 100% rename from services/minecraft/src/agents/prompt/llm-agent.plugin.ts rename to services/minecraft/src/agents/prompt/llm-agent.ts diff --git a/services/minecraft/src/container.ts b/services/minecraft/src/container.ts index 97fae1116..44da5cdec 100644 --- a/services/minecraft/src/container.ts +++ b/services/minecraft/src/container.ts @@ -60,6 +60,8 @@ export function createAppContainer(options: { agent: options.neuri, model: options.model, }, + maxHistoryLength: 50, + idleTimeout: 5 * 60 * 1000, // 5 minutes })), }) diff --git a/services/minecraft/src/plugins/llm-agent/chat.ts b/services/minecraft/src/libs/llm-agent/chat.ts similarity index 99% rename from services/minecraft/src/plugins/llm-agent/chat.ts rename to services/minecraft/src/libs/llm-agent/chat.ts index e993e1b7c..08fc7a74a 100644 --- a/services/minecraft/src/plugins/llm-agent/chat.ts +++ b/services/minecraft/src/libs/llm-agent/chat.ts @@ -4,7 +4,7 @@ import type { MineflayerWithAgents } from './type' import { system, user } from 'neuri/openai' -import { generateStatusPrompt } from '../../agents/prompt/llm-agent.plugin' +import { generateStatusPrompt } from '../../agents/prompt/llm-agent' import { toRetriable } from '../../utils/helper' import { handleLLMCompletion } from './completion' diff --git a/services/minecraft/src/plugins/llm-agent/completion.ts b/services/minecraft/src/libs/llm-agent/completion.ts similarity index 100% rename from services/minecraft/src/plugins/llm-agent/completion.ts rename to services/minecraft/src/libs/llm-agent/completion.ts diff --git a/services/minecraft/src/libs/llm/base.ts b/services/minecraft/src/libs/llm-agent/handler.ts similarity index 100% rename from services/minecraft/src/libs/llm/base.ts rename to services/minecraft/src/libs/llm-agent/handler.ts diff --git a/services/minecraft/src/plugins/llm-agent/index.ts b/services/minecraft/src/libs/llm-agent/index.ts similarity index 93% rename from services/minecraft/src/plugins/llm-agent/index.ts rename to services/minecraft/src/libs/llm-agent/index.ts index ae2fb7bd6..c2cabaa8b 100644 --- a/services/minecraft/src/plugins/llm-agent/index.ts +++ b/services/minecraft/src/libs/llm-agent/index.ts @@ -1,13 +1,13 @@ -import type { MineflayerPlugin } from '../../libs/mineflayer' +import type { MineflayerPlugin } from '../mineflayer' import type { LLMAgentOptions, MineflayerWithAgents } from './type' import { useLogg } from '@guiiai/logg' import { system } from 'neuri/openai' -import { generateActionAgentPrompt } from '../../agents/prompt/llm-agent.plugin' +import { generateActionAgentPrompt } from '../../agents/prompt/llm-agent' import { openaiConfig } from '../../composables/config' import { createAppContainer } from '../../container' -import { ChatMessageHandler } from '../../libs/mineflayer' +import { ChatMessageHandler } from '../mineflayer' import { handleChatMessage } from './chat' import { handleVoiceInput } from './voice' diff --git a/services/minecraft/src/plugins/llm-agent/type.ts b/services/minecraft/src/libs/llm-agent/type.ts similarity index 65% rename from services/minecraft/src/plugins/llm-agent/type.ts rename to services/minecraft/src/libs/llm-agent/type.ts index d5444a130..a96345021 100644 --- a/services/minecraft/src/plugins/llm-agent/type.ts +++ b/services/minecraft/src/libs/llm-agent/type.ts @@ -1,7 +1,7 @@ import type { Client } from '@proj-airi/server-sdk' import type { Neuri } from 'neuri' -import type { Mineflayer } from '../../libs/mineflayer' -import type { ActionAgent, ChatAgent, PlanningAgent } from '../../libs/mineflayer/base-agent' +import type { Mineflayer } from '../mineflayer' +import type { ActionAgent, ChatAgent, PlanningAgent } from '../mineflayer/base-agent' export interface MineflayerWithAgents extends Mineflayer { planning: PlanningAgent diff --git a/services/minecraft/src/libs/llm/types.ts b/services/minecraft/src/libs/llm-agent/types.ts similarity index 100% rename from services/minecraft/src/libs/llm/types.ts rename to services/minecraft/src/libs/llm-agent/types.ts diff --git a/services/minecraft/src/plugins/llm-agent/voice.ts b/services/minecraft/src/libs/llm-agent/voice.ts similarity index 99% rename from services/minecraft/src/plugins/llm-agent/voice.ts rename to services/minecraft/src/libs/llm-agent/voice.ts index ff1ad5010..0b07cdcb8 100644 --- a/services/minecraft/src/plugins/llm-agent/voice.ts +++ b/services/minecraft/src/libs/llm-agent/voice.ts @@ -4,7 +4,7 @@ import type { MineflayerWithAgents } from './type' import { system, user } from 'neuri/openai' -import { generateStatusPrompt } from '../../agents/prompt/llm-agent.plugin' +import { generateStatusPrompt } from '../../agents/prompt/llm-agent' import { toRetriable } from '../../utils/helper' import { handleLLMCompletion } from './completion' diff --git a/services/minecraft/src/main.ts b/services/minecraft/src/main.ts index 076471b5e..7afe316df 100644 --- a/services/minecraft/src/main.ts +++ b/services/minecraft/src/main.ts @@ -11,8 +11,8 @@ import { plugin as MineflayerTool } from 'mineflayer-tool' import { initBot } from './composables/bot' import { botConfig, initEnv } from './composables/config' import { createNeuriAgent } from './composables/neuri' +import { LLMAgent } from './libs/llm-agent' import { wrapPlugin } from './libs/mineflayer' -import { LLMAgent } from './plugins/llm-agent' import { initLogger } from './utils/logger' const logger = useLogg('main').useGlobalConfig()