@wzyjs/utils 0.2.65 → 0.2.67
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/browser/index.d.ts +1 -0
- package/dist/browser.cjs.js +38 -0
- package/dist/browser.esm.js +38 -0
- package/dist/common/dayjs.d.ts +2 -0
- package/dist/node.cjs.js +3 -2
- package/dist/node.esm.js +3 -2
- package/package.json +2 -2
package/dist/browser/index.d.ts
CHANGED
package/dist/browser.cjs.js
CHANGED
|
@@ -10399,6 +10399,7 @@ __export(exports_browser, {
|
|
|
10399
10399
|
coerce: () => coerce,
|
|
10400
10400
|
classnames: () => import_classnames.default,
|
|
10401
10401
|
chinaDayjs: () => chinaDayjs,
|
|
10402
|
+
chat: () => chat,
|
|
10402
10403
|
calcJsText: () => calcJsText,
|
|
10403
10404
|
boolean: () => booleanType,
|
|
10404
10405
|
bigint: () => bigIntType,
|
|
@@ -21066,3 +21067,40 @@ var urlGetPath = (url = location.href) => {
|
|
|
21066
21067
|
}
|
|
21067
21068
|
return url.slice(0, lastIndex);
|
|
21068
21069
|
};
|
|
21070
|
+
// src/ai/302/axios.ts
|
|
21071
|
+
var key = process.env.AI_302_KEY || process.env.NEXT_PUBLIC_AI_302_KEY;
|
|
21072
|
+
var axios2 = axios_default.create({
|
|
21073
|
+
baseURL: "https://api.302.ai",
|
|
21074
|
+
headers: {
|
|
21075
|
+
"mj-api-secret": key,
|
|
21076
|
+
Authorization: `Bearer ${key}`
|
|
21077
|
+
}
|
|
21078
|
+
});
|
|
21079
|
+
|
|
21080
|
+
// src/ai/302/chat/index.ts
|
|
21081
|
+
var import_json52 = __toESM(require_dist());
|
|
21082
|
+
var chat = async (message, model = "gpt-4.1", isParse = true) => {
|
|
21083
|
+
try {
|
|
21084
|
+
let { data } = await axios2({
|
|
21085
|
+
url: "/v1/chat/completions",
|
|
21086
|
+
method: "post",
|
|
21087
|
+
data: {
|
|
21088
|
+
model,
|
|
21089
|
+
message
|
|
21090
|
+
}
|
|
21091
|
+
});
|
|
21092
|
+
console.log(666, typeof data, data);
|
|
21093
|
+
const output = typeof data === "string" ? import_json52.default.parse(data)?.output : data?.output;
|
|
21094
|
+
if (isParse) {
|
|
21095
|
+
const match = /```(json)?(.*)```/s.exec(output);
|
|
21096
|
+
if (!match) {
|
|
21097
|
+
return import_json52.default.parse(output);
|
|
21098
|
+
} else {
|
|
21099
|
+
return import_json52.default.parse(match[2]);
|
|
21100
|
+
}
|
|
21101
|
+
}
|
|
21102
|
+
return output;
|
|
21103
|
+
} catch (error) {
|
|
21104
|
+
throw new Error(error?.response?.statusText || error?.message || "未知原因");
|
|
21105
|
+
}
|
|
21106
|
+
};
|
package/dist/browser.esm.js
CHANGED
|
@@ -20881,6 +20881,43 @@ var urlGetPath = (url = location.href) => {
|
|
|
20881
20881
|
}
|
|
20882
20882
|
return url.slice(0, lastIndex);
|
|
20883
20883
|
};
|
|
20884
|
+
// src/ai/302/axios.ts
|
|
20885
|
+
var key = process.env.AI_302_KEY || process.env.NEXT_PUBLIC_AI_302_KEY;
|
|
20886
|
+
var axios2 = axios_default.create({
|
|
20887
|
+
baseURL: "https://api.302.ai",
|
|
20888
|
+
headers: {
|
|
20889
|
+
"mj-api-secret": key,
|
|
20890
|
+
Authorization: `Bearer ${key}`
|
|
20891
|
+
}
|
|
20892
|
+
});
|
|
20893
|
+
|
|
20894
|
+
// src/ai/302/chat/index.ts
|
|
20895
|
+
var import_json52 = __toESM(require_dist(), 1);
|
|
20896
|
+
var chat = async (message, model = "gpt-4.1", isParse = true) => {
|
|
20897
|
+
try {
|
|
20898
|
+
let { data } = await axios2({
|
|
20899
|
+
url: "/v1/chat/completions",
|
|
20900
|
+
method: "post",
|
|
20901
|
+
data: {
|
|
20902
|
+
model,
|
|
20903
|
+
message
|
|
20904
|
+
}
|
|
20905
|
+
});
|
|
20906
|
+
console.log(666, typeof data, data);
|
|
20907
|
+
const output = typeof data === "string" ? import_json52.default.parse(data)?.output : data?.output;
|
|
20908
|
+
if (isParse) {
|
|
20909
|
+
const match = /```(json)?(.*)```/s.exec(output);
|
|
20910
|
+
if (!match) {
|
|
20911
|
+
return import_json52.default.parse(output);
|
|
20912
|
+
} else {
|
|
20913
|
+
return import_json52.default.parse(match[2]);
|
|
20914
|
+
}
|
|
20915
|
+
}
|
|
20916
|
+
return output;
|
|
20917
|
+
} catch (error) {
|
|
20918
|
+
throw new Error(error?.response?.statusText || error?.message || "未知原因");
|
|
20919
|
+
}
|
|
20920
|
+
};
|
|
20884
20921
|
var export_md5 = import_md5.default;
|
|
20885
20922
|
var export_localforage = import_localforage.default;
|
|
20886
20923
|
var export_json5 = import_json5.default;
|
|
@@ -20998,6 +21035,7 @@ export {
|
|
|
20998
21035
|
coerce,
|
|
20999
21036
|
export_classnames as classnames,
|
|
21000
21037
|
chinaDayjs,
|
|
21038
|
+
chat,
|
|
21001
21039
|
calcJsText,
|
|
21002
21040
|
booleanType as boolean,
|
|
21003
21041
|
bigIntType as bigint,
|
package/dist/common/dayjs.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import updateLocale from 'dayjs/plugin/updateLocale';
|
|
|
4
4
|
import timezone from 'dayjs/plugin/timezone';
|
|
5
5
|
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
6
6
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
7
|
+
import utc from 'dayjs/plugin/utc';
|
|
7
8
|
import 'dayjs/locale/zh-cn';
|
|
8
9
|
export declare enum Timezone {
|
|
9
10
|
AsiaShanghai = "Asia/Shanghai",
|
|
@@ -20,6 +21,7 @@ declare const _default: typeof dayjs & {
|
|
|
20
21
|
isSameOrAfter: typeof isSameOrAfter;
|
|
21
22
|
isSameOrBefore: typeof isSameOrBefore;
|
|
22
23
|
tz: typeof timezone;
|
|
24
|
+
utc: typeof utc;
|
|
23
25
|
updateLocale: typeof updateLocale;
|
|
24
26
|
};
|
|
25
27
|
export default _default;
|
package/dist/node.cjs.js
CHANGED
|
@@ -12382,11 +12382,12 @@ __export(exports_302, {
|
|
|
12382
12382
|
|
|
12383
12383
|
// src/ai/302/axios.ts
|
|
12384
12384
|
var import_axios3 = __toESM(require("axios"));
|
|
12385
|
+
var key = process.env.AI_302_KEY || process.env.NEXT_PUBLIC_AI_302_KEY;
|
|
12385
12386
|
var axios2 = import_axios3.default.create({
|
|
12386
12387
|
baseURL: "https://api.302.ai",
|
|
12387
12388
|
headers: {
|
|
12388
|
-
"mj-api-secret":
|
|
12389
|
-
Authorization: `Bearer ${
|
|
12389
|
+
"mj-api-secret": key,
|
|
12390
|
+
Authorization: `Bearer ${key}`
|
|
12390
12391
|
}
|
|
12391
12392
|
});
|
|
12392
12393
|
|
package/dist/node.esm.js
CHANGED
|
@@ -12198,11 +12198,12 @@ __export(exports_302, {
|
|
|
12198
12198
|
|
|
12199
12199
|
// src/ai/302/axios.ts
|
|
12200
12200
|
import axios_ from "axios";
|
|
12201
|
+
var key = process.env.AI_302_KEY || process.env.NEXT_PUBLIC_AI_302_KEY;
|
|
12201
12202
|
var axios2 = axios_.create({
|
|
12202
12203
|
baseURL: "https://api.302.ai",
|
|
12203
12204
|
headers: {
|
|
12204
|
-
"mj-api-secret":
|
|
12205
|
-
Authorization: `Bearer ${
|
|
12205
|
+
"mj-api-secret": key,
|
|
12206
|
+
Authorization: `Bearer ${key}`
|
|
12206
12207
|
}
|
|
12207
12208
|
});
|
|
12208
12209
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzyjs/utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.67",
|
|
4
4
|
"description": "description",
|
|
5
5
|
"author": "wzy",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"@types/nodemailer": "^6.4.7",
|
|
70
70
|
"@types/papaparse": "^5.3.15"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "e86ee4ba883177996f5c7c67db0cd0bcc026cb6e"
|
|
73
73
|
}
|