@maiyunnet/kebab 9.11.3 → 9.11.5

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/doc/kebab-rag.md CHANGED
@@ -1360,7 +1360,7 @@ index/variables/VER.md
1360
1360
 
1361
1361
  # Variable: VER
1362
1362
 
1363
- > `const` **VER**: `"9.11.3"` = `'9.11.3'`
1363
+ > `const` **VER**: `"9.11.5"` = `'9.11.5'`
1364
1364
 
1365
1365
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1366
1366
 
@@ -1407,7 +1407,7 @@ lib/ai/classes/Ai.md
1407
1407
 
1408
1408
  # Class: Ai
1409
1409
 
1410
- Defined in: [lib/ai.ts:67](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L67)
1410
+ Defined in: [lib/ai.ts:69](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L69)
1411
1411
 
1412
1412
  ## Constructors
1413
1413
 
@@ -1415,7 +1415,7 @@ Defined in: [lib/ai.ts:67](https://github.com/maiyunnet/kebab/blob/master/lib/ai
1415
1415
 
1416
1416
  > **new Ai**(`ctrEtc`, `opt`): `Ai`
1417
1417
 
1418
- Defined in: [lib/ai.ts:80](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L80)
1418
+ Defined in: [lib/ai.ts:82](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L82)
1419
1419
 
1420
1420
  #### Parameters
1421
1421
 
@@ -1437,7 +1437,7 @@ Defined in: [lib/ai.ts:80](https://github.com/maiyunnet/kebab/blob/master/lib/ai
1437
1437
 
1438
1438
  > `readonly` **link**: `OpenAI`
1439
1439
 
1440
- Defined in: [lib/ai.ts:70](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L70)
1440
+ Defined in: [lib/ai.ts:72](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L72)
1441
1441
 
1442
1442
  openai 原生对象
1443
1443
 
@@ -1449,7 +1449,7 @@ openai 原生对象
1449
1449
 
1450
1450
  > **get** **service**(): [`ESERVICE`](../enumerations/ESERVICE.md)
1451
1451
 
1452
- Defined in: [lib/ai.ts:164](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L164)
1452
+ Defined in: [lib/ai.ts:167](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L167)
1453
1453
 
1454
1454
  获取当前服务商
1455
1455
 
@@ -1467,7 +1467,7 @@ Defined in: [lib/ai.ts:164](https://github.com/maiyunnet/kebab/blob/master/lib/a
1467
1467
 
1468
1468
  > **chat**(`body`): `Promise`\<`false` \| `APIPromise`\<`ChatCompletion`\>\>
1469
1469
 
1470
- Defined in: [lib/ai.ts:169](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L169)
1470
+ Defined in: [lib/ai.ts:172](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L172)
1471
1471
 
1472
1472
  创建非流式对话
1473
1473
 
@@ -1485,7 +1485,7 @@ Defined in: [lib/ai.ts:169](https://github.com/maiyunnet/kebab/blob/master/lib/a
1485
1485
 
1486
1486
  > **chat**(`body`): `Promise`\<`false` \| `APIPromise`\<`Stream`\<`ChatCompletionChunk`\>\>\>
1487
1487
 
1488
- Defined in: [lib/ai.ts:173](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L173)
1488
+ Defined in: [lib/ai.ts:176](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L176)
1489
1489
 
1490
1490
  创建流式对话
1491
1491
 
@@ -1505,7 +1505,7 @@ Defined in: [lib/ai.ts:173](https://github.com/maiyunnet/kebab/blob/master/lib/a
1505
1505
 
1506
1506
  > **embedding**(`body`): `Promise`\<`false` \| `APIPromise`\<`CreateEmbeddingResponse`\>\>
1507
1507
 
1508
- Defined in: [lib/ai.ts:222](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L222)
1508
+ Defined in: [lib/ai.ts:225](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L225)
1509
1509
 
1510
1510
  创建向量
1511
1511
 
@@ -1525,7 +1525,7 @@ Defined in: [lib/ai.ts:222](https://github.com/maiyunnet/kebab/blob/master/lib/a
1525
1525
 
1526
1526
  > **image**(`opt`): `Promise`\<`false` \| \{ `list`: `object`[]; `request`: `string`; `seed`: `number`; \}\>
1527
1527
 
1528
- Defined in: [lib/ai.ts:238](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L238)
1528
+ Defined in: [lib/ai.ts:241](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L241)
1529
1529
 
1530
1530
  生成图像,不支持 GEMINI、GROK 服务商
1531
1531
 
@@ -1587,7 +1587,7 @@ Defined in: [lib/ai.ts:238](https://github.com/maiyunnet/kebab/blob/master/lib/a
1587
1587
 
1588
1588
  > **poll**(`opt`): `Promise`\<`false` \| \{ `add?`: `number`; `end?`: `number`; `error?`: `string`; `start?`: `number`; `status`: `"PENDING"` \| `"RUNNING"` \| `"SUCCEEDED"` \| `"FAILED"` \| `"CANCELED"` \| `"UNKNOWN"`; `task`: `string`; `url?`: `string`; \}\>
1589
1589
 
1590
- Defined in: [lib/ai.ts:599](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L599)
1590
+ Defined in: [lib/ai.ts:602](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L602)
1591
1591
 
1592
1592
  轮询任务
1593
1593
 
@@ -1617,7 +1617,7 @@ Defined in: [lib/ai.ts:599](https://github.com/maiyunnet/kebab/blob/master/lib/a
1617
1617
 
1618
1618
  > **response**(`body`): `Promise`\<`false` \| `APIPromise`\<`Response`\>\>
1619
1619
 
1620
- Defined in: [lib/ai.ts:196](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L196)
1620
+ Defined in: [lib/ai.ts:199](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L199)
1621
1621
 
1622
1622
  创建非流式 Response
1623
1623
 
@@ -1635,7 +1635,7 @@ Defined in: [lib/ai.ts:196](https://github.com/maiyunnet/kebab/blob/master/lib/a
1635
1635
 
1636
1636
  > **response**(`body`): `Promise`\<`false` \| `APIPromise`\<`Stream`\<`ResponseStreamEvent`\>\>\>
1637
1637
 
1638
- Defined in: [lib/ai.ts:200](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L200)
1638
+ Defined in: [lib/ai.ts:203](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L203)
1639
1639
 
1640
1640
  创建流式 Response
1641
1641
 
@@ -1655,7 +1655,7 @@ Defined in: [lib/ai.ts:200](https://github.com/maiyunnet/kebab/blob/master/lib/a
1655
1655
 
1656
1656
  > **video**(`opt`): `Promise`\<`false` \| \{ `request`: `string`; `seed`: `number`; `status`: `"PENDING"` \| `"RUNNING"` \| `"SUCCEEDED"` \| `"FAILED"` \| `"CANCELED"` \| `"UNKNOWN"`; `task`: `string`; \}\>
1657
1657
 
1658
- Defined in: [lib/ai.ts:428](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L428)
1658
+ Defined in: [lib/ai.ts:431](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L431)
1659
1659
 
1660
1660
  异步生成视频,仅支持 ALICN、ALIAS、ALINE
1661
1661
 
@@ -1883,7 +1883,7 @@ lib/ai/functions/get.md
1883
1883
 
1884
1884
  > **get**(`ctrEtc`, `opt`): [`Ai`](../classes/Ai.md)
1885
1885
 
1886
- Defined in: [lib/ai.ts:657](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L657)
1886
+ Defined in: [lib/ai.ts:660](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L660)
1887
1887
 
1888
1888
  创建一个 AI 对象
1889
1889
 
@@ -1999,6 +1999,16 @@ Defined in: [lib/ai.ts:52](https://github.com/maiyunnet/kebab/blob/master/lib/ai
1999
1999
 
2000
2000
  服务商 -
2001
2001
 
2002
+ ***
2003
+
2004
+ ### timeout?
2005
+
2006
+ > `optional` **timeout?**: `number`
2007
+
2008
+ Defined in: [lib/ai.ts:60](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L60)
2009
+
2010
+ 请求超时,毫秒
2011
+
2002
2012
  lib/buffer/classes/Reader.md
2003
2013
  ---
2004
2014
 
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "9.11.3";
8
+ export declare const VER = "9.11.5";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  /** --- 框架的 LIB,以 / 结尾 --- */
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '9.11.3';
9
+ export const VER = '9.11.5';
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
@@ -48,6 +48,8 @@ export interface IOptions {
48
48
  'secretKey'?: string;
49
49
  /** --- 自定义 fetch 函数 --- */
50
50
  'fetch'?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
51
+ /** --- 请求超时,毫秒 --- */
52
+ 'timeout'?: number;
51
53
  }
52
54
  export declare class Ai {
53
55
  /** --- openai 原生对象 --- */
package/lib/ai.js CHANGED
@@ -125,6 +125,7 @@ export class Ai {
125
125
  'apiKey': secretKey,
126
126
  'baseURL': endpoint,
127
127
  'fetch': opt.fetch,
128
+ 'timeout': opt.timeout,
128
129
  });
129
130
  links.push({
130
131
  'token': token,
package/lib/net.js CHANGED
@@ -210,10 +210,7 @@ export async function fetch(input, init = {}) {
210
210
  };
211
211
  // --- 检查是否已中止(注意:请求发起后无法中止) ---
212
212
  if (init.signal?.aborted) {
213
- return new Response(null, {
214
- 'status': 0,
215
- 'statusText': 'Aborted',
216
- });
213
+ throw new DOMException('This operation was aborted', 'AbortError');
217
214
  }
218
215
  // --- 发起请求 ---
219
216
  const res = await request(u, body, opt);
@@ -239,11 +236,14 @@ export async function fetch(input, init = {}) {
239
236
  }
240
237
  }
241
238
  }
242
- const status = res.headers?.['http-code'] ?? (res.error ? 0 : 200);
243
- if (res.error || !resStream) {
239
+ if (res.error) {
240
+ throw new TypeError(res.error.message ?? 'fetch failed');
241
+ }
242
+ const status = res.headers?.['http-code'] ?? 200;
243
+ if (!resStream) {
244
244
  return new Response(null, {
245
245
  'status': status,
246
- 'statusText': res.error?.message ?? 'Unknown Error',
246
+ 'statusText': 'Unknown Error',
247
247
  'headers': resHeaders,
248
248
  });
249
249
  }
package/lib/undici.js CHANGED
@@ -227,10 +227,7 @@ export async function fetch(input, init = {}) {
227
227
  };
228
228
  // --- 检查是否已中止(注意:请求发起后无法中止) ---
229
229
  if (init.signal?.aborted) {
230
- return new Response(null, {
231
- 'status': 0,
232
- 'statusText': 'Aborted',
233
- });
230
+ throw new DOMException('This operation was aborted', 'AbortError');
234
231
  }
235
232
  // --- 发起请求 ---
236
233
  const res = await request(u, body, opt);
@@ -256,11 +253,14 @@ export async function fetch(input, init = {}) {
256
253
  }
257
254
  }
258
255
  }
259
- const status = res.headers?.['http-code'] ?? (res.error ? 0 : 200);
260
- if (res.error || !resStream) {
256
+ if (res.error) {
257
+ throw new TypeError(res.error.message ?? 'fetch failed');
258
+ }
259
+ const status = res.headers?.['http-code'] ?? 200;
260
+ if (!resStream) {
261
261
  return new Response(null, {
262
262
  'status': status,
263
- 'statusText': res.error?.message ?? 'Unknown Error',
263
+ 'statusText': 'Unknown Error',
264
264
  'headers': resHeaders,
265
265
  });
266
266
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "9.11.3",
3
+ "version": "9.11.5",
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": [