up
This commit is contained in:
30
src/command/ai.ts
Normal file
30
src/command/ai.ts
Normal 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();
|
||||
Reference in New Issue
Block a user