Files
app/test/common.ts
2025-12-08 16:41:04 +08:00

33 lines
964 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);