@maiyunnet/kebab 9.10.1 → 9.11.1
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 +147 -85
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/ai.d.ts +9 -1
- package/lib/ai.js +41 -0
- package/lib/core.js +7 -5
- package/lib/undici/response.d.ts +1 -1
- package/lib/undici/response.js +7 -3
- package/lib/vector.d.ts +1 -1
- package/lib/vector.js +5 -5
- package/package.json +1 -1
- package/sys/cmd.js +4 -0
- package/sys/master.js +1 -0
- package/sys/mod.js +12 -0
- package/www/example/ctr/test.js +127 -2
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.
|
|
1363
|
+
> `const` **VER**: `"9.11.1"` = `'9.11.1'`
|
|
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:
|
|
1410
|
+
Defined in: [lib/ai.ts:67](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L67)
|
|
1411
1411
|
|
|
1412
1412
|
## Constructors
|
|
1413
1413
|
|
|
@@ -1415,7 +1415,7 @@ Defined in: [lib/ai.ts:60](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:
|
|
1418
|
+
Defined in: [lib/ai.ts:80](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L80)
|
|
1419
1419
|
|
|
1420
1420
|
#### Parameters
|
|
1421
1421
|
|
|
@@ -1437,7 +1437,7 @@ Defined in: [lib/ai.ts:73](https://github.com/maiyunnet/kebab/blob/master/lib/ai
|
|
|
1437
1437
|
|
|
1438
1438
|
> `readonly` **link**: `OpenAI`
|
|
1439
1439
|
|
|
1440
|
-
Defined in: [lib/ai.ts:
|
|
1440
|
+
Defined in: [lib/ai.ts:70](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L70)
|
|
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:
|
|
1452
|
+
Defined in: [lib/ai.ts:164](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L164)
|
|
1453
1453
|
|
|
1454
1454
|
获取当前服务商
|
|
1455
1455
|
|
|
@@ -1467,7 +1467,7 @@ Defined in: [lib/ai.ts:149](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:
|
|
1470
|
+
Defined in: [lib/ai.ts:169](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L169)
|
|
1471
1471
|
|
|
1472
1472
|
创建非流式对话
|
|
1473
1473
|
|
|
@@ -1485,7 +1485,7 @@ Defined in: [lib/ai.ts:154](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:
|
|
1488
|
+
Defined in: [lib/ai.ts:173](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L173)
|
|
1489
1489
|
|
|
1490
1490
|
创建流式对话
|
|
1491
1491
|
|
|
@@ -1505,7 +1505,7 @@ Defined in: [lib/ai.ts:158](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:
|
|
1508
|
+
Defined in: [lib/ai.ts:222](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L222)
|
|
1509
1509
|
|
|
1510
1510
|
创建向量
|
|
1511
1511
|
|
|
@@ -1525,7 +1525,7 @@ Defined in: [lib/ai.ts:181](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:
|
|
1528
|
+
Defined in: [lib/ai.ts:238](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L238)
|
|
1529
1529
|
|
|
1530
1530
|
生成图像,不支持 GEMINI、GROK 服务商
|
|
1531
1531
|
|
|
@@ -1587,7 +1587,7 @@ Defined in: [lib/ai.ts:197](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:
|
|
1590
|
+
Defined in: [lib/ai.ts:599](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L599)
|
|
1591
1591
|
|
|
1592
1592
|
轮询任务
|
|
1593
1593
|
|
|
@@ -1609,11 +1609,53 @@ Defined in: [lib/ai.ts:546](https://github.com/maiyunnet/kebab/blob/master/lib/a
|
|
|
1609
1609
|
|
|
1610
1610
|
***
|
|
1611
1611
|
|
|
1612
|
+
### response()
|
|
1613
|
+
|
|
1614
|
+
创建 Response
|
|
1615
|
+
|
|
1616
|
+
#### Call Signature
|
|
1617
|
+
|
|
1618
|
+
> **response**(`body`): `Promise`\<`false` \| `APIPromise`\<`Response`\>\>
|
|
1619
|
+
|
|
1620
|
+
Defined in: [lib/ai.ts:196](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L196)
|
|
1621
|
+
|
|
1622
|
+
创建非流式 Response
|
|
1623
|
+
|
|
1624
|
+
##### Parameters
|
|
1625
|
+
|
|
1626
|
+
###### body
|
|
1627
|
+
|
|
1628
|
+
`ResponseCreateParamsNonStreaming`
|
|
1629
|
+
|
|
1630
|
+
##### Returns
|
|
1631
|
+
|
|
1632
|
+
`Promise`\<`false` \| `APIPromise`\<`Response`\>\>
|
|
1633
|
+
|
|
1634
|
+
#### Call Signature
|
|
1635
|
+
|
|
1636
|
+
> **response**(`body`): `Promise`\<`false` \| `APIPromise`\<`Stream`\<`ResponseStreamEvent`\>\>\>
|
|
1637
|
+
|
|
1638
|
+
Defined in: [lib/ai.ts:200](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L200)
|
|
1639
|
+
|
|
1640
|
+
创建流式 Response
|
|
1641
|
+
|
|
1642
|
+
##### Parameters
|
|
1643
|
+
|
|
1644
|
+
###### body
|
|
1645
|
+
|
|
1646
|
+
`ResponseCreateParamsStreaming`
|
|
1647
|
+
|
|
1648
|
+
##### Returns
|
|
1649
|
+
|
|
1650
|
+
`Promise`\<`false` \| `APIPromise`\<`Stream`\<`ResponseStreamEvent`\>\>\>
|
|
1651
|
+
|
|
1652
|
+
***
|
|
1653
|
+
|
|
1612
1654
|
### video()
|
|
1613
1655
|
|
|
1614
1656
|
> **video**(`opt`): `Promise`\<`false` \| \{ `request`: `string`; `seed`: `number`; `status`: `"PENDING"` \| `"RUNNING"` \| `"SUCCEEDED"` \| `"FAILED"` \| `"CANCELED"` \| `"UNKNOWN"`; `task`: `string`; \}\>
|
|
1615
1657
|
|
|
1616
|
-
Defined in: [lib/ai.ts:
|
|
1658
|
+
Defined in: [lib/ai.ts:428](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L428)
|
|
1617
1659
|
|
|
1618
1660
|
异步生成视频,仅支持 ALICN、ALIAS、ALINE
|
|
1619
1661
|
|
|
@@ -1790,6 +1832,26 @@ Grok
|
|
|
1790
1832
|
|
|
1791
1833
|
***
|
|
1792
1834
|
|
|
1835
|
+
### OFOX
|
|
1836
|
+
|
|
1837
|
+
> **OFOX**: `11`
|
|
1838
|
+
|
|
1839
|
+
Defined in: [lib/ai.ts:46](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L46)
|
|
1840
|
+
|
|
1841
|
+
OfoxAI
|
|
1842
|
+
|
|
1843
|
+
***
|
|
1844
|
+
|
|
1845
|
+
### OPENROUTER
|
|
1846
|
+
|
|
1847
|
+
> **OPENROUTER**: `10`
|
|
1848
|
+
|
|
1849
|
+
Defined in: [lib/ai.ts:44](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L44)
|
|
1850
|
+
|
|
1851
|
+
OpenRouter
|
|
1852
|
+
|
|
1853
|
+
***
|
|
1854
|
+
|
|
1793
1855
|
### VOLAS
|
|
1794
1856
|
|
|
1795
1857
|
> **VOLAS**: `9`
|
|
@@ -1821,7 +1883,7 @@ lib/ai/functions/get.md
|
|
|
1821
1883
|
|
|
1822
1884
|
> **get**(`ctrEtc`, `opt`): [`Ai`](../classes/Ai.md)
|
|
1823
1885
|
|
|
1824
|
-
Defined in: [lib/ai.ts:
|
|
1886
|
+
Defined in: [lib/ai.ts:657](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L657)
|
|
1825
1887
|
|
|
1826
1888
|
创建一个 AI 对象
|
|
1827
1889
|
|
|
@@ -1879,7 +1941,7 @@ lib/ai/interfaces/IOptions.md
|
|
|
1879
1941
|
|
|
1880
1942
|
# Interface: IOptions
|
|
1881
1943
|
|
|
1882
|
-
Defined in: [lib/ai.ts:
|
|
1944
|
+
Defined in: [lib/ai.ts:50](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L50)
|
|
1883
1945
|
|
|
1884
1946
|
选项
|
|
1885
1947
|
|
|
@@ -1889,7 +1951,7 @@ Defined in: [lib/ai.ts:43](https://github.com/maiyunnet/kebab/blob/master/lib/ai
|
|
|
1889
1951
|
|
|
1890
1952
|
> `optional` **endpoint?**: `string`
|
|
1891
1953
|
|
|
1892
|
-
Defined in: [lib/ai.ts:
|
|
1954
|
+
Defined in: [lib/ai.ts:54](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L54)
|
|
1893
1955
|
|
|
1894
1956
|
接入点
|
|
1895
1957
|
|
|
@@ -1899,7 +1961,7 @@ Defined in: [lib/ai.ts:47](https://github.com/maiyunnet/kebab/blob/master/lib/ai
|
|
|
1899
1961
|
|
|
1900
1962
|
> `optional` **fetch?**: (`input`, `init?`) => `Promise`\<`Response`\>
|
|
1901
1963
|
|
|
1902
|
-
Defined in: [lib/ai.ts:
|
|
1964
|
+
Defined in: [lib/ai.ts:58](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L58)
|
|
1903
1965
|
|
|
1904
1966
|
自定义 fetch 函数
|
|
1905
1967
|
|
|
@@ -1923,7 +1985,7 @@ Defined in: [lib/ai.ts:51](https://github.com/maiyunnet/kebab/blob/master/lib/ai
|
|
|
1923
1985
|
|
|
1924
1986
|
> `optional` **secretKey?**: `string`
|
|
1925
1987
|
|
|
1926
|
-
Defined in: [lib/ai.ts:
|
|
1988
|
+
Defined in: [lib/ai.ts:56](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L56)
|
|
1927
1989
|
|
|
1928
1990
|
密钥
|
|
1929
1991
|
|
|
@@ -1933,7 +1995,7 @@ Defined in: [lib/ai.ts:49](https://github.com/maiyunnet/kebab/blob/master/lib/ai
|
|
|
1933
1995
|
|
|
1934
1996
|
> **service**: [`ESERVICE`](../enumerations/ESERVICE.md)
|
|
1935
1997
|
|
|
1936
|
-
Defined in: [lib/ai.ts:
|
|
1998
|
+
Defined in: [lib/ai.ts:52](https://github.com/maiyunnet/kebab/blob/master/lib/ai.ts#L52)
|
|
1937
1999
|
|
|
1938
2000
|
服务商 -
|
|
1939
2001
|
|
|
@@ -3258,7 +3320,7 @@ lib/core/functions/clone.md
|
|
|
3258
3320
|
|
|
3259
3321
|
> **clone**\<`T`\>(`obj`): `T`
|
|
3260
3322
|
|
|
3261
|
-
Defined in: [lib/core.ts:
|
|
3323
|
+
Defined in: [lib/core.ts:1164](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1164)
|
|
3262
3324
|
|
|
3263
3325
|
完整的克隆一份数组/对象
|
|
3264
3326
|
|
|
@@ -3322,7 +3384,7 @@ lib/core/functions/debug.md
|
|
|
3322
3384
|
|
|
3323
3385
|
> **debug**(`message?`, ...`optionalParams`): `void`
|
|
3324
3386
|
|
|
3325
|
-
Defined in: [lib/core.ts:
|
|
3387
|
+
Defined in: [lib/core.ts:1198](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1198)
|
|
3326
3388
|
|
|
3327
3389
|
打印调试信息,线上环境不会打印
|
|
3328
3390
|
|
|
@@ -3357,7 +3419,7 @@ lib/core/functions/display.md
|
|
|
3357
3419
|
|
|
3358
3420
|
> **display**(`message?`, ...`optionalParams`): `void`
|
|
3359
3421
|
|
|
3360
|
-
Defined in: [lib/core.ts:
|
|
3422
|
+
Defined in: [lib/core.ts:1211](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1211)
|
|
3361
3423
|
|
|
3362
3424
|
向控制台直接显示内容,一般情况下禁止使用
|
|
3363
3425
|
|
|
@@ -3462,7 +3524,7 @@ lib/core/functions/getLog.md
|
|
|
3462
3524
|
|
|
3463
3525
|
> **getLog**(`opt`): `Promise`\<`false` \| \{ `list`: `any`[] \| `string`[][]; `total`: `number`; \}\>
|
|
3464
3526
|
|
|
3465
|
-
Defined in: [lib/core.ts:
|
|
3527
|
+
Defined in: [lib/core.ts:1076](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1076)
|
|
3466
3528
|
|
|
3467
3529
|
获取日志内容为一个数组
|
|
3468
3530
|
|
|
@@ -3597,7 +3659,7 @@ lib/core/functions/loadEnv.md
|
|
|
3597
3659
|
|
|
3598
3660
|
> **loadEnv**(`dir`): `Promise`\<`void`\>
|
|
3599
3661
|
|
|
3600
|
-
Defined in: [lib/core.ts:
|
|
3662
|
+
Defined in: [lib/core.ts:1263](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1263)
|
|
3601
3663
|
|
|
3602
3664
|
加载 .env 文件到 process.env,若文件不存在则跳过
|
|
3603
3665
|
|
|
@@ -3667,7 +3729,7 @@ lib/core/functions/ls.md
|
|
|
3667
3729
|
|
|
3668
3730
|
> **ls**(`opt`): `Promise`\<`object`[]\>
|
|
3669
3731
|
|
|
3670
|
-
Defined in: [lib/core.ts:
|
|
3732
|
+
Defined in: [lib/core.ts:1125](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1125)
|
|
3671
3733
|
|
|
3672
3734
|
获取目录内文件/文件夹列表
|
|
3673
3735
|
|
|
@@ -4028,7 +4090,7 @@ lib/core/functions/resolveEnvVars.md
|
|
|
4028
4090
|
|
|
4029
4091
|
> **resolveEnvVars**(`obj`): `void`
|
|
4030
4092
|
|
|
4031
|
-
Defined in: [lib/core.ts:
|
|
4093
|
+
Defined in: [lib/core.ts:1293](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1293)
|
|
4032
4094
|
|
|
4033
4095
|
将配置对象中的 ${ENV_VAR} 占位符替换为 process.env 的值
|
|
4034
4096
|
|
|
@@ -4470,7 +4532,7 @@ lib/core/functions/writeEventStreamHead.md
|
|
|
4470
4532
|
|
|
4471
4533
|
> **writeEventStreamHead**(`res`): `void`
|
|
4472
4534
|
|
|
4473
|
-
Defined in: [lib/core.ts:
|
|
4535
|
+
Defined in: [lib/core.ts:1233](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1233)
|
|
4474
4536
|
|
|
4475
4537
|
## Parameters
|
|
4476
4538
|
|
|
@@ -4495,7 +4557,7 @@ lib/core/functions/writeHead.md
|
|
|
4495
4557
|
|
|
4496
4558
|
> **writeHead**(`res`, `statusCode`, `headers?`): `void`
|
|
4497
4559
|
|
|
4498
|
-
Defined in: [lib/core.ts:
|
|
4560
|
+
Defined in: [lib/core.ts:1222](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1222)
|
|
4499
4561
|
|
|
4500
4562
|
让 res 发送头部(前提是头部没有被发送才能调用本方法
|
|
4501
4563
|
|
|
@@ -4536,7 +4598,7 @@ lib/core/functions/write.md
|
|
|
4536
4598
|
|
|
4537
4599
|
> **write**(`res`, `data`): `void`
|
|
4538
4600
|
|
|
4539
|
-
Defined in: [lib/core.ts:
|
|
4601
|
+
Defined in: [lib/core.ts:1245](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1245)
|
|
4540
4602
|
|
|
4541
4603
|
向 res 发送数据
|
|
4542
4604
|
|
|
@@ -19204,7 +19266,7 @@ lib/undici/response/classes/Response.md
|
|
|
19204
19266
|
|
|
19205
19267
|
# Class: Response
|
|
19206
19268
|
|
|
19207
|
-
Defined in: [lib/undici/response.ts:
|
|
19269
|
+
Defined in: [lib/undici/response.ts:13](https://github.com/maiyunnet/kebab/blob/master/lib/undici/response.ts#L13)
|
|
19208
19270
|
|
|
19209
19271
|
## Constructors
|
|
19210
19272
|
|
|
@@ -19212,7 +19274,7 @@ Defined in: [lib/undici/response.ts:12](https://github.com/maiyunnet/kebab/blob/
|
|
|
19212
19274
|
|
|
19213
19275
|
> **new Response**(`req`): `Response`
|
|
19214
19276
|
|
|
19215
|
-
Defined in: [lib/undici/response.ts:
|
|
19277
|
+
Defined in: [lib/undici/response.ts:26](https://github.com/maiyunnet/kebab/blob/master/lib/undici/response.ts#L26)
|
|
19216
19278
|
|
|
19217
19279
|
#### Parameters
|
|
19218
19280
|
|
|
@@ -19230,7 +19292,7 @@ Defined in: [lib/undici/response.ts:25](https://github.com/maiyunnet/kebab/blob/
|
|
|
19230
19292
|
|
|
19231
19293
|
> **error**: `Error` \| `null` = `null`
|
|
19232
19294
|
|
|
19233
|
-
Defined in: [lib/undici/response.ts:
|
|
19295
|
+
Defined in: [lib/undici/response.ts:21](https://github.com/maiyunnet/kebab/blob/master/lib/undici/response.ts#L21)
|
|
19234
19296
|
|
|
19235
19297
|
***
|
|
19236
19298
|
|
|
@@ -19238,7 +19300,7 @@ Defined in: [lib/undici/response.ts:20](https://github.com/maiyunnet/kebab/blob/
|
|
|
19238
19300
|
|
|
19239
19301
|
> **headers**: [`THttpHeaders`](../../type-aliases/THttpHeaders.md) \| `null` = `null`
|
|
19240
19302
|
|
|
19241
|
-
Defined in: [lib/undici/response.ts:
|
|
19303
|
+
Defined in: [lib/undici/response.ts:19](https://github.com/maiyunnet/kebab/blob/master/lib/undici/response.ts#L19)
|
|
19242
19304
|
|
|
19243
19305
|
返回的 headers
|
|
19244
19306
|
|
|
@@ -19248,7 +19310,7 @@ Defined in: [lib/undici/response.ts:18](https://github.com/maiyunnet/kebab/blob/
|
|
|
19248
19310
|
|
|
19249
19311
|
> **getContent**(): `Promise`\<`Buffer`\<`ArrayBufferLike`\> \| `null`\>
|
|
19250
19312
|
|
|
19251
|
-
Defined in: [lib/undici/response.ts:
|
|
19313
|
+
Defined in: [lib/undici/response.ts:33](https://github.com/maiyunnet/kebab/blob/master/lib/undici/response.ts#L33)
|
|
19252
19314
|
|
|
19253
19315
|
读取所有内容到内存
|
|
19254
19316
|
|
|
@@ -19262,7 +19324,7 @@ Defined in: [lib/undici/response.ts:32](https://github.com/maiyunnet/kebab/blob/
|
|
|
19262
19324
|
|
|
19263
19325
|
> **getJson**(): `Promise`\<`any`\>
|
|
19264
19326
|
|
|
19265
|
-
Defined in: [lib/undici/response.ts:
|
|
19327
|
+
Defined in: [lib/undici/response.ts:66](https://github.com/maiyunnet/kebab/blob/master/lib/undici/response.ts#L66)
|
|
19266
19328
|
|
|
19267
19329
|
读取所有内容为 JSON,失败返回 null
|
|
19268
19330
|
|
|
@@ -19276,7 +19338,7 @@ Defined in: [lib/undici/response.ts:63](https://github.com/maiyunnet/kebab/blob/
|
|
|
19276
19338
|
|
|
19277
19339
|
> **getRawStream**(): `BodyReadable` & `BodyMixin` \| `null`
|
|
19278
19340
|
|
|
19279
|
-
Defined in: [lib/undici/response.ts:
|
|
19341
|
+
Defined in: [lib/undici/response.ts:128](https://github.com/maiyunnet/kebab/blob/master/lib/undici/response.ts#L128)
|
|
19280
19342
|
|
|
19281
19343
|
获取原生响应读取流对象
|
|
19282
19344
|
|
|
@@ -19290,7 +19352,7 @@ Defined in: [lib/undici/response.ts:124](https://github.com/maiyunnet/kebab/blob
|
|
|
19290
19352
|
|
|
19291
19353
|
> **getStream**(): `BrotliDecompress` \| `Gunzip` \| `Inflate` \| `BodyReadable` & `BodyMixin` \| `null`
|
|
19292
19354
|
|
|
19293
|
-
Defined in: [lib/undici/response.ts:
|
|
19355
|
+
Defined in: [lib/undici/response.ts:92](https://github.com/maiyunnet/kebab/blob/master/lib/undici/response.ts#L92)
|
|
19294
19356
|
|
|
19295
19357
|
获取响应读取流对象
|
|
19296
19358
|
|
|
@@ -19304,7 +19366,7 @@ Defined in: [lib/undici/response.ts:88](https://github.com/maiyunnet/kebab/blob/
|
|
|
19304
19366
|
|
|
19305
19367
|
> **getText**(): `Promise`\<`string` \| `null`\>
|
|
19306
19368
|
|
|
19307
|
-
Defined in: [lib/undici/response.ts:
|
|
19369
|
+
Defined in: [lib/undici/response.ts:51](https://github.com/maiyunnet/kebab/blob/master/lib/undici/response.ts#L51)
|
|
19308
19370
|
|
|
19309
19371
|
读取所有内容为文本
|
|
19310
19372
|
|
|
@@ -19318,7 +19380,7 @@ Defined in: [lib/undici/response.ts:49](https://github.com/maiyunnet/kebab/blob/
|
|
|
19318
19380
|
|
|
19319
19381
|
> **setContent**(`v`): `void`
|
|
19320
19382
|
|
|
19321
|
-
Defined in: [lib/undici/response.ts:
|
|
19383
|
+
Defined in: [lib/undici/response.ts:84](https://github.com/maiyunnet/kebab/blob/master/lib/undici/response.ts#L84)
|
|
19322
19384
|
|
|
19323
19385
|
用户自定义的 content 内容
|
|
19324
19386
|
|
|
@@ -19469,9 +19531,9 @@ Defined in: [lib/vector.ts:85](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
19469
19531
|
|
|
19470
19532
|
***
|
|
19471
19533
|
|
|
19472
|
-
###
|
|
19534
|
+
### search()
|
|
19473
19535
|
|
|
19474
|
-
> **
|
|
19536
|
+
> **search**(`data`): `Promise`\<`false` \| `object`[]\>
|
|
19475
19537
|
|
|
19476
19538
|
Defined in: [lib/vector.ts:35](https://github.com/maiyunnet/kebab/blob/master/lib/vector.ts#L35)
|
|
19477
19539
|
|
|
@@ -23703,7 +23765,7 @@ Defined in: [sys/mod.ts:68](https://github.com/maiyunnet/kebab/blob/master/sys/m
|
|
|
23703
23765
|
|
|
23704
23766
|
> `protected` **\_keyGenerator**(): `string`
|
|
23705
23767
|
|
|
23706
|
-
Defined in: [sys/mod.ts:
|
|
23768
|
+
Defined in: [sys/mod.ts:1797](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1797)
|
|
23707
23769
|
|
|
23708
23770
|
当 _key 不为空时,则依据继承此方法的方法自动生成填充 key
|
|
23709
23771
|
|
|
@@ -23725,7 +23787,7 @@ Defined in: [sys/mod.ts:1785](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23725
23787
|
|
|
23726
23788
|
> **all**(): `Promise`\<`false` \| [`Rows`](Rows.md)\<`Mod`\>\>
|
|
23727
23789
|
|
|
23728
|
-
Defined in: [sys/mod.ts:
|
|
23790
|
+
Defined in: [sys/mod.ts:1139](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1139)
|
|
23729
23791
|
|
|
23730
23792
|
##### Returns
|
|
23731
23793
|
|
|
@@ -23735,7 +23797,7 @@ Defined in: [sys/mod.ts:1127](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23735
23797
|
|
|
23736
23798
|
> **all**(`key`): `Promise`\<`false` \| `Record`\<`string`, `Mod`\>\>
|
|
23737
23799
|
|
|
23738
|
-
Defined in: [sys/mod.ts:
|
|
23800
|
+
Defined in: [sys/mod.ts:1140](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1140)
|
|
23739
23801
|
|
|
23740
23802
|
##### Parameters
|
|
23741
23803
|
|
|
@@ -23761,7 +23823,7 @@ Defined in: [sys/mod.ts:1128](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23761
23823
|
|
|
23762
23824
|
> **allArray**(): `Promise`\<`false` \| `Record`\<`string`, `any`\>[]\>
|
|
23763
23825
|
|
|
23764
|
-
Defined in: [sys/mod.ts:
|
|
23826
|
+
Defined in: [sys/mod.ts:1318](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1318)
|
|
23765
23827
|
|
|
23766
23828
|
##### Returns
|
|
23767
23829
|
|
|
@@ -23771,7 +23833,7 @@ Defined in: [sys/mod.ts:1306](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23771
23833
|
|
|
23772
23834
|
> **allArray**(`key`): `Promise`\<`false` \| `Record`\<`string`, `Record`\<`string`, `any`\>\>\>
|
|
23773
23835
|
|
|
23774
|
-
Defined in: [sys/mod.ts:
|
|
23836
|
+
Defined in: [sys/mod.ts:1319](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1319)
|
|
23775
23837
|
|
|
23776
23838
|
##### Parameters
|
|
23777
23839
|
|
|
@@ -23789,7 +23851,7 @@ Defined in: [sys/mod.ts:1307](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23789
23851
|
|
|
23790
23852
|
> **append**(`sql`): `this`
|
|
23791
23853
|
|
|
23792
|
-
Defined in: [sys/mod.ts:
|
|
23854
|
+
Defined in: [sys/mod.ts:1706](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1706)
|
|
23793
23855
|
|
|
23794
23856
|
在 sql 最后追加字符串
|
|
23795
23857
|
|
|
@@ -23809,7 +23871,7 @@ Defined in: [sys/mod.ts:1694](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23809
23871
|
|
|
23810
23872
|
> **by**(`c`, `d?`): `this`
|
|
23811
23873
|
|
|
23812
|
-
Defined in: [sys/mod.ts:
|
|
23874
|
+
Defined in: [sys/mod.ts:1662](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1662)
|
|
23813
23875
|
|
|
23814
23876
|
ORDER BY
|
|
23815
23877
|
|
|
@@ -23837,7 +23899,7 @@ ORDER BY
|
|
|
23837
23899
|
|
|
23838
23900
|
> **contain**(`contain`): `this`
|
|
23839
23901
|
|
|
23840
|
-
Defined in: [sys/mod.ts:
|
|
23902
|
+
Defined in: [sys/mod.ts:1715](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1715)
|
|
23841
23903
|
|
|
23842
23904
|
设置闭包含数据
|
|
23843
23905
|
|
|
@@ -23865,7 +23927,7 @@ Defined in: [sys/mod.ts:1703](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23865
23927
|
|
|
23866
23928
|
> **count**(): `Promise`\<`number`\>
|
|
23867
23929
|
|
|
23868
|
-
Defined in: [sys/mod.ts:
|
|
23930
|
+
Defined in: [sys/mod.ts:1526](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1526)
|
|
23869
23931
|
|
|
23870
23932
|
根据当前条件,筛选出当前条目该有的数据条数
|
|
23871
23933
|
|
|
@@ -23879,7 +23941,7 @@ Defined in: [sys/mod.ts:1514](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23879
23941
|
|
|
23880
23942
|
> **countSql**(): `string`
|
|
23881
23943
|
|
|
23882
|
-
Defined in: [sys/mod.ts:
|
|
23944
|
+
Defined in: [sys/mod.ts:1547](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1547)
|
|
23883
23945
|
|
|
23884
23946
|
获取当前条件下的 count 的 SQL 语句
|
|
23885
23947
|
|
|
@@ -23909,7 +23971,7 @@ true-成功,false-报错,null-唯一键非 _$key 键冲突
|
|
|
23909
23971
|
|
|
23910
23972
|
> **crossJoin**(`f`, `s`, `index?`, `pre?`): `this`
|
|
23911
23973
|
|
|
23912
|
-
Defined in: [sys/mod.ts:
|
|
23974
|
+
Defined in: [sys/mod.ts:1622](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1622)
|
|
23913
23975
|
|
|
23914
23976
|
cross join 方法
|
|
23915
23977
|
|
|
@@ -23957,7 +24019,7 @@ ON 信息
|
|
|
23957
24019
|
|
|
23958
24020
|
> **explain**(`all?`): `Promise`\<`string` \| `false`\>
|
|
23959
24021
|
|
|
23960
|
-
Defined in: [sys/mod.ts:
|
|
24022
|
+
Defined in: [sys/mod.ts:1444](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1444)
|
|
23961
24023
|
|
|
23962
24024
|
##### Parameters
|
|
23963
24025
|
|
|
@@ -23973,7 +24035,7 @@ Defined in: [sys/mod.ts:1432](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23973
24035
|
|
|
23974
24036
|
> **explain**(`all`): `Promise`\<`false` \| `Record`\<`string`, `any`\>\>
|
|
23975
24037
|
|
|
23976
|
-
Defined in: [sys/mod.ts:
|
|
24038
|
+
Defined in: [sys/mod.ts:1445](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1445)
|
|
23977
24039
|
|
|
23978
24040
|
##### Parameters
|
|
23979
24041
|
|
|
@@ -23991,7 +24053,7 @@ Defined in: [sys/mod.ts:1433](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
23991
24053
|
|
|
23992
24054
|
> **filter**(`s`): `this`
|
|
23993
24055
|
|
|
23994
|
-
Defined in: [sys/mod.ts:
|
|
24056
|
+
Defined in: [sys/mod.ts:1640](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1640)
|
|
23995
24057
|
|
|
23996
24058
|
筛选器
|
|
23997
24059
|
|
|
@@ -24025,7 +24087,7 @@ Defined in: [sys/mod.ts:1628](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24025
24087
|
|
|
24026
24088
|
> **first**(`lock`, `array`): `Promise`\<`false` \| `Record`\<`string`, `any`\> \| `null`\>
|
|
24027
24089
|
|
|
24028
|
-
Defined in: [sys/mod.ts:
|
|
24090
|
+
Defined in: [sys/mod.ts:1028](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1028)
|
|
24029
24091
|
|
|
24030
24092
|
##### Parameters
|
|
24031
24093
|
|
|
@@ -24045,7 +24107,7 @@ Defined in: [sys/mod.ts:1016](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24045
24107
|
|
|
24046
24108
|
> **first**(`lock?`, `array?`): `Promise`\<`false` \| `Mod` & `Record`\<`string`, `any`\> \| `null`\>
|
|
24047
24109
|
|
|
24048
|
-
Defined in: [sys/mod.ts:
|
|
24110
|
+
Defined in: [sys/mod.ts:1032](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1032)
|
|
24049
24111
|
|
|
24050
24112
|
##### Parameters
|
|
24051
24113
|
|
|
@@ -24067,7 +24129,7 @@ Defined in: [sys/mod.ts:1020](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24067
24129
|
|
|
24068
24130
|
> **firstArray**(`lock?`): `Promise`\<`false` \| `Record`\<`string`, `any`\> \| `null`\>
|
|
24069
24131
|
|
|
24070
|
-
Defined in: [sys/mod.ts:
|
|
24132
|
+
Defined in: [sys/mod.ts:1072](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1072)
|
|
24071
24133
|
|
|
24072
24134
|
获取数据库第一个原生对象
|
|
24073
24135
|
|
|
@@ -24089,7 +24151,7 @@ Defined in: [sys/mod.ts:1060](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24089
24151
|
|
|
24090
24152
|
> **format**(`sql?`, `data?`): `string`
|
|
24091
24153
|
|
|
24092
|
-
Defined in: [sys/mod.ts:
|
|
24154
|
+
Defined in: [sys/mod.ts:1742](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1742)
|
|
24093
24155
|
|
|
24094
24156
|
获取带 data 的 sql 语句
|
|
24095
24157
|
|
|
@@ -24117,7 +24179,7 @@ sql 语句
|
|
|
24117
24179
|
|
|
24118
24180
|
> **fullJoin**(`f`, `s`, `index?`, `pre?`): `this`
|
|
24119
24181
|
|
|
24120
|
-
Defined in: [sys/mod.ts:
|
|
24182
|
+
Defined in: [sys/mod.ts:1610](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1610)
|
|
24121
24183
|
|
|
24122
24184
|
full join 方法
|
|
24123
24185
|
|
|
@@ -24179,7 +24241,7 @@ Defined in: [sys/mod.ts:813](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24179
24241
|
|
|
24180
24242
|
> **getData**(): `any`[]
|
|
24181
24243
|
|
|
24182
|
-
Defined in: [sys/mod.ts:
|
|
24244
|
+
Defined in: [sys/mod.ts:1733](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1733)
|
|
24183
24245
|
|
|
24184
24246
|
获取全部 data
|
|
24185
24247
|
|
|
@@ -24193,7 +24255,7 @@ Defined in: [sys/mod.ts:1721](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24193
24255
|
|
|
24194
24256
|
> **getSql**(): `string`
|
|
24195
24257
|
|
|
24196
|
-
Defined in: [sys/mod.ts:
|
|
24258
|
+
Defined in: [sys/mod.ts:1726](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1726)
|
|
24197
24259
|
|
|
24198
24260
|
获取 sql 语句
|
|
24199
24261
|
|
|
@@ -24207,7 +24269,7 @@ Defined in: [sys/mod.ts:1714](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24207
24269
|
|
|
24208
24270
|
> **group**(`c`): `this`
|
|
24209
24271
|
|
|
24210
|
-
Defined in: [sys/mod.ts:
|
|
24272
|
+
Defined in: [sys/mod.ts:1671](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1671)
|
|
24211
24273
|
|
|
24212
24274
|
GROUP BY
|
|
24213
24275
|
|
|
@@ -24229,7 +24291,7 @@ GROUP BY
|
|
|
24229
24291
|
|
|
24230
24292
|
> **having**(`s`): `this`
|
|
24231
24293
|
|
|
24232
|
-
Defined in: [sys/mod.ts:
|
|
24294
|
+
Defined in: [sys/mod.ts:1631](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1631)
|
|
24233
24295
|
|
|
24234
24296
|
筛选器
|
|
24235
24297
|
|
|
@@ -24251,7 +24313,7 @@ Defined in: [sys/mod.ts:1619](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24251
24313
|
|
|
24252
24314
|
> **innerJoin**(`f`, `s`, `index?`, `pre?`): `this`
|
|
24253
24315
|
|
|
24254
|
-
Defined in: [sys/mod.ts:
|
|
24316
|
+
Defined in: [sys/mod.ts:1598](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1598)
|
|
24255
24317
|
|
|
24256
24318
|
inner join 方法
|
|
24257
24319
|
|
|
@@ -24291,7 +24353,7 @@ ON 信息
|
|
|
24291
24353
|
|
|
24292
24354
|
> **join**(`f`, `s?`, `type?`, `index?`, `pre?`): `this`
|
|
24293
24355
|
|
|
24294
|
-
Defined in: [sys/mod.ts:
|
|
24356
|
+
Defined in: [sys/mod.ts:1562](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1562)
|
|
24295
24357
|
|
|
24296
24358
|
#### Parameters
|
|
24297
24359
|
|
|
@@ -24335,7 +24397,7 @@ ON 信息
|
|
|
24335
24397
|
|
|
24336
24398
|
> **langText**(`col`, `lang`): `string`
|
|
24337
24399
|
|
|
24338
|
-
Defined in: [sys/mod.ts:
|
|
24400
|
+
Defined in: [sys/mod.ts:1777](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1777)
|
|
24339
24401
|
|
|
24340
24402
|
获取字段的可用语种文本
|
|
24341
24403
|
|
|
@@ -24363,7 +24425,7 @@ Defined in: [sys/mod.ts:1765](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24363
24425
|
|
|
24364
24426
|
> **leftJoin**(`f`, `s`, `index?`, `pre?`): `this`
|
|
24365
24427
|
|
|
24366
|
-
Defined in: [sys/mod.ts:
|
|
24428
|
+
Defined in: [sys/mod.ts:1574](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1574)
|
|
24367
24429
|
|
|
24368
24430
|
left join 方法
|
|
24369
24431
|
|
|
@@ -24403,7 +24465,7 @@ ON 信息
|
|
|
24403
24465
|
|
|
24404
24466
|
> **limit**(`a`, `b?`): `this`
|
|
24405
24467
|
|
|
24406
|
-
Defined in: [sys/mod.ts:
|
|
24468
|
+
Defined in: [sys/mod.ts:1684](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1684)
|
|
24407
24469
|
|
|
24408
24470
|
LIMIT
|
|
24409
24471
|
|
|
@@ -24431,7 +24493,7 @@ LIMIT
|
|
|
24431
24493
|
|
|
24432
24494
|
> **page**(`count`, `page?`): `this`
|
|
24433
24495
|
|
|
24434
|
-
Defined in: [sys/mod.ts:
|
|
24496
|
+
Defined in: [sys/mod.ts:1695](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1695)
|
|
24435
24497
|
|
|
24436
24498
|
分页
|
|
24437
24499
|
|
|
@@ -24481,7 +24543,7 @@ Defined in: [sys/mod.ts:941](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24481
24543
|
|
|
24482
24544
|
> **remove**(): `Promise`\<`boolean`\>
|
|
24483
24545
|
|
|
24484
|
-
Defined in: [sys/mod.ts:
|
|
24546
|
+
Defined in: [sys/mod.ts:1006](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1006)
|
|
24485
24547
|
|
|
24486
24548
|
移除本条目
|
|
24487
24549
|
|
|
@@ -24495,7 +24557,7 @@ Defined in: [sys/mod.ts:998](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24495
24557
|
|
|
24496
24558
|
> **rightJoin**(`f`, `s`, `index?`, `pre?`): `this`
|
|
24497
24559
|
|
|
24498
|
-
Defined in: [sys/mod.ts:
|
|
24560
|
+
Defined in: [sys/mod.ts:1586](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1586)
|
|
24499
24561
|
|
|
24500
24562
|
right join 方法
|
|
24501
24563
|
|
|
@@ -24535,7 +24597,7 @@ ON 信息
|
|
|
24535
24597
|
|
|
24536
24598
|
> **save**(`where?`): `Promise`\<`boolean`\>
|
|
24537
24599
|
|
|
24538
|
-
Defined in: [sys/mod.ts:
|
|
24600
|
+
Defined in: [sys/mod.ts:973](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L973)
|
|
24539
24601
|
|
|
24540
24602
|
更新 set 的数据到数据库,有未保存数据时才保存
|
|
24541
24603
|
|
|
@@ -24627,7 +24689,7 @@ Defined in: [sys/mod.ts:775](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24627
24689
|
|
|
24628
24690
|
> **toArray**\<`TC`\>(): [`TOnlyProperties`](../type-aliases/TOnlyProperties.md)\<`InstanceType`\<`TC`\>\> & `Record`\<`string`, `any`\>
|
|
24629
24691
|
|
|
24630
|
-
Defined in: [sys/mod.ts:
|
|
24692
|
+
Defined in: [sys/mod.ts:1749](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1749)
|
|
24631
24693
|
|
|
24632
24694
|
获取值对象,获取的是新创建的数组
|
|
24633
24695
|
|
|
@@ -24647,7 +24709,7 @@ Defined in: [sys/mod.ts:1737](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24647
24709
|
|
|
24648
24710
|
> **total**(`f?`): `Promise`\<`number`\>
|
|
24649
24711
|
|
|
24650
|
-
Defined in: [sys/mod.ts:
|
|
24712
|
+
Defined in: [sys/mod.ts:1502](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1502)
|
|
24651
24713
|
|
|
24652
24714
|
获取总条数,自动抛弃 LIMIT,仅用于获取数据的情况(select)
|
|
24653
24715
|
|
|
@@ -24667,7 +24729,7 @@ Defined in: [sys/mod.ts:1490](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24667
24729
|
|
|
24668
24730
|
> **union**(`f`, `type?`): `this`
|
|
24669
24731
|
|
|
24670
|
-
Defined in: [sys/mod.ts:
|
|
24732
|
+
Defined in: [sys/mod.ts:1083](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1083)
|
|
24671
24733
|
|
|
24672
24734
|
联合查询表数据
|
|
24673
24735
|
|
|
@@ -24695,7 +24757,7 @@ Defined in: [sys/mod.ts:1071](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24695
24757
|
|
|
24696
24758
|
> **unionAll**(`f`): `this`
|
|
24697
24759
|
|
|
24698
|
-
Defined in: [sys/mod.ts:
|
|
24760
|
+
Defined in: [sys/mod.ts:1113](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1113)
|
|
24699
24761
|
|
|
24700
24762
|
所有联合查询表数据
|
|
24701
24763
|
|
|
@@ -24717,7 +24779,7 @@ Defined in: [sys/mod.ts:1101](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24717
24779
|
|
|
24718
24780
|
> **unsaved**(): `boolean`
|
|
24719
24781
|
|
|
24720
|
-
Defined in: [sys/mod.ts:
|
|
24782
|
+
Defined in: [sys/mod.ts:1768](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1768)
|
|
24721
24783
|
|
|
24722
24784
|
当前是否设置了未保存 --=
|
|
24723
24785
|
|
|
@@ -24731,7 +24793,7 @@ Defined in: [sys/mod.ts:1756](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
24731
24793
|
|
|
24732
24794
|
> **updates**(): `Record`\<`string`, `any`\>
|
|
24733
24795
|
|
|
24734
|
-
Defined in: [sys/mod.ts:
|
|
24796
|
+
Defined in: [sys/mod.ts:1757](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1757)
|
|
24735
24797
|
|
|
24736
24798
|
获取当前设置要提交的数据
|
|
24737
24799
|
|
|
@@ -24767,7 +24829,7 @@ Defined in: [sys/mod.ts:911](https://github.com/maiyunnet/kebab/blob/master/sys/
|
|
|
24767
24829
|
|
|
24768
24830
|
> **where**(`s`): `this`
|
|
24769
24831
|
|
|
24770
|
-
Defined in: [sys/mod.ts:
|
|
24832
|
+
Defined in: [sys/mod.ts:1651](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1651)
|
|
24771
24833
|
|
|
24772
24834
|
是 filter 的别名
|
|
24773
24835
|
|
|
@@ -25941,7 +26003,7 @@ sys/mod/interfaces/IModUnionItem.md
|
|
|
25941
26003
|
|
|
25942
26004
|
# Interface: IModUnionItem
|
|
25943
26005
|
|
|
25944
|
-
Defined in: [sys/mod.ts:
|
|
26006
|
+
Defined in: [sys/mod.ts:1811](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1811)
|
|
25945
26007
|
|
|
25946
26008
|
## Properties
|
|
25947
26009
|
|
|
@@ -25949,7 +26011,7 @@ Defined in: [sys/mod.ts:1799](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
25949
26011
|
|
|
25950
26012
|
> **field**: `string`
|
|
25951
26013
|
|
|
25952
|
-
Defined in: [sys/mod.ts:
|
|
26014
|
+
Defined in: [sys/mod.ts:1812](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1812)
|
|
25953
26015
|
|
|
25954
26016
|
***
|
|
25955
26017
|
|
|
@@ -25957,7 +26019,7 @@ Defined in: [sys/mod.ts:1800](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
25957
26019
|
|
|
25958
26020
|
> `optional` **where?**: `any`
|
|
25959
26021
|
|
|
25960
|
-
Defined in: [sys/mod.ts:
|
|
26022
|
+
Defined in: [sys/mod.ts:1813](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1813)
|
|
25961
26023
|
|
|
25962
26024
|
sys/mod/interfaces/IRows.md
|
|
25963
26025
|
---
|
|
@@ -25970,7 +26032,7 @@ sys/mod/interfaces/IRows.md
|
|
|
25970
26032
|
|
|
25971
26033
|
# Interface: IRows\<T\>
|
|
25972
26034
|
|
|
25973
|
-
Defined in: [sys/mod.ts:
|
|
26035
|
+
Defined in: [sys/mod.ts:1805](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1805)
|
|
25974
26036
|
|
|
25975
26037
|
## Extends
|
|
25976
26038
|
|
|
@@ -25988,7 +26050,7 @@ Defined in: [sys/mod.ts:1793](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
25988
26050
|
|
|
25989
26051
|
> `readonly` **length**: `number`
|
|
25990
26052
|
|
|
25991
|
-
Defined in: [sys/mod.ts:
|
|
26053
|
+
Defined in: [sys/mod.ts:1806](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1806)
|
|
25992
26054
|
|
|
25993
26055
|
## Methods
|
|
25994
26056
|
|
|
@@ -25996,7 +26058,7 @@ Defined in: [sys/mod.ts:1794](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
25996
26058
|
|
|
25997
26059
|
> **item**(`index`): `T`
|
|
25998
26060
|
|
|
25999
|
-
Defined in: [sys/mod.ts:
|
|
26061
|
+
Defined in: [sys/mod.ts:1807](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1807)
|
|
26000
26062
|
|
|
26001
26063
|
#### Parameters
|
|
26002
26064
|
|
|
@@ -26014,7 +26076,7 @@ Defined in: [sys/mod.ts:1795](https://github.com/maiyunnet/kebab/blob/master/sys
|
|
|
26014
26076
|
|
|
26015
26077
|
> **toArray**(): `Record`\<`string`, `any`\>[]
|
|
26016
26078
|
|
|
26017
|
-
Defined in: [sys/mod.ts:
|
|
26079
|
+
Defined in: [sys/mod.ts:1808](https://github.com/maiyunnet/kebab/blob/master/sys/mod.ts#L1808)
|
|
26018
26080
|
|
|
26019
26081
|
#### Returns
|
|
26020
26082
|
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '9.
|
|
9
|
+
export const VER = '9.11.1';
|
|
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
|
@@ -32,7 +32,11 @@ export declare enum ESERVICE {
|
|
|
32
32
|
/** --- 火山引擎中国大陆区 --- */
|
|
33
33
|
'VOLCN' = 8,
|
|
34
34
|
/** --- 火山引擎国际区 --- */
|
|
35
|
-
'VOLAS' = 9
|
|
35
|
+
'VOLAS' = 9,
|
|
36
|
+
/** --- OpenRouter --- */
|
|
37
|
+
'OPENROUTER' = 10,
|
|
38
|
+
/** --- OfoxAI --- */
|
|
39
|
+
'OFOX' = 11
|
|
36
40
|
}
|
|
37
41
|
/** --- 选项 --- */
|
|
38
42
|
export interface IOptions {
|
|
@@ -59,6 +63,10 @@ export declare class Ai {
|
|
|
59
63
|
chat(body: openai.default.Chat.Completions.ChatCompletionCreateParamsNonStreaming): Promise<openai.APIPromise<openai.default.Chat.ChatCompletion> | false>;
|
|
60
64
|
/** --- 创建流式对话 --- */
|
|
61
65
|
chat(body: openai.default.Chat.Completions.ChatCompletionCreateParamsStreaming): Promise<openai.APIPromise<streaming.Stream<openai.default.Chat.ChatCompletionChunk>> | false>;
|
|
66
|
+
/** --- 创建非流式 Response --- */
|
|
67
|
+
response(body: openai.default.Responses.ResponseCreateParamsNonStreaming): Promise<openai.APIPromise<openai.default.Responses.Response> | false>;
|
|
68
|
+
/** --- 创建流式 Response --- */
|
|
69
|
+
response(body: openai.default.Responses.ResponseCreateParamsStreaming): Promise<openai.APIPromise<streaming.Stream<openai.default.Responses.ResponseStreamEvent>> | false>;
|
|
62
70
|
/** --- 创建向量 --- */
|
|
63
71
|
embedding(body: openai.default.EmbeddingCreateParams): Promise<openai.APIPromise<openai.default.CreateEmbeddingResponse> | false>;
|
|
64
72
|
/** --- 生成图像,不支持 GEMINI、GROK 服务商 --- */
|
package/lib/ai.js
CHANGED
|
@@ -34,6 +34,11 @@ export var ESERVICE;
|
|
|
34
34
|
ESERVICE[ESERVICE["VOLCN"] = 8] = "VOLCN";
|
|
35
35
|
/** --- 火山引擎国际区 --- */
|
|
36
36
|
ESERVICE[ESERVICE["VOLAS"] = 9] = "VOLAS";
|
|
37
|
+
// --- 以下为第三方服务商 ---
|
|
38
|
+
/** --- OpenRouter --- */
|
|
39
|
+
ESERVICE[ESERVICE["OPENROUTER"] = 10] = "OPENROUTER";
|
|
40
|
+
/** --- OfoxAI --- */
|
|
41
|
+
ESERVICE[ESERVICE["OFOX"] = 11] = "OFOX";
|
|
37
42
|
})(ESERVICE || (ESERVICE = {}));
|
|
38
43
|
/** --- openai 的连接对象 --- */
|
|
39
44
|
const links = [];
|
|
@@ -94,6 +99,14 @@ export class Ai {
|
|
|
94
99
|
endpoint = opt.endpoint ?? `https://ark.ap-southeast.bytepluses.com/api/v3`;
|
|
95
100
|
break;
|
|
96
101
|
}
|
|
102
|
+
case ESERVICE.OPENROUTER: {
|
|
103
|
+
endpoint = opt.endpoint ?? `https://openrouter.ai/api/v1`;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case ESERVICE.OFOX: {
|
|
107
|
+
endpoint = opt.endpoint ?? `https://api.ofox.ai/v1`;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
97
110
|
default: {
|
|
98
111
|
// --- ESERVICE.AZURE3 ---
|
|
99
112
|
endpoint = opt.endpoint ?? configAi.endpoint ?? '';
|
|
@@ -136,6 +149,19 @@ export class Ai {
|
|
|
136
149
|
return false;
|
|
137
150
|
}
|
|
138
151
|
}
|
|
152
|
+
/** --- 创建 Response --- */
|
|
153
|
+
async response(body) {
|
|
154
|
+
try {
|
|
155
|
+
return await this.link.responses.create(body);
|
|
156
|
+
}
|
|
157
|
+
catch (e) {
|
|
158
|
+
if (!e.message.includes('Input data may contain inappropriate content')) {
|
|
159
|
+
lCore.debug('[AI][RESPONSE]', e);
|
|
160
|
+
lCore.log(this._ctr ?? {}, `[AI][RESPONSE] ${e.message}`, '-error');
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
139
165
|
/** --- 创建向量 --- */
|
|
140
166
|
async embedding(body) {
|
|
141
167
|
try {
|
|
@@ -151,6 +177,9 @@ export class Ai {
|
|
|
151
177
|
}
|
|
152
178
|
/** --- 生成图像,不支持 GEMINI、GROK 服务商 --- */
|
|
153
179
|
async image(opt) {
|
|
180
|
+
if (!this.link.apiKey) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
154
183
|
const seed = opt.seed ?? lCore.rand(0, 2147483647);
|
|
155
184
|
switch (this._service) {
|
|
156
185
|
case ESERVICE.ALICN:
|
|
@@ -300,6 +329,12 @@ export class Ai {
|
|
|
300
329
|
return false;
|
|
301
330
|
}
|
|
302
331
|
}
|
|
332
|
+
case ESERVICE.OPENROUTER: {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
case ESERVICE.OFOX: {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
303
338
|
}
|
|
304
339
|
}
|
|
305
340
|
/** --- 异步生成视频,仅支持 ALICN、ALIAS、ALINE --- */
|
|
@@ -307,6 +342,9 @@ export class Ai {
|
|
|
307
342
|
if (this._service !== ESERVICE.ALICN && this._service !== ESERVICE.ALIAS && this._service !== ESERVICE.ALINE) {
|
|
308
343
|
return false;
|
|
309
344
|
}
|
|
345
|
+
if (!this.link.apiKey) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
310
348
|
const mode = opt.mode ?? 'text';
|
|
311
349
|
const imgs = opt.imgs ?? [];
|
|
312
350
|
const resolution = opt.resolution ?? '720p';
|
|
@@ -442,6 +480,9 @@ export class Ai {
|
|
|
442
480
|
if (this._service !== ESERVICE.ALICN && this._service !== ESERVICE.ALIAS && this._service !== ESERVICE.ALINE) {
|
|
443
481
|
return false;
|
|
444
482
|
}
|
|
483
|
+
if (!this.link.apiKey) {
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
445
486
|
try {
|
|
446
487
|
const res = await this._fetch(`https://dashscope${this._service === ESERVICE.ALIAS ? '-intl' : (this._service === ESERVICE.ALINE ? '-us' : '')}.aliyuncs.com/api/v1/tasks/${opt.task}`, {
|
|
447
488
|
'method': 'GET',
|
package/lib/core.js
CHANGED
|
@@ -858,7 +858,9 @@ export function log(opt, msg, fend = '') {
|
|
|
858
858
|
'cf': '',
|
|
859
859
|
'x': ''
|
|
860
860
|
};
|
|
861
|
-
|
|
861
|
+
/** --- 文件和内容统一使用同一时间点 --- */
|
|
862
|
+
const now = new Date();
|
|
863
|
+
const [y, m, d, h] = lTime.format(null, 'Y-m-d-H', now).split('-');
|
|
862
864
|
let path = kebab.LOG_CWD + hostname + fend + '/' + y + '/' + m + '/' + d + '/';
|
|
863
865
|
const rtn = await lFs.mkdir(path, 0o777);
|
|
864
866
|
if (!rtn) {
|
|
@@ -869,8 +871,8 @@ export function log(opt, msg, fend = '') {
|
|
|
869
871
|
// --- JSON Lines 格式 ---
|
|
870
872
|
path += h + '.jsonl';
|
|
871
873
|
const entry = lText.stringifyJson({
|
|
872
|
-
'time': lTime.format(null, 'H:i:s'),
|
|
873
|
-
'unix': lTime.stamp(),
|
|
874
|
+
'time': lTime.format(null, 'H:i:s', now),
|
|
875
|
+
'unix': lTime.stamp(now),
|
|
874
876
|
'url': urlFull + wpath + (Object.keys(get).length ? '?' + lText.queryStringify(get) : ''),
|
|
875
877
|
'cookie': cookie,
|
|
876
878
|
'session': session,
|
|
@@ -900,8 +902,8 @@ export function log(opt, msg, fend = '') {
|
|
|
900
902
|
}
|
|
901
903
|
}
|
|
902
904
|
await lFs.putContent(path, '"' +
|
|
903
|
-
lText.csvescape(lTime.format(null, 'H:i:s')) + '","' +
|
|
904
|
-
lText.csvescape(lTime.stamp().toString()) + '","' +
|
|
905
|
+
lText.csvescape(lTime.format(null, 'H:i:s', now)) + '","' +
|
|
906
|
+
lText.csvescape(lTime.stamp(now).toString()) + '","' +
|
|
905
907
|
lText.csvescape(urlFull + wpath + (Object.keys(get).length ? '?' + lText.queryStringify(get) : '')) + '","' +
|
|
906
908
|
lText.csvescape(lText.queryStringify(cookie)) + '","' +
|
|
907
909
|
lText.csvescape(lText.stringifyJson(session)) + '","' +
|
package/lib/undici/response.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare class Response {
|
|
|
31
31
|
/**
|
|
32
32
|
* --- 获取响应读取流对象 ---
|
|
33
33
|
*/
|
|
34
|
-
getStream(): (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) |
|
|
34
|
+
getStream(): zlib.BrotliDecompress | zlib.Gunzip | zlib.Inflate | (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | null;
|
|
35
35
|
/**
|
|
36
36
|
* --- 获取原生响应读取流对象 ---
|
|
37
37
|
*/
|
package/lib/undici/response.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as zlib from 'zlib';
|
|
2
2
|
import * as lBuffer from '#kebab/lib/buffer.js';
|
|
3
|
+
import * as lCore from '#kebab/lib/core.js';
|
|
3
4
|
import * as lText from '#kebab/lib/text.js';
|
|
4
5
|
export class Response {
|
|
5
6
|
/** --- httpClient 请求对象 --- */
|
|
@@ -26,7 +27,8 @@ export class Response {
|
|
|
26
27
|
}
|
|
27
28
|
return this._req ? await lBuffer.getFull(stream) : null;
|
|
28
29
|
}
|
|
29
|
-
catch {
|
|
30
|
+
catch (e) {
|
|
31
|
+
lCore.log({}, '[Undici][Response][getContent] ' + e.message, '-error');
|
|
30
32
|
return null;
|
|
31
33
|
}
|
|
32
34
|
}
|
|
@@ -39,7 +41,8 @@ export class Response {
|
|
|
39
41
|
}
|
|
40
42
|
return buf.toString('utf-8');
|
|
41
43
|
}
|
|
42
|
-
catch {
|
|
44
|
+
catch (e) {
|
|
45
|
+
lCore.log({}, '[Undici][Response][getText] ' + e.message, '-error');
|
|
43
46
|
return null;
|
|
44
47
|
}
|
|
45
48
|
}
|
|
@@ -52,7 +55,8 @@ export class Response {
|
|
|
52
55
|
}
|
|
53
56
|
return lText.parseJson(text);
|
|
54
57
|
}
|
|
55
|
-
catch {
|
|
58
|
+
catch (e) {
|
|
59
|
+
lCore.log({}, '[Undici][Response][getJson] ' + e.message, '-error');
|
|
56
60
|
return null;
|
|
57
61
|
}
|
|
58
62
|
}
|
package/lib/vector.d.ts
CHANGED
package/lib/vector.js
CHANGED
|
@@ -8,7 +8,7 @@ export class Vector {
|
|
|
8
8
|
this._etc = etc;
|
|
9
9
|
}
|
|
10
10
|
/** --- 搜索 --- */
|
|
11
|
-
async
|
|
11
|
+
async search(data) {
|
|
12
12
|
const body = {
|
|
13
13
|
'dbName': this._etc.name,
|
|
14
14
|
'collectionName': data.collection,
|
|
@@ -27,15 +27,15 @@ export class Vector {
|
|
|
27
27
|
try {
|
|
28
28
|
const res = await lUndici.postJsonResponseJson(`http://${this._etc.host}:${this._etc.port}/v2/vectordb/entities/search`, body, { 'headers': { 'Authorization': `Bearer ${this._etc.user}:${this._etc.pwd}` } });
|
|
29
29
|
if (res?.code !== 0) {
|
|
30
|
-
lCore.log({}, '[VECTOR][
|
|
31
|
-
lCore.debug('[VECTOR][
|
|
30
|
+
lCore.log({}, '[VECTOR][search][error] ' + (res?.message ?? ''), '-error');
|
|
31
|
+
lCore.debug('[VECTOR][search]', res);
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
return res.data;
|
|
35
35
|
}
|
|
36
36
|
catch (e) {
|
|
37
|
-
lCore.log({}, '[VECTOR][
|
|
38
|
-
lCore.debug('[VECTOR][
|
|
37
|
+
lCore.log({}, '[VECTOR][search][error] ' + e.message, '-error');
|
|
38
|
+
lCore.debug('[VECTOR][search]', e);
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
41
41
|
}
|
package/package.json
CHANGED
package/sys/cmd.js
CHANGED
|
@@ -191,6 +191,10 @@ async function run() {
|
|
|
191
191
|
config.ai['VOLCN'].skey ??= '';
|
|
192
192
|
config.ai['VOLAS'] ??= {};
|
|
193
193
|
config.ai['VOLAS'].skey ??= '';
|
|
194
|
+
config.ai['OPENROUTER'] ??= {};
|
|
195
|
+
config.ai['OPENROUTER'].skey ??= '';
|
|
196
|
+
config.ai['OFOX'] ??= {};
|
|
197
|
+
config.ai['OFOX'].skey ??= '';
|
|
194
198
|
// --- config - vector ---
|
|
195
199
|
config.vector ??= {};
|
|
196
200
|
config.vector.host ??= '127.0.0.1';
|
package/sys/master.js
CHANGED
package/sys/mod.js
CHANGED
|
@@ -681,6 +681,10 @@ export default class Mod {
|
|
|
681
681
|
*/
|
|
682
682
|
async refresh(lock = false) {
|
|
683
683
|
const cstr = this.constructor;
|
|
684
|
+
if (!this._data[cstr._$primary]) {
|
|
685
|
+
lCore.log(this._ctr ?? {}, '[MOD][refresh] primary key not found', '-error');
|
|
686
|
+
return false;
|
|
687
|
+
}
|
|
684
688
|
this._sql.select('*', cstr._$table + (this._index ? ('_' + this._index[0]) : '')).where([{
|
|
685
689
|
[cstr._$primary]: this._data[cstr._$primary]
|
|
686
690
|
}]);
|
|
@@ -711,6 +715,10 @@ export default class Mod {
|
|
|
711
715
|
return true;
|
|
712
716
|
}
|
|
713
717
|
const cstr = this.constructor;
|
|
718
|
+
if (!this._data[cstr._$primary]) {
|
|
719
|
+
lCore.log(this._ctr ?? {}, '[MOD][save] primary key not found', '-error');
|
|
720
|
+
return false;
|
|
721
|
+
}
|
|
714
722
|
const updates = {};
|
|
715
723
|
for (const k in this._updates) {
|
|
716
724
|
updates[k] = this._data[k];
|
|
@@ -736,6 +744,10 @@ export default class Mod {
|
|
|
736
744
|
*/
|
|
737
745
|
async remove() {
|
|
738
746
|
const cstr = this.constructor;
|
|
747
|
+
if (!this._data[cstr._$primary]) {
|
|
748
|
+
lCore.log(this._ctr ?? {}, '[MOD][remove] primary key not found', '-error');
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
739
751
|
this._sql.delete(cstr._$table + (this._index ? ('_' + this._index[0]) : '')).where([{
|
|
740
752
|
[cstr._$primary]: this._data[cstr._$primary]
|
|
741
753
|
}]);
|
package/www/example/ctr/test.js
CHANGED
|
@@ -140,6 +140,7 @@ export default class extends sCtr.Ctr {
|
|
|
140
140
|
`<br><br><b>Ai:</b>`,
|
|
141
141
|
`<br><a href="${this._config.const.urlBase}test/ai-stream">View "test/ai-stream"</a>`,
|
|
142
142
|
`<br><a href="${this._config.const.urlBase}test/ai?action=chat">View "test/ai?action=chat"</a>`,
|
|
143
|
+
`<br><a href="${this._config.const.urlBase}test/ai?action=response">View "test/ai?action=response"</a>`,
|
|
143
144
|
`<br><a href="${this._config.const.urlBase}test/ai?action=text-to-image">View "test/ai?action=text-to-image"</a>`,
|
|
144
145
|
`<br><a href="${this._config.const.urlBase}test/ai?action=image-to-image">View "test/ai?action=image-to-image"</a>`,
|
|
145
146
|
`<br><a href="${this._config.const.urlBase}test/ai?action=text-to-video">View "test/ai?action=text-to-video"</a>`,
|
|
@@ -1728,12 +1729,12 @@ exec: ${JSON.stringify(exec)}<br><br>`);
|
|
|
1728
1729
|
}
|
|
1729
1730
|
async vector() {
|
|
1730
1731
|
const vector = lVector.get(this);
|
|
1731
|
-
const res = await vector.
|
|
1732
|
+
const res = await vector.search({
|
|
1732
1733
|
'collection': 'ai_wiki_content',
|
|
1733
1734
|
'metric': 'COSINE',
|
|
1734
1735
|
'data': [0.4100031323819555, 0.7188991736586672, 0.32890290245747833, 0.9187961849628559, 0.023142186415922916, 0.45239563148580797, 0.23537591588175988, 0.6848990771759962, 0.9865744633216178, 0.8239142304110896, 0.997768380245414, 0.3012929412655765, 0.13731236076734943, 0.5126131685642945, 0.9806290097015617, 0.1870468071764284, 0.17178642706602143, 0.4016660911946244, 0.15484433366942607, 0.29719222215610386, 0.3103748731148619, 0.6892950176658315, 0.01785695346759608, 0.08539564964986557, 0.2655959514380064, 0.9964617086704073, 0.2838371937684081, 0.14987010598298633, 0.6228479079557896, 0.8080833516756243, 0.15438562173495285, 0.5078008662168574, 0.27262149922940804, 0.23104911473240675, 0.6266656488428926, 0.8553958245035254, 0.11699454830789868, 0.2300336351244865, 0.3042943975707315, 0.20182231286864427, 0.14334825938359863, 0.5272057735967806, 0.6568390179350452, 0.11388912236667226, 0.4916225414998463, 0.4913046496135085, 0.6301252401085475, 0.26051075673874036, 0.17023441587522825, 0.371755148312803, 0.5831318953846139, 0.9756820442368113, 0.6818893859710211, 0.5188330204766185, 0.7868335112863099, 0.7263293211859105, 0.15777067513918275, 0.25071428052177835, 0.9055952502390328, 0.39066574162485046, 0.6694768856781026, 0.904527206408617, 0.5359679189729842, 0.42923033393177423, 0.6959492373261136, 0.4721197667950616, 0.6861043448179791, 0.05188999799541438, 0.7346607591003518, 0.1574483630625012, 0.9141756884547747, 0.9116789303557802, 0.7609450526832306, 0.7763073356227885, 0.7334996162535046, 0.8036447394427264, 0.21291521237560262, 0.4628513517221038, 0.005054981316060525, 0.6289756103407573, 0.9376033918403373, 0.79713161153396, 0.1795021378890418, 0.32421299215073773, 0.5585715705291334, 0.1964507020528392, 0.9170965358836494, 0.44199069294404825, 0.46924875851341463, 0.005915168915280544, 0.4519648598811945, 0.7817208441823769, 0.39630447274483926, 0.874803477246406, 0.02593537985516514, 0.03494415508402371, 0.6948556600612117, 0.02531235612016558, 0.3252859275909026, 0.6124602304575255, 0.6662991517754546, 0.054786469959723805, 0.09541281916656552, 0.047971618444194286, 0.9888851535738363, 0.09923862294731634, 0.37389883211204245, 0.0510449762242422, 0.5140187522339308, 0.9165108670272317, 0.473682888066292, 0.7553395418192084, 0.48450479101753663, 0.22080081972551513, 0.8461012374988566, 0.32711442729081885, 0.46740436391036244, 0.9330234279632854, 0.7456194346850014, 0.8575560505025164, 0.2617623984893922, 0.6418053194775086, 0.607749877895083, 0.2176063100000032, 0.5366633111896186, 0.9689538808794083, 0.8226310778269623, 0.4813948057818185]
|
|
1735
1736
|
});
|
|
1736
|
-
const echo = [`<pre>const res = await vector.
|
|
1737
|
+
const echo = [`<pre>const res = await vector.search({
|
|
1737
1738
|
'collection': 'oas_wiki',
|
|
1738
1739
|
'metric': 'COSINE',
|
|
1739
1740
|
'data': [0.4100031323819555, 0.7188991736586672, 0.32890290245747833, ...]
|
|
@@ -4095,11 +4096,13 @@ rtn.push(reader.readBCDString());</pre>${JSON.stringify(rtn)}`);
|
|
|
4095
4096
|
return echo.join('') + '<br>' + this._getEnd();
|
|
4096
4097
|
}
|
|
4097
4098
|
async ai() {
|
|
4099
|
+
this.timeout = 60_000 * 10;
|
|
4098
4100
|
const echo = [`<pre>const ai = lAi.get(this, {
|
|
4099
4101
|
'service': lAi.ESERVICE.${lText.htmlescape(this._get['service']?.toUpperCase() ?? 'ALICN')},
|
|
4100
4102
|
});</pre>`];
|
|
4101
4103
|
const ai = lAi.get(this, {
|
|
4102
4104
|
'service': lAi.ESERVICE[this._get['service']?.toUpperCase() ?? 'ALICN'] ?? lAi.ESERVICE.ALICN,
|
|
4105
|
+
'endpoint': this._get['service'] === 'ofox' ? 'https://api.ofox.io/v1' : undefined,
|
|
4103
4106
|
});
|
|
4104
4107
|
switch (this._get['action']) {
|
|
4105
4108
|
case 'text-to-image': {
|
|
@@ -4243,6 +4246,128 @@ rtn.push(reader.readBCDString());</pre>${JSON.stringify(rtn)}`);
|
|
|
4243
4246
|
}
|
|
4244
4247
|
break;
|
|
4245
4248
|
}
|
|
4249
|
+
case 'response': {
|
|
4250
|
+
// --- Responses API:多轮对话 + Function Calling + 数据库存储方案 ---
|
|
4251
|
+
let model = ai.service === lAi.ESERVICE.ALICN ? 'qwen3.5-flash' : 'openai/gpt-5-nano';
|
|
4252
|
+
const responseInstructions = 'You are Kebab, a helpful assistant. Do not mention any model names or AI identity. Respond in Chinese.';
|
|
4253
|
+
// --- 工具定义 ---
|
|
4254
|
+
const responseTools = [
|
|
4255
|
+
{
|
|
4256
|
+
'type': 'function',
|
|
4257
|
+
'name': 'get_weather',
|
|
4258
|
+
'description': '获取指定城市的当前天气,返回 `false`: 调用失败, `null`: 无数据, 成功: 温度和天气',
|
|
4259
|
+
'parameters': {
|
|
4260
|
+
'type': 'object',
|
|
4261
|
+
'required': ['city'],
|
|
4262
|
+
'properties': {
|
|
4263
|
+
'city': { 'type': 'string', 'description': '城市名称,如"北京"' },
|
|
4264
|
+
},
|
|
4265
|
+
},
|
|
4266
|
+
},
|
|
4267
|
+
];
|
|
4268
|
+
// --- 模拟本地工具执行 ---
|
|
4269
|
+
const execTool = (name, argsJson) => {
|
|
4270
|
+
const args = lText.parseJson(argsJson);
|
|
4271
|
+
if (!args) {
|
|
4272
|
+
return 'false';
|
|
4273
|
+
}
|
|
4274
|
+
if (name === 'get_weather') {
|
|
4275
|
+
const table = {
|
|
4276
|
+
'北京': { 'temp': '22°C', 'condition': '晴' },
|
|
4277
|
+
'上海': { 'temp': '28°C', 'condition': '多云' },
|
|
4278
|
+
};
|
|
4279
|
+
return table[args['city']] ? lText.stringifyJson(table[args['city']]) : 'null';
|
|
4280
|
+
}
|
|
4281
|
+
return 'false';
|
|
4282
|
+
};
|
|
4283
|
+
// --- 完整对话历史(同时作为数据库存储内容) ---
|
|
4284
|
+
const conversation = [];
|
|
4285
|
+
// --- 运行一轮(自动处理 function_call 循环) ---
|
|
4286
|
+
const runTurn = async (userMsg) => {
|
|
4287
|
+
conversation.push({ 'role': 'user', 'content': userMsg });
|
|
4288
|
+
let data = await ai.response({
|
|
4289
|
+
'model': model,
|
|
4290
|
+
'store': false,
|
|
4291
|
+
'reasoning': {
|
|
4292
|
+
'effort': 'minimal',
|
|
4293
|
+
},
|
|
4294
|
+
'instructions': responseInstructions,
|
|
4295
|
+
'input': conversation,
|
|
4296
|
+
'tools': responseTools,
|
|
4297
|
+
});
|
|
4298
|
+
while (data) {
|
|
4299
|
+
const calls = data.output.filter(item => item.type === 'function_call');
|
|
4300
|
+
if (!calls.length) {
|
|
4301
|
+
// --- 无工具调用,追加 assistant 回复,供下一轮使用 ---
|
|
4302
|
+
conversation.push({ 'role': 'assistant', 'content': data.output_text });
|
|
4303
|
+
return data;
|
|
4304
|
+
}
|
|
4305
|
+
// --- 将 function_call 追加到 conversation ---
|
|
4306
|
+
for (const call of calls) {
|
|
4307
|
+
conversation.push({
|
|
4308
|
+
'type': 'function_call',
|
|
4309
|
+
'name': call.name,
|
|
4310
|
+
'arguments': call.arguments,
|
|
4311
|
+
'call_id': call.call_id,
|
|
4312
|
+
});
|
|
4313
|
+
}
|
|
4314
|
+
// --- 全部追加完后再统一执行工具,将结果追加到 conversation,再次调用 ---
|
|
4315
|
+
for (const call of calls) {
|
|
4316
|
+
conversation.push({
|
|
4317
|
+
'type': 'function_call_output',
|
|
4318
|
+
'call_id': call.call_id,
|
|
4319
|
+
'output': execTool(call.name, call.arguments),
|
|
4320
|
+
});
|
|
4321
|
+
}
|
|
4322
|
+
data = await ai.response({
|
|
4323
|
+
'model': model,
|
|
4324
|
+
'store': false,
|
|
4325
|
+
'reasoning': {
|
|
4326
|
+
'effort': 'minimal',
|
|
4327
|
+
},
|
|
4328
|
+
'instructions': responseInstructions,
|
|
4329
|
+
'input': conversation,
|
|
4330
|
+
'tools': responseTools,
|
|
4331
|
+
});
|
|
4332
|
+
}
|
|
4333
|
+
return false;
|
|
4334
|
+
};
|
|
4335
|
+
// --- 第一轮:自我介绍 + 查北京天气(触发 Function Calling) ---
|
|
4336
|
+
const d1str = '你是谁?今天北京天气怎么样?';
|
|
4337
|
+
const d1 = await runTurn(d1str);
|
|
4338
|
+
if (!d1) {
|
|
4339
|
+
echo.push('Turn 1 Failed');
|
|
4340
|
+
break;
|
|
4341
|
+
}
|
|
4342
|
+
echo.push(`<b>第一轮(触发 get_weather 工具):</b><br>${d1str + '<br>' + lText.htmlescape(d1.output_text)}<br><br>`);
|
|
4343
|
+
// --- 第二轮:续接上文,查上海天气 ---
|
|
4344
|
+
const d2str = '那上海呢?';
|
|
4345
|
+
const d2 = await runTurn(d2str);
|
|
4346
|
+
if (!d2) {
|
|
4347
|
+
echo.push('Turn 2 Failed');
|
|
4348
|
+
break;
|
|
4349
|
+
}
|
|
4350
|
+
echo.push(`<b>第二轮(conversation 续接,自动触发工具):</b><br>${d2str + '<br>' + lText.htmlescape(d2.output_text)}<br><br>`);
|
|
4351
|
+
// --- 第三轮:基于前两轮结果直接推理,无需工具 ---
|
|
4352
|
+
const d3str = '两个城市比较,今天哪个更适合出行?';
|
|
4353
|
+
const d3 = await runTurn(d3str);
|
|
4354
|
+
if (!d3) {
|
|
4355
|
+
echo.push('Turn 3 Failed');
|
|
4356
|
+
break;
|
|
4357
|
+
}
|
|
4358
|
+
echo.push(`<b>第三轮(直接推理):</b><br>${d3str + '<br>' + lText.htmlescape(d3.output_text)}<br>`);
|
|
4359
|
+
// --- 数据库存储格式 ---
|
|
4360
|
+
// --- conversation 顺序:user → function_call → function_call_output → assistant → user → ... ---
|
|
4361
|
+
echo.push(`<hr><b>数据库存储 input:</b><pre>${lText.htmlescape(lText.stringifyJson(conversation, 4))}</pre>`);
|
|
4362
|
+
// --- 从头重建(直接将 dbRecord.input 发送即可) ---
|
|
4363
|
+
echo.push(`<hr><b>从头重建:</b><pre>${lText.htmlescape(`const replay = await ai.response({
|
|
4364
|
+
'model': model,
|
|
4365
|
+
'instructions': instructions,
|
|
4366
|
+
'input': conversation,
|
|
4367
|
+
'tools': tools,
|
|
4368
|
+
});`)}</pre>`);
|
|
4369
|
+
break;
|
|
4370
|
+
}
|
|
4246
4371
|
default: {
|
|
4247
4372
|
// --- CHAT ---
|
|
4248
4373
|
let model = ai.service === lAi.ESERVICE.ALICN ? 'qwen-plus' : 'doubao-seed-2-0-mini-260215';
|