@wzyjs/utils 0.3.17 → 0.3.20
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/node.cjs.js +11 -44
- package/dist/node.esm.js +11 -44
- package/dist/web.cjs.js +11 -44
- package/dist/web.esm.js +11 -44
- package/package.json +2 -2
package/dist/node.cjs.js
CHANGED
|
@@ -35649,28 +35649,12 @@ var chat = async (message, model = "gpt-4.1", isParse = true) => {
|
|
|
35649
35649
|
console.log(666, typeof data, data);
|
|
35650
35650
|
const output = typeof data === "string" ? import_json5.default.parse(data)?.output : data?.output;
|
|
35651
35651
|
if (isParse) {
|
|
35652
|
-
const
|
|
35653
|
-
|
|
35654
|
-
|
|
35655
|
-
|
|
35656
|
-
|
|
35657
|
-
|
|
35658
|
-
if (endBlock > startBlock) {
|
|
35659
|
-
jsonString = jsonString.substring(startBlock + (startBlockJson !== -1 ? 7 : 3), endBlock);
|
|
35660
|
-
}
|
|
35661
|
-
}
|
|
35662
|
-
const firstBrace = jsonString.indexOf("{");
|
|
35663
|
-
const lastBrace = jsonString.lastIndexOf("}");
|
|
35664
|
-
const firstBracket = jsonString.indexOf("[");
|
|
35665
|
-
const lastBracket = jsonString.lastIndexOf("]");
|
|
35666
|
-
const isObject = firstBrace !== -1 && (firstBracket === -1 || firstBrace < firstBracket);
|
|
35667
|
-
const isArray = firstBracket !== -1 && (firstBrace === -1 || firstBracket < firstBrace);
|
|
35668
|
-
if (isObject && lastBrace >= firstBrace) {
|
|
35669
|
-
jsonString = jsonString.substring(firstBrace, lastBrace + 1);
|
|
35670
|
-
} else if (isArray && lastBracket >= firstBracket) {
|
|
35671
|
-
jsonString = jsonString.substring(firstBracket, lastBracket + 1);
|
|
35672
|
-
}
|
|
35673
|
-
return import_json5.default.parse(jsonString);
|
|
35652
|
+
const match = /```(json)?(.*)```/s.exec(output);
|
|
35653
|
+
if (!match) {
|
|
35654
|
+
return import_json5.default.parse(output);
|
|
35655
|
+
} else {
|
|
35656
|
+
return import_json5.default.parse(match[2]);
|
|
35657
|
+
}
|
|
35674
35658
|
}
|
|
35675
35659
|
return output;
|
|
35676
35660
|
} catch (error) {
|
|
@@ -36130,28 +36114,11 @@ var complete = async (apiUrl, model, token, messages, json = true) => {
|
|
|
36130
36114
|
throw new Error("No content in response");
|
|
36131
36115
|
}
|
|
36132
36116
|
if (json) {
|
|
36133
|
-
const
|
|
36134
|
-
|
|
36135
|
-
|
|
36136
|
-
|
|
36137
|
-
|
|
36138
|
-
const endBlock = jsonString.lastIndexOf("```");
|
|
36139
|
-
if (endBlock > startBlock) {
|
|
36140
|
-
jsonString = jsonString.substring(startBlock + (startBlockJson !== -1 ? 7 : 3), endBlock);
|
|
36141
|
-
}
|
|
36142
|
-
}
|
|
36143
|
-
const firstBrace = jsonString.indexOf("{");
|
|
36144
|
-
const lastBrace = jsonString.lastIndexOf("}");
|
|
36145
|
-
const firstBracket = jsonString.indexOf("[");
|
|
36146
|
-
const lastBracket = jsonString.lastIndexOf("]");
|
|
36147
|
-
const isObject = firstBrace !== -1 && (firstBracket === -1 || firstBrace < firstBracket);
|
|
36148
|
-
const isArray = firstBracket !== -1 && (firstBrace === -1 || firstBracket < firstBrace);
|
|
36149
|
-
if (isObject && lastBrace >= firstBrace) {
|
|
36150
|
-
jsonString = jsonString.substring(firstBrace, lastBrace + 1);
|
|
36151
|
-
} else if (isArray && lastBracket >= firstBracket) {
|
|
36152
|
-
jsonString = jsonString.substring(firstBracket, lastBracket + 1);
|
|
36153
|
-
}
|
|
36154
|
-
return import_json52.default.parse(jsonString);
|
|
36117
|
+
const match = /```(json)?(.*)```/s.exec(content);
|
|
36118
|
+
if (match && match[2]) {
|
|
36119
|
+
return import_json52.default.parse(match[2]);
|
|
36120
|
+
}
|
|
36121
|
+
return import_json52.default.parse(content);
|
|
36155
36122
|
}
|
|
36156
36123
|
return content;
|
|
36157
36124
|
} catch (error) {
|
package/dist/node.esm.js
CHANGED
|
@@ -34749,28 +34749,12 @@ var chat = async (message, model = "gpt-4.1", isParse = true) => {
|
|
|
34749
34749
|
console.log(666, typeof data, data);
|
|
34750
34750
|
const output = typeof data === "string" ? json5.parse(data)?.output : data?.output;
|
|
34751
34751
|
if (isParse) {
|
|
34752
|
-
const
|
|
34753
|
-
|
|
34754
|
-
|
|
34755
|
-
|
|
34756
|
-
|
|
34757
|
-
|
|
34758
|
-
if (endBlock > startBlock) {
|
|
34759
|
-
jsonString = jsonString.substring(startBlock + (startBlockJson !== -1 ? 7 : 3), endBlock);
|
|
34760
|
-
}
|
|
34761
|
-
}
|
|
34762
|
-
const firstBrace = jsonString.indexOf("{");
|
|
34763
|
-
const lastBrace = jsonString.lastIndexOf("}");
|
|
34764
|
-
const firstBracket = jsonString.indexOf("[");
|
|
34765
|
-
const lastBracket = jsonString.lastIndexOf("]");
|
|
34766
|
-
const isObject = firstBrace !== -1 && (firstBracket === -1 || firstBrace < firstBracket);
|
|
34767
|
-
const isArray = firstBracket !== -1 && (firstBrace === -1 || firstBracket < firstBrace);
|
|
34768
|
-
if (isObject && lastBrace >= firstBrace) {
|
|
34769
|
-
jsonString = jsonString.substring(firstBrace, lastBrace + 1);
|
|
34770
|
-
} else if (isArray && lastBracket >= firstBracket) {
|
|
34771
|
-
jsonString = jsonString.substring(firstBracket, lastBracket + 1);
|
|
34772
|
-
}
|
|
34773
|
-
return json5.parse(jsonString);
|
|
34752
|
+
const match = /```(json)?(.*)```/s.exec(output);
|
|
34753
|
+
if (!match) {
|
|
34754
|
+
return json5.parse(output);
|
|
34755
|
+
} else {
|
|
34756
|
+
return json5.parse(match[2]);
|
|
34757
|
+
}
|
|
34774
34758
|
}
|
|
34775
34759
|
return output;
|
|
34776
34760
|
} catch (error) {
|
|
@@ -35230,28 +35214,11 @@ var complete = async (apiUrl, model, token, messages, json = true) => {
|
|
|
35230
35214
|
throw new Error("No content in response");
|
|
35231
35215
|
}
|
|
35232
35216
|
if (json) {
|
|
35233
|
-
const
|
|
35234
|
-
|
|
35235
|
-
|
|
35236
|
-
|
|
35237
|
-
|
|
35238
|
-
const endBlock = jsonString.lastIndexOf("```");
|
|
35239
|
-
if (endBlock > startBlock) {
|
|
35240
|
-
jsonString = jsonString.substring(startBlock + (startBlockJson !== -1 ? 7 : 3), endBlock);
|
|
35241
|
-
}
|
|
35242
|
-
}
|
|
35243
|
-
const firstBrace = jsonString.indexOf("{");
|
|
35244
|
-
const lastBrace = jsonString.lastIndexOf("}");
|
|
35245
|
-
const firstBracket = jsonString.indexOf("[");
|
|
35246
|
-
const lastBracket = jsonString.lastIndexOf("]");
|
|
35247
|
-
const isObject = firstBrace !== -1 && (firstBracket === -1 || firstBrace < firstBracket);
|
|
35248
|
-
const isArray = firstBracket !== -1 && (firstBrace === -1 || firstBracket < firstBrace);
|
|
35249
|
-
if (isObject && lastBrace >= firstBrace) {
|
|
35250
|
-
jsonString = jsonString.substring(firstBrace, lastBrace + 1);
|
|
35251
|
-
} else if (isArray && lastBracket >= firstBracket) {
|
|
35252
|
-
jsonString = jsonString.substring(firstBracket, lastBracket + 1);
|
|
35253
|
-
}
|
|
35254
|
-
return json52.parse(jsonString);
|
|
35217
|
+
const match = /```(json)?(.*)```/s.exec(content);
|
|
35218
|
+
if (match && match[2]) {
|
|
35219
|
+
return json52.parse(match[2]);
|
|
35220
|
+
}
|
|
35221
|
+
return json52.parse(content);
|
|
35255
35222
|
}
|
|
35256
35223
|
return content;
|
|
35257
35224
|
} catch (error) {
|
package/dist/web.cjs.js
CHANGED
|
@@ -18319,28 +18319,12 @@ var chat = async (message, model = "gpt-4.1", isParse = true) => {
|
|
|
18319
18319
|
console.log(666, typeof data, data);
|
|
18320
18320
|
const output = typeof data === "string" ? import_json5.default.parse(data)?.output : data?.output;
|
|
18321
18321
|
if (isParse) {
|
|
18322
|
-
const
|
|
18323
|
-
|
|
18324
|
-
|
|
18325
|
-
|
|
18326
|
-
|
|
18327
|
-
|
|
18328
|
-
if (endBlock > startBlock) {
|
|
18329
|
-
jsonString = jsonString.substring(startBlock + (startBlockJson !== -1 ? 7 : 3), endBlock);
|
|
18330
|
-
}
|
|
18331
|
-
}
|
|
18332
|
-
const firstBrace = jsonString.indexOf("{");
|
|
18333
|
-
const lastBrace = jsonString.lastIndexOf("}");
|
|
18334
|
-
const firstBracket = jsonString.indexOf("[");
|
|
18335
|
-
const lastBracket = jsonString.lastIndexOf("]");
|
|
18336
|
-
const isObject2 = firstBrace !== -1 && (firstBracket === -1 || firstBrace < firstBracket);
|
|
18337
|
-
const isArray2 = firstBracket !== -1 && (firstBrace === -1 || firstBracket < firstBrace);
|
|
18338
|
-
if (isObject2 && lastBrace >= firstBrace) {
|
|
18339
|
-
jsonString = jsonString.substring(firstBrace, lastBrace + 1);
|
|
18340
|
-
} else if (isArray2 && lastBracket >= firstBracket) {
|
|
18341
|
-
jsonString = jsonString.substring(firstBracket, lastBracket + 1);
|
|
18342
|
-
}
|
|
18343
|
-
return import_json5.default.parse(jsonString);
|
|
18322
|
+
const match = /```(json)?(.*)```/s.exec(output);
|
|
18323
|
+
if (!match) {
|
|
18324
|
+
return import_json5.default.parse(output);
|
|
18325
|
+
} else {
|
|
18326
|
+
return import_json5.default.parse(match[2]);
|
|
18327
|
+
}
|
|
18344
18328
|
}
|
|
18345
18329
|
return output;
|
|
18346
18330
|
} catch (error) {
|
|
@@ -19205,28 +19189,11 @@ var complete = async (apiUrl, model, token, messages, json = true) => {
|
|
|
19205
19189
|
throw new Error("No content in response");
|
|
19206
19190
|
}
|
|
19207
19191
|
if (json) {
|
|
19208
|
-
const
|
|
19209
|
-
|
|
19210
|
-
|
|
19211
|
-
|
|
19212
|
-
|
|
19213
|
-
const endBlock = jsonString.lastIndexOf("```");
|
|
19214
|
-
if (endBlock > startBlock) {
|
|
19215
|
-
jsonString = jsonString.substring(startBlock + (startBlockJson !== -1 ? 7 : 3), endBlock);
|
|
19216
|
-
}
|
|
19217
|
-
}
|
|
19218
|
-
const firstBrace = jsonString.indexOf("{");
|
|
19219
|
-
const lastBrace = jsonString.lastIndexOf("}");
|
|
19220
|
-
const firstBracket = jsonString.indexOf("[");
|
|
19221
|
-
const lastBracket = jsonString.lastIndexOf("]");
|
|
19222
|
-
const isObject2 = firstBrace !== -1 && (firstBracket === -1 || firstBrace < firstBracket);
|
|
19223
|
-
const isArray2 = firstBracket !== -1 && (firstBrace === -1 || firstBracket < firstBrace);
|
|
19224
|
-
if (isObject2 && lastBrace >= firstBrace) {
|
|
19225
|
-
jsonString = jsonString.substring(firstBrace, lastBrace + 1);
|
|
19226
|
-
} else if (isArray2 && lastBracket >= firstBracket) {
|
|
19227
|
-
jsonString = jsonString.substring(firstBracket, lastBracket + 1);
|
|
19228
|
-
}
|
|
19229
|
-
return import_json52.default.parse(jsonString);
|
|
19192
|
+
const match = /```(json)?(.*)```/s.exec(content);
|
|
19193
|
+
if (match && match[2]) {
|
|
19194
|
+
return import_json52.default.parse(match[2]);
|
|
19195
|
+
}
|
|
19196
|
+
return import_json52.default.parse(content);
|
|
19230
19197
|
}
|
|
19231
19198
|
return content;
|
|
19232
19199
|
} catch (error) {
|
package/dist/web.esm.js
CHANGED
|
@@ -18132,28 +18132,12 @@ var chat = async (message, model = "gpt-4.1", isParse = true) => {
|
|
|
18132
18132
|
console.log(666, typeof data, data);
|
|
18133
18133
|
const output = typeof data === "string" ? import_json5.default.parse(data)?.output : data?.output;
|
|
18134
18134
|
if (isParse) {
|
|
18135
|
-
const
|
|
18136
|
-
|
|
18137
|
-
|
|
18138
|
-
|
|
18139
|
-
|
|
18140
|
-
|
|
18141
|
-
if (endBlock > startBlock) {
|
|
18142
|
-
jsonString = jsonString.substring(startBlock + (startBlockJson !== -1 ? 7 : 3), endBlock);
|
|
18143
|
-
}
|
|
18144
|
-
}
|
|
18145
|
-
const firstBrace = jsonString.indexOf("{");
|
|
18146
|
-
const lastBrace = jsonString.lastIndexOf("}");
|
|
18147
|
-
const firstBracket = jsonString.indexOf("[");
|
|
18148
|
-
const lastBracket = jsonString.lastIndexOf("]");
|
|
18149
|
-
const isObject2 = firstBrace !== -1 && (firstBracket === -1 || firstBrace < firstBracket);
|
|
18150
|
-
const isArray2 = firstBracket !== -1 && (firstBrace === -1 || firstBracket < firstBrace);
|
|
18151
|
-
if (isObject2 && lastBrace >= firstBrace) {
|
|
18152
|
-
jsonString = jsonString.substring(firstBrace, lastBrace + 1);
|
|
18153
|
-
} else if (isArray2 && lastBracket >= firstBracket) {
|
|
18154
|
-
jsonString = jsonString.substring(firstBracket, lastBracket + 1);
|
|
18155
|
-
}
|
|
18156
|
-
return import_json5.default.parse(jsonString);
|
|
18135
|
+
const match = /```(json)?(.*)```/s.exec(output);
|
|
18136
|
+
if (!match) {
|
|
18137
|
+
return import_json5.default.parse(output);
|
|
18138
|
+
} else {
|
|
18139
|
+
return import_json5.default.parse(match[2]);
|
|
18140
|
+
}
|
|
18157
18141
|
}
|
|
18158
18142
|
return output;
|
|
18159
18143
|
} catch (error) {
|
|
@@ -19018,28 +19002,11 @@ var complete = async (apiUrl, model, token, messages, json = true) => {
|
|
|
19018
19002
|
throw new Error("No content in response");
|
|
19019
19003
|
}
|
|
19020
19004
|
if (json) {
|
|
19021
|
-
const
|
|
19022
|
-
|
|
19023
|
-
|
|
19024
|
-
|
|
19025
|
-
|
|
19026
|
-
const endBlock = jsonString.lastIndexOf("```");
|
|
19027
|
-
if (endBlock > startBlock) {
|
|
19028
|
-
jsonString = jsonString.substring(startBlock + (startBlockJson !== -1 ? 7 : 3), endBlock);
|
|
19029
|
-
}
|
|
19030
|
-
}
|
|
19031
|
-
const firstBrace = jsonString.indexOf("{");
|
|
19032
|
-
const lastBrace = jsonString.lastIndexOf("}");
|
|
19033
|
-
const firstBracket = jsonString.indexOf("[");
|
|
19034
|
-
const lastBracket = jsonString.lastIndexOf("]");
|
|
19035
|
-
const isObject2 = firstBrace !== -1 && (firstBracket === -1 || firstBrace < firstBracket);
|
|
19036
|
-
const isArray2 = firstBracket !== -1 && (firstBrace === -1 || firstBracket < firstBrace);
|
|
19037
|
-
if (isObject2 && lastBrace >= firstBrace) {
|
|
19038
|
-
jsonString = jsonString.substring(firstBrace, lastBrace + 1);
|
|
19039
|
-
} else if (isArray2 && lastBracket >= firstBracket) {
|
|
19040
|
-
jsonString = jsonString.substring(firstBracket, lastBracket + 1);
|
|
19041
|
-
}
|
|
19042
|
-
return import_json52.default.parse(jsonString);
|
|
19005
|
+
const match = /```(json)?(.*)```/s.exec(content);
|
|
19006
|
+
if (match && match[2]) {
|
|
19007
|
+
return import_json52.default.parse(match[2]);
|
|
19008
|
+
}
|
|
19009
|
+
return import_json52.default.parse(content);
|
|
19043
19010
|
}
|
|
19044
19011
|
return content;
|
|
19045
19012
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzyjs/utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.20",
|
|
4
4
|
"description": "description",
|
|
5
5
|
"author": "wzy",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@types/nodemailer": "^6.4.7",
|
|
71
71
|
"@types/papaparse": "^5.3.15"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "75ecd6752ea11d3e5d51ef76cd4393dca75c358b",
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
76
76
|
}
|