@kevisual/ai 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-provider-browser.d.ts +8 -7
- package/dist/ai-provider-browser.js +3978 -4108
- package/dist/ai-provider.d.ts +8 -7
- package/dist/ai-provider.js +4454 -11148
- package/package.json +17 -17
- package/readme.md +1 -2
- package/src/provider/chat-adapter/dashscope.ts +1 -1
- package/src/provider/chat-adapter/open-router.ts +10 -0
- package/src/provider/chat-adapter/siliconflow.ts +2 -1
- package/src/provider/core/chat.ts +3 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/ai",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.9",
|
|
4
|
+
"description": "AI Center Services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"basename": "/root/ai-center-services",
|
|
7
7
|
"app": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
|
30
30
|
"license": "MIT",
|
|
31
|
-
"packageManager": "pnpm@10.
|
|
31
|
+
"packageManager": "pnpm@10.14.0",
|
|
32
32
|
"type": "module",
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -54,36 +54,36 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@kevisual/code-center-module": "0.0.
|
|
57
|
+
"@kevisual/code-center-module": "0.0.24",
|
|
58
58
|
"@kevisual/mark": "0.0.7",
|
|
59
|
-
"@kevisual/router": "0.0.
|
|
59
|
+
"@kevisual/router": "0.0.23",
|
|
60
60
|
"@kevisual/types": "^0.0.10",
|
|
61
|
-
"@kevisual/use-config": "^1.0.
|
|
62
|
-
"@types/bun": "^1.2.
|
|
61
|
+
"@kevisual/use-config": "^1.0.19",
|
|
62
|
+
"@types/bun": "^1.2.19",
|
|
63
63
|
"@types/crypto-js": "^4.2.2",
|
|
64
64
|
"@types/formidable": "^3.4.5",
|
|
65
65
|
"@types/lodash-es": "^4.17.12",
|
|
66
|
-
"@types/node": "^
|
|
67
|
-
"@vitejs/plugin-basic-ssl": "^2.
|
|
66
|
+
"@types/node": "^24.2.0",
|
|
67
|
+
"@vitejs/plugin-basic-ssl": "^2.1.0",
|
|
68
68
|
"cookie": "^1.0.2",
|
|
69
|
-
"cross-env": "^
|
|
69
|
+
"cross-env": "^10.0.0",
|
|
70
70
|
"crypto-js": "^4.2.0",
|
|
71
71
|
"dayjs": "^1.11.13",
|
|
72
|
-
"dotenv": "^
|
|
72
|
+
"dotenv": "^17.2.1",
|
|
73
73
|
"formidable": "^3.5.4",
|
|
74
|
-
"ioredis": "^5.
|
|
74
|
+
"ioredis": "^5.7.0",
|
|
75
75
|
"json5": "^2.2.3",
|
|
76
76
|
"lodash-es": "^4.17.21",
|
|
77
|
-
"openai": "
|
|
78
|
-
"pm2": "^6.0.
|
|
77
|
+
"openai": "5.12.0",
|
|
78
|
+
"pm2": "^6.0.8",
|
|
79
79
|
"rimraf": "^6.0.1",
|
|
80
|
-
"rollup": "^4.
|
|
80
|
+
"rollup": "^4.46.2",
|
|
81
81
|
"rollup-plugin-dts": "^6.2.1",
|
|
82
82
|
"sequelize": "^6.37.7",
|
|
83
83
|
"tape": "^5.9.0",
|
|
84
84
|
"tiktoken": "^1.0.21",
|
|
85
|
-
"typescript": "^5.
|
|
86
|
-
"vite": "^
|
|
85
|
+
"typescript": "^5.9.2",
|
|
86
|
+
"vite": "^7.1.0"
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@kevisual/logger": "^0.0.4"
|
package/readme.md
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
# AI Center
|
|
2
|
-
|
|
1
|
+
# 【自用】AI Center
|
|
@@ -2,7 +2,7 @@ import { BaseChat, BaseChatOptions } from '../core/chat.ts';
|
|
|
2
2
|
|
|
3
3
|
export type BailianOptions = Partial<BaseChatOptions>;
|
|
4
4
|
export class BailianChat extends BaseChat {
|
|
5
|
-
static BASE_URL = 'https://bailian.aliyuncs.com/compatible-mode/v1
|
|
5
|
+
static BASE_URL = 'https://bailian.aliyuncs.com/compatible-mode/v1';
|
|
6
6
|
constructor(options: BailianOptions) {
|
|
7
7
|
const baseURL = options.baseURL || BailianChat.BASE_URL;
|
|
8
8
|
super({ ...(options as BaseChatOptions), baseURL: baseURL });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseChat, BaseChatOptions } from '../core/chat.ts';
|
|
2
|
+
|
|
3
|
+
export type OpenRouterOptions = Partial<BaseChatOptions>;
|
|
4
|
+
export class OpenRouterChat extends BaseChat {
|
|
5
|
+
static BASE_URL = 'https://openrouter.ai/api/v1';
|
|
6
|
+
constructor(options: OpenRouterOptions) {
|
|
7
|
+
const baseURL = options.baseURL || OpenRouterChat.BASE_URL;
|
|
8
|
+
super({ ...(options as BaseChatOptions), baseURL: baseURL });
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseChat, BaseChatOptions } from '../core/chat.ts';
|
|
2
2
|
import { OpenAI } from 'openai';
|
|
3
|
+
import type { ChatMessage, ChatMessageOptions } from '../core/index.ts';
|
|
3
4
|
|
|
4
5
|
export type SiliconFlowOptions = Partial<BaseChatOptions>;
|
|
5
6
|
|
|
@@ -32,7 +33,7 @@ export class SiliconFlow extends BaseChat {
|
|
|
32
33
|
async getUsageInfo(): Promise<SiliconFlowUsageResponse> {
|
|
33
34
|
return this.openai.get('/user/info');
|
|
34
35
|
}
|
|
35
|
-
async chat(messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[], options?:
|
|
36
|
+
async chat(messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[], options?: ChatMessageOptions) {
|
|
36
37
|
const res = await super.chat(messages, options);
|
|
37
38
|
return res;
|
|
38
39
|
}
|
|
@@ -34,8 +34,8 @@ export type BaseChatOptions<T = Record<string, any>> = {
|
|
|
34
34
|
} & T;
|
|
35
35
|
export const getIsBrowser = () => {
|
|
36
36
|
try {
|
|
37
|
-
//
|
|
38
|
-
return
|
|
37
|
+
// 检查是否存在window对象
|
|
38
|
+
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
39
39
|
} catch (e) {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
@@ -76,7 +76,7 @@ export class BaseChat implements BaseChatInterface, BaseChatUsageInterface {
|
|
|
76
76
|
this.openai = new OpenAI({
|
|
77
77
|
apiKey: this.apiKey,
|
|
78
78
|
baseURL: this.baseURL,
|
|
79
|
-
dangerouslyAllowBrowser: this.isBrowser,
|
|
79
|
+
dangerouslyAllowBrowser: options?.dangerouslyAllowBrowser ?? this.isBrowser,
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
/**
|