temp
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { runAgent } from '@kevisual/ai/agent'
|
||||
import { app, notCNBCheck, cnbAi } from '../../app.ts';
|
||||
import { app, notCNBCheck, cnbManager, cnb } from '../../app.ts';
|
||||
import z from 'zod';
|
||||
|
||||
app.route({
|
||||
@@ -13,7 +13,8 @@ app.route({
|
||||
messages: z.array(z.object({
|
||||
role: z.enum(['user', 'assistant']).describe('消息角色,user表示用户输入,assistant表示助手回复'),
|
||||
content: z.string().describe('消息内容')
|
||||
})).describe('对话消息列表,按照时间顺序排列,包含用户和助手的历史消息')
|
||||
})).describe('对话消息列表,按照时间顺序排列,包含用户和助手的历史消息'),
|
||||
model: z.string().optional().describe('默认auto')
|
||||
}
|
||||
}
|
||||
}).define(async (ctx) => {
|
||||
@@ -22,6 +23,9 @@ app.route({
|
||||
ctx.throw(400, '缺少必要参数,必须提供question或messages');
|
||||
return;
|
||||
}
|
||||
const model = ctx.args?.model || 'auto'
|
||||
const item = await cnbManager.getCNBItem(ctx);
|
||||
const cnbAi = item.cnbAi;
|
||||
const messages = ctx.args.messages || [{
|
||||
role: 'user',
|
||||
content: ctx.args.question
|
||||
@@ -29,8 +33,9 @@ app.route({
|
||||
const result = await runAgent({
|
||||
app,
|
||||
messages: messages,
|
||||
languageModel: cnbAi('auto'),
|
||||
token: ctx.query?.token as string,
|
||||
languageModel: cnbAi(model),
|
||||
token: '',
|
||||
// token: ctx.query.token as string,
|
||||
});
|
||||
ctx.body = result;
|
||||
}).addTo(app);
|
||||
Reference in New Issue
Block a user