refactor: move llm-agent to lib folder

This commit is contained in:
RainbowBird
2025-02-07 01:11:24 +08:00
parent 2171483b43
commit 31988e6964
15 changed files with 15 additions and 13 deletions
@@ -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(() => {
@@ -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<Agent> {
@@ -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(() => {
@@ -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 {
@@ -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<Agent> {
+2
View File
@@ -60,6 +60,8 @@ export function createAppContainer(options: {
agent: options.neuri,
model: options.model,
},
maxHistoryLength: 50,
idleTimeout: 5 * 60 * 1000, // 5 minutes
})),
})
@@ -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'
@@ -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'
@@ -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
@@ -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'
+1 -1
View File
@@ -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()