@zwa73/utils 1.0.265 → 1.0.266
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/UtilClass/Hbs.js +3 -0
- package/dist/UtilCodecs.js +7 -4
- package/dist/UtilFunctions.js +1 -1
- package/package.json +3 -3
package/dist/UtilClass/Hbs.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Hbs = void 0;
|
|
4
4
|
const UtilLogger_1 = require("../UtilLogger");
|
|
5
5
|
const js_utils_1 = require("@zwa73/js-utils");
|
|
6
|
+
const UtilFunctions_1 = require("../UtilFunctions");
|
|
6
7
|
/**文本模板渲染器
|
|
7
8
|
* @template T - 上下文对象的类型,默认为记录类型
|
|
8
9
|
*/
|
|
@@ -34,6 +35,8 @@ class Hbs {
|
|
|
34
35
|
*/
|
|
35
36
|
static async create(context = {}) {
|
|
36
37
|
const Handlebars = await js_utils_1.JsFunc.dynamicImport('handlebars');
|
|
38
|
+
if (Handlebars == undefined)
|
|
39
|
+
UtilFunctions_1.UtilFunc.throwError(`npm包 handlebars 动态导入失败, 此包不会随@zwa73/utils自动安装, 可能是未安装, 可使用 npm i handlebars@4.7.8 来安装`);
|
|
37
40
|
//console.log(Handlebars);
|
|
38
41
|
const hbs = Handlebars.create();
|
|
39
42
|
return new Hbs(hbs, context);
|
package/dist/UtilCodecs.js
CHANGED
|
@@ -27,7 +27,10 @@ exports.UtilCodec = void 0;
|
|
|
27
27
|
const he = __importStar(require("html-entities"));
|
|
28
28
|
const UtilFunctions_1 = require("./UtilFunctions");
|
|
29
29
|
async function importTikToken() {
|
|
30
|
-
|
|
30
|
+
const tik = await UtilFunctions_1.UtilFunc.dynamicImport("tiktoken");
|
|
31
|
+
if (tik == undefined)
|
|
32
|
+
UtilFunctions_1.UtilFunc.throwError(`npm包 tiktoken 动态导入失败, 此包不会随@zwa73/utils自动安装, 可能是未安装, 可使用 npm i tiktoken@1.0.7 来安装`);
|
|
33
|
+
return tik;
|
|
31
34
|
}
|
|
32
35
|
/**编码/解码器 */
|
|
33
36
|
var UtilCodec;
|
|
@@ -57,9 +60,9 @@ var UtilCodec;
|
|
|
57
60
|
UtilCodec.encodeHtmlEntities = encodeHtmlEntities;
|
|
58
61
|
//#region LAM
|
|
59
62
|
//token长度计算器
|
|
60
|
-
//cl100k_base
|
|
61
|
-
//p50k_base
|
|
62
|
-
//r50k_base (or gpt2)
|
|
63
|
+
//cl100k_base ChatGPT models, text-embedding-ada-002
|
|
64
|
+
//p50k_base Code models, text-davinci-002, text-davinci-003
|
|
65
|
+
//r50k_base (or gpt2) GPT-3 models like davinci
|
|
63
66
|
//避免在nextjs调用时出错
|
|
64
67
|
async function initTikTokenEncoder() {
|
|
65
68
|
if (encoderCl100kBase != null && encoderP50kBase != null)
|
package/dist/UtilFunctions.js
CHANGED
|
@@ -124,7 +124,7 @@ class _UtilFunc {
|
|
|
124
124
|
//if(_UtilFunc.publicIp===undefined)
|
|
125
125
|
// _UtilFunc.publicIp = await import("public-ip");
|
|
126
126
|
if (pip == undefined) {
|
|
127
|
-
UtilLogger_1.SLogger.warn(`npm包 public-ip 动态导入失败, 可能是未安装, 可使用 npm i public-ip@6.0.2 来安装`);
|
|
127
|
+
UtilLogger_1.SLogger.warn(`npm包 public-ip 动态导入失败, 此包不会随@zwa73/utils自动安装, 可能是未安装, 可使用 npm i public-ip@6.0.2 来安装`);
|
|
128
128
|
return undefined;
|
|
129
129
|
}
|
|
130
130
|
return pip.publicIpv4();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zwa73/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.266",
|
|
4
4
|
"description": "my utils",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,14 +20,12 @@
|
|
|
20
20
|
"@zwa73/modular-mixer": "^1.0.8",
|
|
21
21
|
"form-data": "^4.0.2",
|
|
22
22
|
"glob": "^10.4.1",
|
|
23
|
-
"handlebars": "^4.7.8",
|
|
24
23
|
"html-entities": "^2.3.3",
|
|
25
24
|
"http-proxy-agent": "^5.0.0",
|
|
26
25
|
"https-proxy-agent": "^5.0.1",
|
|
27
26
|
"json5": "^2.2.3",
|
|
28
27
|
"pathe": "^1.1.2",
|
|
29
28
|
"querystring": "^0.2.1",
|
|
30
|
-
"tiktoken": "^1.0.7",
|
|
31
29
|
"winston": "^3.10.0",
|
|
32
30
|
"winston-daily-rotate-file": "^4.7.1"
|
|
33
31
|
},
|
|
@@ -36,7 +34,9 @@
|
|
|
36
34
|
"@types/jest": "^29.5.12",
|
|
37
35
|
"@types/node": "^20.14.11",
|
|
38
36
|
"@zwa73/dev-utils": "*",
|
|
37
|
+
"handlebars": "^4.7.8",
|
|
39
38
|
"public-ip": "^6.0.2",
|
|
39
|
+
"tiktoken": "^1.0.7",
|
|
40
40
|
"tsc-alias": "^1.8.8",
|
|
41
41
|
"typescript": "^5.3.3"
|
|
42
42
|
},
|