feat: add AI provider support and documentation

- Update version to 0.0.2
- Add mod.ts to package files
- Support multiple AI providers via config.provider field
- Add qwen integration example in documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-09 22:27:31 +08:00
parent 18ed03da01
commit e9c626c590
3 changed files with 25 additions and 5 deletions

View File

@@ -1,13 +1,14 @@
{ {
"name": "@kevisual/app", "name": "@kevisual/app",
"version": "0.0.1", "version": "0.0.2",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"dev": "bun" "dev": "bun"
}, },
"files": [ "files": [
"src" "src",
"mod.ts"
], ],
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"

View File

@@ -6,4 +6,17 @@
当调用外部系统的时候,通过 auth token 去获取自己的对应的外部系统的 token然后再调用外部系统的接口。 当调用外部系统的时候,通过 auth token 去获取自己的对应的外部系统的 token然后再调用外部系统的接口。
## ## 举个例子,我要用 qwen 的接口
qwen 在我的系统中的存储的配置是 qwen.json
目的是纯前端快速访问页面, 因为要快速生成页面
```ts
const app = new App({token});
const config = await app.getConfig('qwen.json');
const qwen = new Qwen({token: config.token});
const response = await qwen.chat({messages: [...]});
console.log(response);
```

View File

@@ -1,7 +1,7 @@
import { QueryRouterServer } from '@kevisual/router' import { QueryRouterServer } from '@kevisual/router'
import { use } from '@kevisual/context' import { use } from '@kevisual/context'
import { Query } from '@kevisual/query' import { Query } from '@kevisual/query'
import { Kevisual } from '@kevisual/ai' import { Kevisual, ChatProviderMap } from '@kevisual/ai'
import mitt from 'mitt'; import mitt from 'mitt';
const isBrowser = typeof window !== 'undefined' const isBrowser = typeof window !== 'undefined'
@@ -57,7 +57,13 @@ export class App {
try { try {
const config = await this.getConfig('ai.json'); const config = await this.getConfig('ai.json');
if (config.token) { if (config.token) {
this.ai = new Kevisual(config); if (config.provider) {
const provider = config.provider;
// @ts-ignore
this.ai = ChatProviderMap[provider] ? new ChatProviderMap[provider](config) : new Kevisual(config);
} else {
this.ai = new Kevisual(config);
}
} }
} catch (e) { } } catch (e) { }
this.emitter.emit('ai-inited'); this.emitter.emit('ai-inited');