This commit is contained in:
2025-12-08 16:41:04 +08:00
commit 4e5f94c839
6 changed files with 230 additions and 0 deletions

33
test/common.ts Normal file
View File

@@ -0,0 +1,33 @@
import { App } from '../src/app.ts';
import { useConfig } from '@kevisual/use-config';
export const config = useConfig();
export const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
const time = Date.now();
const app = new App({ token: config.KEVISUAL_TOKEN || '' });
console.log('time to init app', Date.now() - time);
await app.loadAI();
console.log('app ai inited', Date.now() - time);
const router = app.router;
router.route({
description: '获取天气,返回天气情况',
}).define(async ctx => {
ctx.body = '今天天气晴朗气温25度适合出行。';
}).addTo(router)
router.route({
description: '获取新闻,返回最新新闻',
}).define(async (ctx) => {
ctx.body = '今天的头条新闻是:科技公司发布了最新的智能手机。';
}).addTo(router)
// await sleep(1000);
const run = await app.chat('今天的新闻');
console.log('run', run);
console.log('all done', Date.now() - time);