@maiyunnet/kebab 3.2.24 → 3.2.25

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/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "3.2.24";
8
+ export declare const VER = "3.2.25";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  export declare const LIB_PATH: string;
@@ -84,6 +84,8 @@ export interface IConfigS3 {
84
84
  }
85
85
  /** --- AI --- */
86
86
  export interface IConfigAi {
87
+ /** --- 目前只有微软 Azure 有 --- */
88
+ 'endpoint'?: string;
87
89
  'skey': string;
88
90
  }
89
91
  /** --- 向量数据库 --- */
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '3.2.24';
9
+ export const VER = '3.2.25';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/ai.d.ts CHANGED
@@ -14,14 +14,20 @@ export declare enum ESERVICE {
14
14
  /** --- 阿里中国大陆区 --- */
15
15
  'ALICN' = 0,
16
16
  /** --- 阿里国际区 --- */
17
- 'ALIAS' = 1
17
+ 'ALIAS' = 1,
18
+ /** --- 微软 Azure --- */
19
+ 'AZURE' = 2
18
20
  }
19
21
  /** --- 选项 --- */
20
22
  export interface IOptions {
21
23
  /** --- 服务商 ---- */
22
24
  'service': ESERVICE;
23
- /** --- 密钥值 --- */
25
+ /** --- 接入点 --- */
26
+ 'endpoint'?: string;
27
+ /** --- 密钥 --- */
24
28
  'secretKey'?: string;
29
+ /** --- 自定义 fetch 函数 --- */
30
+ 'fetch'?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
25
31
  }
26
32
  export declare class Ai {
27
33
  /** --- openai 原生对象,建议只读 --- */
package/lib/ai.js CHANGED
@@ -15,6 +15,8 @@ export var ESERVICE;
15
15
  ESERVICE[ESERVICE["ALICN"] = 0] = "ALICN";
16
16
  /** --- 阿里国际区 --- */
17
17
  ESERVICE[ESERVICE["ALIAS"] = 1] = "ALIAS";
18
+ /** --- 微软 Azure --- */
19
+ ESERVICE[ESERVICE["AZURE"] = 2] = "AZURE";
18
20
  })(ESERVICE || (ESERVICE = {}));
19
21
  /** --- openai 的连接对象 --- */
20
22
  const links = [];
@@ -25,11 +27,15 @@ export class Ai {
25
27
  let endpoint;
26
28
  switch (opt.service) {
27
29
  case ESERVICE.ALICN: {
28
- endpoint = `https://dashscope.aliyuncs.com/compatible-mode/v1`;
30
+ endpoint = opt.endpoint ?? `https://dashscope.aliyuncs.com/compatible-mode/v1`;
29
31
  break;
30
32
  }
31
33
  case ESERVICE.ALIAS: {
32
- endpoint = `https://dashscope-intl.aliyuncs.com/compatible-mode/v1`;
34
+ endpoint = opt.endpoint ?? `https://dashscope-intl.aliyuncs.com/compatible-mode/v1`;
35
+ break;
36
+ }
37
+ case ESERVICE.AZURE: {
38
+ endpoint = opt.endpoint ?? config.ai?.[ESERVICE[opt.service]]?.endpoint ?? '';
33
39
  break;
34
40
  }
35
41
  default: {
@@ -45,6 +51,7 @@ export class Ai {
45
51
  this.link = new openai.OpenAI({
46
52
  'apiKey': secretKey,
47
53
  'baseURL': endpoint,
54
+ 'fetch': opt.fetch,
48
55
  });
49
56
  links.push({
50
57
  'token': token,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "3.2.24",
3
+ "version": "3.2.25",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
package/sys/cmd.js CHANGED
@@ -152,6 +152,9 @@ async function run() {
152
152
  config.ai['ALICN'].skey ??= '';
153
153
  config.ai['ALIAS'] ??= {};
154
154
  config.ai['ALIAS'].skey ??= '';
155
+ config.ai['AZURE'] ??= {};
156
+ config.ai['AZURE'].endpoint ??= '';
157
+ config.ai['AZURE'].skey ??= '';
155
158
  // --- config - vector ---
156
159
  config.vector ??= {};
157
160
  config.vector.host ??= '127.0.0.1';