20 lines
631 B
TypeScript
20 lines
631 B
TypeScript
import { CustomError } from '@abearxiong/router';
|
|
import { app } from '../app.ts';
|
|
// import { agent, HumanMessage } from '../agent/index.ts';
|
|
import { agentManger } from '../module/agent.ts';
|
|
app
|
|
.route('ai', 'chat')
|
|
.define(async (ctx) => {
|
|
const { message, agentId, chatId } = ctx.query.data;
|
|
// const response = await agent.invoke({ messages: [new HumanMessage(message)] }, { configurable: { thread_id: '44' } });
|
|
// ctx.body = response;
|
|
//
|
|
const agent = agentManger.getAgent(agentId);
|
|
if (!agent) {
|
|
throw new CustomError('agent not found');
|
|
}
|
|
})
|
|
.addTo(app);
|
|
|
|
// app.router.parse({})
|