ant-design-x-vue 1.2.0 → 1.2.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/README.en.md +6 -0
- package/README.md +5 -0
- package/dist/index.umd.js +10 -10
- package/es/attachments/FileList/FileList2.mjs +10 -12
- package/es/sender/components/LoadingButton.mjs +5 -5
- package/es/thought-chain/hooks/useCollapsible.mjs +25 -17
- package/es/use-x-agent/use-x-agent.mjs +41 -34
- package/es/use-x-chat/use-x-chat.mjs +98 -69
- package/es/x-request/x-request.mjs +55 -53
- package/lib/attachments/FileList/FileList2.js +1 -1
- package/lib/sender/components/LoadingButton.js +1 -1
- package/lib/thought-chain/hooks/useCollapsible.js +1 -1
- package/lib/use-x-agent/use-x-agent.js +1 -1
- package/lib/use-x-chat/use-x-chat.js +1 -1
- package/lib/x-request/x-request.js +1 -1
- package/package.json +1 -1
- package/typings/use-x-agent/use-x-agent.d.ts +3 -1
- package/typings/use-x-chat/use-x-chat.d.ts +15 -1
- package/typings/x-request/x-request.d.ts +4 -0
|
@@ -1465,18 +1465,16 @@ const Et = 1, dn = /* @__PURE__ */ Nt({
|
|
|
1465
1465
|
name: "AXAttachmentsFileList",
|
|
1466
1466
|
__name: "FileList",
|
|
1467
1467
|
props: {
|
|
1468
|
-
prefixCls:
|
|
1469
|
-
items:
|
|
1470
|
-
onRemove: {
|
|
1471
|
-
|
|
1472
|
-
},
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
itemClassName: null,
|
|
1479
|
-
itemStyle: null
|
|
1468
|
+
prefixCls: {},
|
|
1469
|
+
items: {},
|
|
1470
|
+
onRemove: {},
|
|
1471
|
+
overflow: {},
|
|
1472
|
+
upload: {},
|
|
1473
|
+
imageProps: {},
|
|
1474
|
+
listClassName: {},
|
|
1475
|
+
listStyle: {},
|
|
1476
|
+
itemClassName: {},
|
|
1477
|
+
itemStyle: {}
|
|
1480
1478
|
},
|
|
1481
1479
|
setup(t) {
|
|
1482
1480
|
const e = be(() => `${t.prefixCls}-list`), r = me("file-list-container"), [n, a] = I(!1), i = xe();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineComponent as a, mergeDefaults as r, createVNode as l, mergeProps as s } from "vue";
|
|
2
2
|
import { a as i, c as u } from "../../attachments/Attachments2.mjs";
|
|
3
3
|
import c from "./ActionButton/index.mjs";
|
|
4
|
-
import
|
|
5
|
-
import { useActionButtonContextInject as
|
|
4
|
+
import d from "../StopLoading.mjs";
|
|
5
|
+
import { useActionButtonContextInject as m } from "./ActionButton/context.mjs";
|
|
6
6
|
import { theme as p } from "ant-design-vue";
|
|
7
7
|
const x = /* @__PURE__ */ a({
|
|
8
8
|
name: "AXSenderLoadingButton",
|
|
@@ -27,11 +27,11 @@ const x = /* @__PURE__ */ a({
|
|
|
27
27
|
}, {
|
|
28
28
|
type: "primary",
|
|
29
29
|
shape: "circle",
|
|
30
|
-
icon:
|
|
30
|
+
icon: void 0,
|
|
31
31
|
disabled: void 0
|
|
32
32
|
}),
|
|
33
33
|
setup(e) {
|
|
34
|
-
const o = i(e, ["type", "shape", "icon", "disabled"]), n =
|
|
34
|
+
const o = i(e, ["type", "shape", "icon", "disabled"]), n = m(), {
|
|
35
35
|
token: t
|
|
36
36
|
} = p.useToken();
|
|
37
37
|
return () => l(c, s({
|
|
@@ -47,7 +47,7 @@ const x = /* @__PURE__ */ a({
|
|
|
47
47
|
class: u(`${n.value.prefixCls}-loading-button`),
|
|
48
48
|
action: "onCancel"
|
|
49
49
|
}), {
|
|
50
|
-
default: () => [l(
|
|
50
|
+
default: () => [l(d, {
|
|
51
51
|
className: `${n.value.prefixCls}-loading-icon`
|
|
52
52
|
}, null)]
|
|
53
53
|
});
|
|
@@ -1,33 +1,41 @@
|
|
|
1
1
|
import r from "../../_util/hooks/use-state.mjs";
|
|
2
|
-
import { computed as
|
|
3
|
-
const b = (
|
|
4
|
-
const n =
|
|
5
|
-
const
|
|
6
|
-
let
|
|
2
|
+
import { computed as p, toValue as u, watch as c } from "vue";
|
|
3
|
+
const b = (t, f, m) => {
|
|
4
|
+
const n = p(() => {
|
|
5
|
+
const e = u(t);
|
|
6
|
+
let a = {
|
|
7
7
|
expandedKeys: [],
|
|
8
8
|
onExpand: () => {
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
-
return
|
|
11
|
+
return e ? (typeof e == "object" && (a = { ...a, ...e }), {
|
|
12
12
|
enableCollapse: !0,
|
|
13
|
-
customizeExpandedKeys:
|
|
14
|
-
customizeOnExpand:
|
|
13
|
+
customizeExpandedKeys: a.expandedKeys,
|
|
14
|
+
customizeOnExpand: a.onExpand
|
|
15
15
|
}) : {
|
|
16
16
|
enableCollapse: !1,
|
|
17
|
-
customizeExpandedKeys:
|
|
18
|
-
customizeOnExpand:
|
|
17
|
+
customizeExpandedKeys: a.expandedKeys,
|
|
18
|
+
customizeOnExpand: a.onExpand
|
|
19
19
|
};
|
|
20
|
-
}), [s,
|
|
21
|
-
var l,
|
|
20
|
+
}), [s, o] = r(n.value.customizeExpandedKeys), i = (e) => {
|
|
21
|
+
var l, d;
|
|
22
22
|
if (!n.value.enableCollapse)
|
|
23
23
|
return;
|
|
24
|
-
const
|
|
25
|
-
(
|
|
24
|
+
const a = s.value.includes(e) ? s.value.filter((x) => x !== e) : [...s.value, e];
|
|
25
|
+
(d = (l = n.value).customizeOnExpand) == null || d.call(l, a), typeof u(t) != "object" && o(a);
|
|
26
26
|
};
|
|
27
|
-
return
|
|
28
|
-
|
|
27
|
+
return c(
|
|
28
|
+
n,
|
|
29
|
+
(e) => {
|
|
30
|
+
o(e.customizeExpandedKeys);
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
deep: 1
|
|
34
|
+
}
|
|
35
|
+
), [
|
|
36
|
+
p(() => n.value.enableCollapse),
|
|
29
37
|
s,
|
|
30
|
-
|
|
38
|
+
i
|
|
31
39
|
// collapseMotion,
|
|
32
40
|
];
|
|
33
41
|
};
|
|
@@ -1,49 +1,56 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { computed as
|
|
3
|
-
let
|
|
4
|
-
class
|
|
5
|
-
constructor(
|
|
6
|
-
this.requestingMap = {}, this.request = (
|
|
7
|
-
const { request: n } = this.config, { onUpdate:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import p from "../x-request/x-request.mjs";
|
|
2
|
+
import { computed as f, ref as q } from "vue";
|
|
3
|
+
let a = 0;
|
|
4
|
+
class d {
|
|
5
|
+
constructor(i) {
|
|
6
|
+
this.requestingMap = q({}), this.request = (s, o, g) => {
|
|
7
|
+
const { request: n } = this.config, { onUpdate: c, onSuccess: h, onError: l, onStream: u } = o, e = a;
|
|
8
|
+
a += 1, this.requestingMap.value[e] = !0, n == null || n(
|
|
9
|
+
s,
|
|
10
|
+
{
|
|
11
|
+
onStream: (t) => {
|
|
12
|
+
this.requestingMap.value[e] && (u == null || u(t));
|
|
13
|
+
},
|
|
14
|
+
// Status should be unique.
|
|
15
|
+
// One get success or error should not get more message
|
|
16
|
+
onUpdate: (t) => {
|
|
17
|
+
this.requestingMap.value[e] && c(t);
|
|
18
|
+
},
|
|
19
|
+
onSuccess: (t) => {
|
|
20
|
+
this.requestingMap.value[e] && (h(t), this.finishRequest(e));
|
|
21
|
+
},
|
|
22
|
+
onError: (t) => {
|
|
23
|
+
this.requestingMap.value[e] && (l(t), this.finishRequest(e));
|
|
24
|
+
}
|
|
13
25
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
onError: (i) => {
|
|
18
|
-
this.requestingMap[t] && (g(i), this.finishRequest(t));
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}, this.config = s;
|
|
26
|
+
g
|
|
27
|
+
);
|
|
28
|
+
}, this.config = i;
|
|
22
29
|
}
|
|
23
|
-
finishRequest(
|
|
24
|
-
delete this.requestingMap[
|
|
30
|
+
finishRequest(i) {
|
|
31
|
+
delete this.requestingMap.value[i];
|
|
25
32
|
}
|
|
26
33
|
isRequesting() {
|
|
27
|
-
return Object.keys(this.requestingMap).length > 0;
|
|
34
|
+
return Object.keys(this.requestingMap.value).length > 0;
|
|
28
35
|
}
|
|
29
36
|
}
|
|
30
|
-
function
|
|
31
|
-
const { request:
|
|
37
|
+
function v(r) {
|
|
38
|
+
const { request: i, ...s } = r;
|
|
32
39
|
return [
|
|
33
|
-
|
|
34
|
-
() => new
|
|
40
|
+
f(
|
|
41
|
+
() => new d({
|
|
35
42
|
// @ts-expect-error
|
|
36
|
-
request:
|
|
37
|
-
baseURL:
|
|
38
|
-
model:
|
|
39
|
-
dangerouslyApiKey:
|
|
43
|
+
request: i || p({
|
|
44
|
+
baseURL: s.baseURL,
|
|
45
|
+
model: s.model,
|
|
46
|
+
dangerouslyApiKey: s.dangerouslyApiKey
|
|
40
47
|
}).create,
|
|
41
|
-
...
|
|
48
|
+
...s
|
|
42
49
|
})
|
|
43
50
|
)
|
|
44
51
|
];
|
|
45
52
|
}
|
|
46
53
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
d as XAgent,
|
|
55
|
+
v as default
|
|
49
56
|
};
|
|
@@ -1,97 +1,126 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import
|
|
3
|
-
import { useEventCallback as
|
|
4
|
-
function
|
|
5
|
-
return Array.isArray(
|
|
1
|
+
import { ref as F, computed as $ } from "vue";
|
|
2
|
+
import I from "./useSyncState.mjs";
|
|
3
|
+
import { useEventCallback as T } from "../_util/hooks/use-event-callback.mjs";
|
|
4
|
+
function W(i) {
|
|
5
|
+
return Array.isArray(i) ? i : [i];
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
const {
|
|
9
|
-
|
|
7
|
+
function U(i) {
|
|
8
|
+
const {
|
|
9
|
+
defaultMessages: q,
|
|
10
|
+
agent: b,
|
|
11
|
+
requestFallback: d,
|
|
12
|
+
requestPlaceholder: f,
|
|
13
|
+
parser: v,
|
|
14
|
+
transformMessage: R,
|
|
15
|
+
transformStream: A,
|
|
16
|
+
resolveAbortController: h
|
|
17
|
+
} = i, w = F(0), _ = $(() => (q || []).map((s, t) => ({
|
|
18
|
+
id: `default_${t}`,
|
|
10
19
|
status: "local",
|
|
11
|
-
...
|
|
12
|
-
}))), [
|
|
13
|
-
}),
|
|
20
|
+
...s
|
|
21
|
+
}))), [m, g] = I(_.value, () => {
|
|
22
|
+
}), M = (s, t) => {
|
|
14
23
|
const o = {
|
|
15
|
-
id: `msg_${
|
|
16
|
-
message:
|
|
17
|
-
status:
|
|
24
|
+
id: `msg_${w.value}`,
|
|
25
|
+
message: s,
|
|
26
|
+
status: t
|
|
18
27
|
};
|
|
19
|
-
return
|
|
20
|
-
},
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
const o =
|
|
24
|
-
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
id:
|
|
28
|
-
message:
|
|
29
|
-
status:
|
|
28
|
+
return w.value += 1, o;
|
|
29
|
+
}, x = $(() => {
|
|
30
|
+
const s = [];
|
|
31
|
+
return m.value.forEach((t) => {
|
|
32
|
+
const o = v ? v(t.message) : t.message, u = W(o);
|
|
33
|
+
u.forEach((l, p) => {
|
|
34
|
+
let e = t.id;
|
|
35
|
+
u.length > 1 && (e = `${e}_${p}`), s.push({
|
|
36
|
+
id: e,
|
|
37
|
+
message: l,
|
|
38
|
+
status: t.status
|
|
30
39
|
});
|
|
31
40
|
});
|
|
32
|
-
}),
|
|
33
|
-
}),
|
|
41
|
+
}), s;
|
|
42
|
+
}), E = (s) => s.filter((t) => t.status !== "loading" && t.status !== "error").map((t) => t.message), S = () => E(m.value), k = (s) => typeof R == "function" ? R(s) : s.currentMessage;
|
|
34
43
|
return {
|
|
35
|
-
onRequest:
|
|
36
|
-
if (!
|
|
44
|
+
onRequest: T((s) => {
|
|
45
|
+
if (!b)
|
|
37
46
|
throw new Error(
|
|
38
47
|
"The agent parameter is required when using the onRequest method in an agent generated by useXAgent."
|
|
39
48
|
);
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
let t = null, o, u = {};
|
|
50
|
+
if (typeof s == "object" && (s != null && s.message)) {
|
|
51
|
+
const { message: e, ...r } = s;
|
|
52
|
+
o = e, u = r;
|
|
53
|
+
} else
|
|
54
|
+
o = s;
|
|
55
|
+
g((e) => {
|
|
56
|
+
let r = [...e, M(o, "local")];
|
|
57
|
+
if (f) {
|
|
58
|
+
let a;
|
|
59
|
+
typeof f == "function" ? a = f(o, {
|
|
60
|
+
messages: E(r)
|
|
61
|
+
}) : a = f;
|
|
62
|
+
const n = M(a, "loading");
|
|
63
|
+
t = n.id, r = [...r, n];
|
|
50
64
|
}
|
|
51
|
-
return
|
|
65
|
+
return r;
|
|
52
66
|
});
|
|
53
|
-
let
|
|
54
|
-
const
|
|
55
|
-
let
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
67
|
+
let l = null;
|
|
68
|
+
const p = (e, r) => {
|
|
69
|
+
let a = m.value.find((n) => n.id === l);
|
|
70
|
+
return a ? g((n) => n.map((c) => {
|
|
71
|
+
if (c.id === l) {
|
|
72
|
+
const y = k({
|
|
73
|
+
originMessage: c.message,
|
|
74
|
+
currentMessage: e,
|
|
75
|
+
status: r
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
...c,
|
|
79
|
+
message: y,
|
|
80
|
+
status: r
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return c;
|
|
84
|
+
})) : (k({ currentMessage: e, status: r }), a = M(e, r), g((n) => [...n.filter((y) => y.id !== t), a]), l = a.id), a;
|
|
61
85
|
};
|
|
62
|
-
|
|
86
|
+
b.request(
|
|
63
87
|
{
|
|
64
|
-
message:
|
|
65
|
-
messages:
|
|
88
|
+
message: o,
|
|
89
|
+
messages: S(),
|
|
90
|
+
...u
|
|
66
91
|
},
|
|
67
92
|
{
|
|
68
|
-
onUpdate: (
|
|
69
|
-
|
|
93
|
+
onUpdate: (e) => {
|
|
94
|
+
p(e, "loading");
|
|
70
95
|
},
|
|
71
|
-
onSuccess: (
|
|
72
|
-
|
|
96
|
+
onSuccess: (e) => {
|
|
97
|
+
p(e, "success");
|
|
73
98
|
},
|
|
74
|
-
onError: async (
|
|
99
|
+
onError: async (e) => {
|
|
75
100
|
if (d) {
|
|
76
|
-
let
|
|
77
|
-
typeof d == "function" ?
|
|
78
|
-
error:
|
|
79
|
-
messages:
|
|
80
|
-
}) :
|
|
81
|
-
...
|
|
82
|
-
|
|
101
|
+
let r;
|
|
102
|
+
typeof d == "function" ? r = await d(o, {
|
|
103
|
+
error: e,
|
|
104
|
+
messages: S()
|
|
105
|
+
}) : r = d, g((a) => [
|
|
106
|
+
...a.filter((n) => n.id !== t && n.id !== l),
|
|
107
|
+
M(r, "error")
|
|
83
108
|
]);
|
|
84
109
|
} else
|
|
85
|
-
|
|
110
|
+
g((r) => r.filter((a) => a.id !== t && a.id !== l));
|
|
111
|
+
},
|
|
112
|
+
onStream: (e) => {
|
|
113
|
+
h == null || h(e);
|
|
86
114
|
}
|
|
87
|
-
}
|
|
115
|
+
},
|
|
116
|
+
A
|
|
88
117
|
);
|
|
89
118
|
}),
|
|
90
|
-
messages:
|
|
91
|
-
parsedMessages:
|
|
92
|
-
setMessages:
|
|
119
|
+
messages: m,
|
|
120
|
+
parsedMessages: x,
|
|
121
|
+
setMessages: g
|
|
93
122
|
};
|
|
94
123
|
}
|
|
95
124
|
export {
|
|
96
|
-
|
|
125
|
+
U as default
|
|
97
126
|
};
|
|
@@ -1,83 +1,85 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
constructor(
|
|
5
|
-
this.create = async (
|
|
6
|
-
var
|
|
7
|
-
const
|
|
1
|
+
import y from "../x-stream/x-stream.mjs";
|
|
2
|
+
import R from "./x-fetch.mjs";
|
|
3
|
+
const s = class s {
|
|
4
|
+
constructor(t) {
|
|
5
|
+
this.create = async (h, e, o) => {
|
|
6
|
+
var i, u;
|
|
7
|
+
const n = new AbortController(), r = {
|
|
8
8
|
method: "POST",
|
|
9
9
|
body: JSON.stringify({
|
|
10
10
|
model: this.model,
|
|
11
|
-
...
|
|
11
|
+
...h
|
|
12
12
|
}),
|
|
13
|
-
headers: this.defaultHeaders
|
|
13
|
+
headers: this.defaultHeaders,
|
|
14
|
+
signal: n.signal
|
|
14
15
|
};
|
|
16
|
+
(i = e == null ? void 0 : e.onStream) == null || i.call(e, n);
|
|
15
17
|
try {
|
|
16
|
-
const
|
|
18
|
+
const d = await R(this.baseURL, {
|
|
17
19
|
fetch: this.customOptions.fetch,
|
|
18
|
-
...
|
|
20
|
+
...r
|
|
19
21
|
});
|
|
20
|
-
if (
|
|
21
|
-
await this.customResponseHandler(
|
|
22
|
+
if (o) {
|
|
23
|
+
await this.customResponseHandler(d, e, o);
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
24
|
-
const
|
|
25
|
-
switch (
|
|
26
|
+
const p = d.headers.get("content-type") || "";
|
|
27
|
+
switch (p.split(";")[0].trim()) {
|
|
26
28
|
/** SSE */
|
|
27
29
|
case "text/event-stream":
|
|
28
|
-
await this.sseResponseHandler(
|
|
30
|
+
await this.sseResponseHandler(d, e);
|
|
29
31
|
break;
|
|
30
32
|
/** JSON */
|
|
31
33
|
case "application/json":
|
|
32
|
-
await this.jsonResponseHandler(
|
|
34
|
+
await this.jsonResponseHandler(d, e);
|
|
33
35
|
break;
|
|
34
36
|
default:
|
|
35
|
-
throw new Error(`The response content-type: ${
|
|
37
|
+
throw new Error(`The response content-type: ${p} is not support!`);
|
|
36
38
|
}
|
|
37
|
-
} catch (
|
|
38
|
-
const
|
|
39
|
-
throw (
|
|
39
|
+
} catch (d) {
|
|
40
|
+
const p = d instanceof Error ? d : new Error("Unknown error!");
|
|
41
|
+
throw (u = e == null ? void 0 : e.onError) == null || u.call(e, p), p;
|
|
40
42
|
}
|
|
41
|
-
}, this.customResponseHandler = async (
|
|
42
|
-
var
|
|
43
|
-
const
|
|
44
|
-
for await (const
|
|
45
|
-
readableStream:
|
|
46
|
-
transformStream:
|
|
43
|
+
}, this.customResponseHandler = async (h, e, o) => {
|
|
44
|
+
var r, i;
|
|
45
|
+
const n = [];
|
|
46
|
+
for await (const u of y({
|
|
47
|
+
readableStream: h.body,
|
|
48
|
+
transformStream: o
|
|
47
49
|
}))
|
|
48
|
-
|
|
49
|
-
(
|
|
50
|
-
}, this.sseResponseHandler = async (
|
|
51
|
-
var
|
|
52
|
-
const
|
|
53
|
-
for await (const
|
|
54
|
-
readableStream:
|
|
50
|
+
n.push(u), (r = e == null ? void 0 : e.onUpdate) == null || r.call(e, u);
|
|
51
|
+
(i = e == null ? void 0 : e.onSuccess) == null || i.call(e, n);
|
|
52
|
+
}, this.sseResponseHandler = async (h, e) => {
|
|
53
|
+
var n, r;
|
|
54
|
+
const o = [];
|
|
55
|
+
for await (const i of y({
|
|
56
|
+
readableStream: h.body
|
|
55
57
|
}))
|
|
56
|
-
|
|
57
|
-
(
|
|
58
|
-
}, this.jsonResponseHandler = async (
|
|
59
|
-
var
|
|
60
|
-
const
|
|
61
|
-
(
|
|
58
|
+
o.push(i), (n = e == null ? void 0 : e.onUpdate) == null || n.call(e, i);
|
|
59
|
+
(r = e == null ? void 0 : e.onSuccess) == null || r.call(e, o);
|
|
60
|
+
}, this.jsonResponseHandler = async (h, e) => {
|
|
61
|
+
var n, r;
|
|
62
|
+
const o = await h.json();
|
|
63
|
+
(n = e == null ? void 0 : e.onUpdate) == null || n.call(e, o), (r = e == null ? void 0 : e.onSuccess) == null || r.call(e, [o]);
|
|
62
64
|
};
|
|
63
|
-
const { baseURL:
|
|
64
|
-
this.baseURL =
|
|
65
|
+
const { baseURL: f, model: U, dangerouslyApiKey: g, ...w } = t;
|
|
66
|
+
this.baseURL = t.baseURL, this.model = t.model, this.defaultHeaders = {
|
|
65
67
|
"Content-Type": "application/json",
|
|
66
|
-
...
|
|
67
|
-
Authorization:
|
|
68
|
+
...t.dangerouslyApiKey && {
|
|
69
|
+
Authorization: t.dangerouslyApiKey
|
|
68
70
|
}
|
|
69
|
-
}, this.customOptions =
|
|
71
|
+
}, this.customOptions = w;
|
|
70
72
|
}
|
|
71
|
-
static init(
|
|
72
|
-
if (!
|
|
73
|
+
static init(t) {
|
|
74
|
+
if (!t.baseURL || typeof t.baseURL != "string")
|
|
73
75
|
throw new Error("The baseURL is not valid!");
|
|
74
|
-
const
|
|
75
|
-
return
|
|
76
|
+
const f = t.fetch || t.baseURL;
|
|
77
|
+
return s.instanceBuffer.has(f) || s.instanceBuffer.set(f, new s(t)), s.instanceBuffer.get(f);
|
|
76
78
|
}
|
|
77
79
|
};
|
|
78
|
-
|
|
79
|
-
let
|
|
80
|
-
const
|
|
80
|
+
s.instanceBuffer = /* @__PURE__ */ new Map();
|
|
81
|
+
let m = s;
|
|
82
|
+
const T = m.init;
|
|
81
83
|
export {
|
|
82
|
-
|
|
84
|
+
T as default
|
|
83
85
|
};
|