chore: remove xsai

This commit is contained in:
RainbowBird
2025-01-06 18:56:54 +08:00
parent 337117fccb
commit ebf9223d6c
2 changed files with 54 additions and 53 deletions
+52 -52
View File
@@ -1,8 +1,8 @@
import type { BotContext } from 'src/bot'
import type { Agent, Neuri } from 'neuri'
import { useLogg } from '@guiiai/logg'
import { tool } from 'xsai'
import { createQueryAgentBotContext, queryList } from './queries'
import { agent, neuri } from 'neuri'
import { openaiConfig } from '../composables/config'
import { queryList } from './queries'
// Types
interface AgentBotContext {
@@ -15,60 +15,60 @@ const agents = new Set<Agent | Promise<Agent>>()
const logger = useLogg('openai').useGlobalConfig()
// Agent initialization
// export async function initAgent(): Promise<Neuri> {
// logger.log('Initializing agent')
// let n = neuri()
// agents.add(initQueryAgent())
// agents.forEach(agent => n = n.agent(agent))
// return n.build({
// provider: {
// apiKey: openaiConfig.apiKey,
// baseURL: openaiConfig.baseUrl,
// },
// })
// }
// export async function initQueryAgent(): Promise<Agent> {
// logger.log('Initializing query agent')
// let queryAgent = agent('query')
// queryList.forEach((query) => {
// queryAgent = queryAgent.tool(
// query.name,
// query.schema,
// query.perform,
// { description: query.description },
// )
// })
// return queryAgent.build()
// }
export async function initAgent(ctx: BotContext) {
export async function initAgent(): Promise<Neuri> {
logger.log('Initializing agent')
let n = neuri()
initQueryAgent(ctx)
agents.add(initQueryAgent())
agents.forEach(agent => n = n.agent(agent))
return n.build({
provider: {
apiKey: openaiConfig.apiKey,
baseURL: openaiConfig.baseUrl,
},
})
}
export function initQueryAgent(ctx: BotContext) {
export async function initQueryAgent(): Promise<Agent> {
logger.log('Initializing query agent')
const agentBotContext = createQueryAgentBotContext(ctx.bot)
let queryAgent = agent('query')
const tools = []
for (const query of queryList) {
tools.push(
tool({
name: query.name,
description: query.description,
execute: query.perform(agentBotContext),
parameters: query.schema as never,
}),
queryList.forEach((query) => {
queryAgent = queryAgent.tool(
query.name,
query.schema,
query.perform,
{ description: query.description },
)
}
})
return tools
return queryAgent.build()
}
// export async function initAgent(ctx: BotContext) {
// logger.log('Initializing agent')
// initQueryAgent(ctx)
// }
// export function initQueryAgent(ctx: BotContext) {
// logger.log('Initializing query agent')
// const agentBotContext = createQueryAgentBotContext(ctx.bot)
// const tools = []
// for (const query of queryList) {
// tools.push(
// tool({
// name: query.name,
// description: query.description,
// execute: query.perform(agentBotContext),
// parameters: query.schema as never,
// }),
// )
// }
// return tools
// }
+2 -1
View File
@@ -2,6 +2,7 @@ import process from 'node:process'
import { Format, LogLevel, setGlobalFormat, setGlobalLogLevel, useLogg } from '@guiiai/logg'
import { initAgent } from './agents/openai'
import { createCommandComponent } from './components/command'
import { createFollowComponent } from './components/follow'
import { createPathFinderComponent } from './components/pathfinder'
@@ -28,7 +29,7 @@ async function main() {
registerComponent('command', createCommandComponent)
})
// initAgent(ctx)
// initAgent()
process.on('SIGINT', () => {
cleanup()