This commit is contained in:
2025-12-09 13:40:41 +08:00
parent 9127df2600
commit 5b83f7a6d1
9 changed files with 442 additions and 113 deletions

30
src/command/ai.ts Normal file
View File

@@ -0,0 +1,30 @@
import { App } from '@kevisual/app/src/app.ts';
import { storage } from '../module/query.ts';
export const runAIApp = async () => {
const token = storage.getItem('token') || '';
if (!token) {
console.log('Please login first.');
return;
}
const aiApp = new App({ token })
await aiApp.loadAI();
const router= aiApp.router;
router.route({
description: '今天的天气怎么样?',
}).define(async (ctx) => {
ctx.body = '今天的天气晴朗,适合外出活动!';
}).addTo(router)
router.route({
description: '当前时间是几点?',
}).define(async (ctx) => {
ctx.body = `当前时间是:${new Date().toLocaleTimeString()}`;
}).addTo(router)
const chat = await aiApp.chat('今天的天气怎么样?');
console.log('AI Response:', aiApp.ai.responseText);
console.log('chat', chat);
}
runAIApp();