@glodon-aiot/agent-cli-ui 3.3.3 → 3.3.4-beta.2
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/es/AgentClientUI.mjs +121 -109
- package/dist/es/Dialog/AgentChat/HistoryItem/index.mjs +156 -142
- package/dist/es/Dialog/AgentChat/PromptSetting/index.mjs +83 -98
- package/dist/es/Dialog/AgentChat/index.mjs +331 -314
- package/dist/es/Dialog/SessionList/index.mjs +35 -34
- package/dist/es/Dialog/index.mjs +101 -94
- package/dist/es/ReactTextGenerationUI/components/TextSiders/index.mjs +394 -0
- package/dist/es/ReactTextGenerationUI/components/fetchEventSource/fetch.mjs +112 -0
- package/dist/es/ReactTextGenerationUI/components/fetchEventSource/parse.mjs +97 -0
- package/dist/es/ReactTextGenerationUI/index.mjs +81 -0
- package/dist/es/components/FilePreview/index.mjs +26 -25
- package/dist/es/index.mjs +402 -217
- package/dist/es/node_modules/moment/dist/moment.mjs +2301 -0
- package/dist/es/packages/agent-cli-ui/package.json.mjs +162 -0
- package/dist/es/packages/react-components/dist/es/components/Markdown/ATag/index.mjs +27 -25
- package/dist/es/packages/react-components/dist/es/components/Markdown/Image/index.mjs +29 -27
- package/dist/es/packages/react-components/dist/es/components/Markdown/index.mjs +58 -48
- package/dist/es/packages/react-components/dist/es/index.mjs +1 -1
- package/dist/es/src/style.css +1 -1
- package/dist/es/src/style10.css +1 -1
- package/dist/es/src/style11.css +1 -1
- package/dist/es/src/style12.css +1 -1
- package/dist/es/src/style13.css +1 -1
- package/dist/es/src/style14.css +1 -1
- package/dist/es/src/style15.css +1 -1
- package/dist/es/src/style16.css +1 -1
- package/dist/es/src/style17.css +1 -1
- package/dist/es/src/style18.css +1 -1
- package/dist/es/src/style19.css +1 -1
- package/dist/es/src/style2.css +1 -1
- package/dist/es/src/style20.css +1 -1
- package/dist/es/src/style21.css +1 -1
- package/dist/es/src/style22.css +1 -1
- package/dist/es/src/style23.css +1 -1
- package/dist/es/src/style24.css +1 -1
- package/dist/es/src/style25.css +1 -1
- package/dist/es/src/style26.css +1 -1
- package/dist/es/src/style27.css +1 -1
- package/dist/es/src/style28.css +1 -1
- package/dist/es/src/style29.css +1 -1
- package/dist/es/src/style3.css +1 -1
- package/dist/es/src/style30.css +1 -0
- package/dist/es/src/style31.css +1 -0
- package/dist/es/src/style4.css +1 -1
- package/dist/es/src/style5.css +1 -1
- package/dist/es/src/style6.css +1 -1
- package/dist/es/src/style7.css +1 -1
- package/dist/es/src/style8.css +1 -1
- package/dist/es/src/style9.css +1 -1
- package/dist/lib/index.css +1 -1
- package/dist/lib/index.js +69 -58
- package/dist/src/AgentClientUI.d.ts +10 -2
- package/dist/src/Dialog/AgentChat/HistoryItem/index.d.ts +2 -0
- package/dist/src/Dialog/SessionList/index.d.ts +1 -0
- package/dist/src/Dialog/index.d.ts +9 -1
- package/dist/src/index.d.ts +11 -2
- package/dist/src/types.d.ts +8 -3
- package/package.json +3 -3
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
var ge = Object.defineProperty, he = Object.defineProperties;
|
|
2
|
+
var ye = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var G = Object.getOwnPropertySymbols;
|
|
4
|
+
var Ie = Object.prototype.hasOwnProperty, ke = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Q = (n, d, l) => d in n ? ge(n, d, { enumerable: !0, configurable: !0, writable: !0, value: l }) : n[d] = l, V = (n, d) => {
|
|
6
|
+
for (var l in d || (d = {}))
|
|
7
|
+
Ie.call(d, l) && Q(n, l, d[l]);
|
|
8
|
+
if (G)
|
|
9
|
+
for (var l of G(d))
|
|
10
|
+
ke.call(d, l) && Q(n, l, d[l]);
|
|
11
|
+
return n;
|
|
12
|
+
}, X = (n, d) => he(n, ye(d));
|
|
13
|
+
var p = (n, d, l) => new Promise((u, v) => {
|
|
14
|
+
var q = (f) => {
|
|
15
|
+
try {
|
|
16
|
+
x(l.next(f));
|
|
17
|
+
} catch (b) {
|
|
18
|
+
v(b);
|
|
19
|
+
}
|
|
20
|
+
}, S = (f) => {
|
|
21
|
+
try {
|
|
22
|
+
x(l.throw(f));
|
|
23
|
+
} catch (b) {
|
|
24
|
+
v(b);
|
|
25
|
+
}
|
|
26
|
+
}, x = (f) => f.done ? u(f.value) : Promise.resolve(f.value).then(q, S);
|
|
27
|
+
x((l = l.apply(n, d)).next());
|
|
28
|
+
});
|
|
29
|
+
import { jsxs as w, jsx as o, Fragment as ve } from "react/jsx-runtime";
|
|
30
|
+
import { useState as h, useRef as Se, useContext as xe, useEffect as T } from "react";
|
|
31
|
+
import { Form as M, Collapse as _, Input as K, Button as be, message as C, notification as Pe } from "antd";
|
|
32
|
+
import { PromptVariableType as y } from "@glodon-aiot/apis";
|
|
33
|
+
import { v4 as pe } from "uuid";
|
|
34
|
+
import we from "../../../context.mjs";
|
|
35
|
+
import Ce from "../../../components/KnowledgeList/KnowledgeSelect/index.mjs";
|
|
36
|
+
import "../../../packages/react-components/dist/es/index.mjs";
|
|
37
|
+
import Ne from "../../../Dialog/AgentChat/HistoryItem/SessionRefer/index.mjs";
|
|
38
|
+
import Te from "../../../node_modules/moment/dist/moment.mjs";
|
|
39
|
+
/* empty css */import { fetchEventSource as Ae } from "../fetchEventSource/fetch.mjs";
|
|
40
|
+
import { Markdown as Ve } from "../../../packages/react-components/dist/es/components/Markdown/index.mjs";
|
|
41
|
+
const {
|
|
42
|
+
Panel: Z
|
|
43
|
+
} = _, Ee = ({
|
|
44
|
+
application: n,
|
|
45
|
+
sessionId: d,
|
|
46
|
+
docViewerUrl: l
|
|
47
|
+
}) => {
|
|
48
|
+
const u = n.id, [v, q] = h(""), [S, x] = h(""), [f, b] = h(), [L, N] = h(!1), D = Se(null), [H, ee] = h([]), [A, O] = h([]), [te, Y] = h(0), [$, j] = h(), [c, R] = h(), [E] = M.useForm(), [U, re] = h({}), [B, se] = h({}), [ne, ae] = h(0), {
|
|
49
|
+
service: g,
|
|
50
|
+
agentClient: I,
|
|
51
|
+
popupContainer: P,
|
|
52
|
+
token: oe,
|
|
53
|
+
apiUrl: ce
|
|
54
|
+
} = xe(we), le = (e, a, i, t) => {
|
|
55
|
+
const r = {
|
|
56
|
+
messageId: pe(),
|
|
57
|
+
content: "",
|
|
58
|
+
role: 1,
|
|
59
|
+
sessionId: "",
|
|
60
|
+
reference: [],
|
|
61
|
+
messageTime: "",
|
|
62
|
+
llmModel: "",
|
|
63
|
+
searchReference: []
|
|
64
|
+
}, s = X(V({}, i), {
|
|
65
|
+
stream: !0
|
|
66
|
+
});
|
|
67
|
+
Ae(`${ce}/chat/v2/chat?applicationId=${e}&sessionId=${a}`, {
|
|
68
|
+
method: "POST",
|
|
69
|
+
headers: {
|
|
70
|
+
Authorization: `Bearer ${oe}`,
|
|
71
|
+
"Content-Type": "application/json"
|
|
72
|
+
},
|
|
73
|
+
body: JSON.stringify(s),
|
|
74
|
+
openWhenHidden: !0,
|
|
75
|
+
onopen(m) {
|
|
76
|
+
return console.log("onopen"), m.ok && t != null && t.onopen && t.onopen(), Promise.resolve();
|
|
77
|
+
},
|
|
78
|
+
onmessage(m) {
|
|
79
|
+
if (!m.id && !m.data && !m.event && !m.retry)
|
|
80
|
+
return;
|
|
81
|
+
if (!m.data.includes('{"code": ')) {
|
|
82
|
+
r.content = r.content + m.data;
|
|
83
|
+
const F = {
|
|
84
|
+
content: r.content,
|
|
85
|
+
role: 1,
|
|
86
|
+
reference: r.reference,
|
|
87
|
+
messageId: r.messageId,
|
|
88
|
+
sessionId: a,
|
|
89
|
+
messageTime: Te(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:mm:ss"),
|
|
90
|
+
searchReference: []
|
|
91
|
+
};
|
|
92
|
+
return (t == null ? void 0 : t.onmessage) && t.onmessage(F);
|
|
93
|
+
}
|
|
94
|
+
const k = JSON.parse(m.data);
|
|
95
|
+
if (r.reference = k.data.reference, r.messageTime = k.data.messageTime, r.messageId = k.data.messageId, r.llmModel = k.data.llmModel, r.content = k.data.content, r.code = k.code, k.code === 200) {
|
|
96
|
+
const F = {
|
|
97
|
+
code: r.code,
|
|
98
|
+
content: r.content,
|
|
99
|
+
role: 1,
|
|
100
|
+
reference: r.reference,
|
|
101
|
+
messageId: r.messageId,
|
|
102
|
+
sessionId: a,
|
|
103
|
+
messageTime: r.messageTime,
|
|
104
|
+
searchReference: []
|
|
105
|
+
};
|
|
106
|
+
t != null && t.onmessage && t.onmessage(F);
|
|
107
|
+
} else
|
|
108
|
+
return Pe.error({
|
|
109
|
+
message: k.message
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
onerror() {
|
|
113
|
+
t != null && t.onerror && t.onerror();
|
|
114
|
+
},
|
|
115
|
+
onclose() {
|
|
116
|
+
console.log("onclose");
|
|
117
|
+
const m = {
|
|
118
|
+
code: r.code,
|
|
119
|
+
content: r.content,
|
|
120
|
+
role: 1,
|
|
121
|
+
reference: r.reference,
|
|
122
|
+
messageId: r.messageId,
|
|
123
|
+
sessionId: a,
|
|
124
|
+
messageTime: r.messageTime,
|
|
125
|
+
comment: {
|
|
126
|
+
isAgree: 0
|
|
127
|
+
},
|
|
128
|
+
searchReference: []
|
|
129
|
+
};
|
|
130
|
+
t != null && t.onclose && t.onclose(m);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
T(() => {
|
|
135
|
+
if (!(n != null && n.id))
|
|
136
|
+
return;
|
|
137
|
+
const e = n.arrange;
|
|
138
|
+
if (!(e != null && e.length))
|
|
139
|
+
return;
|
|
140
|
+
const i = e[0].knowledges || [];
|
|
141
|
+
ee(i), Y(i.length);
|
|
142
|
+
const t = i.map((r) => r.id);
|
|
143
|
+
O(t);
|
|
144
|
+
}, [n]), T(() => {
|
|
145
|
+
if (!(n != null && n.id) || !I)
|
|
146
|
+
return;
|
|
147
|
+
const e = I.questionContextMaxLength || 4e3;
|
|
148
|
+
ae(e), de();
|
|
149
|
+
}, [n, I]);
|
|
150
|
+
const de = () => p(void 0, null, function* () {
|
|
151
|
+
if (!g || !u)
|
|
152
|
+
return;
|
|
153
|
+
const e = yield g.postApplicationIdSession({
|
|
154
|
+
name: "AI 会话",
|
|
155
|
+
applicationId: u
|
|
156
|
+
});
|
|
157
|
+
j(e);
|
|
158
|
+
});
|
|
159
|
+
T(() => {
|
|
160
|
+
!u || !g || Promise.all([g.getApplicationIdPromptVariables(u, {
|
|
161
|
+
type: y.User,
|
|
162
|
+
status: 1
|
|
163
|
+
}), g.getApplicationIdPromptVariables(u, {
|
|
164
|
+
type: y.System,
|
|
165
|
+
status: 1
|
|
166
|
+
})]).then(([e, a]) => {
|
|
167
|
+
const r = [...e, ...a].filter((s) => !(s.type === y.User && s.key === "query") && !(s.type === y.System && s.key === "datetime")).map((s) => ({
|
|
168
|
+
id: s.id,
|
|
169
|
+
key: s.key,
|
|
170
|
+
name: s.name,
|
|
171
|
+
value: "",
|
|
172
|
+
type: s.type
|
|
173
|
+
}));
|
|
174
|
+
R(r);
|
|
175
|
+
});
|
|
176
|
+
}, [g, u]), T(() => {
|
|
177
|
+
if (!c)
|
|
178
|
+
return;
|
|
179
|
+
const e = c.filter((r) => r.type === y.User), a = c.filter((r) => r.type === y.System), i = {};
|
|
180
|
+
e == null || e.map((r) => {
|
|
181
|
+
r.key && (i[r.key] = r.value);
|
|
182
|
+
});
|
|
183
|
+
const t = {};
|
|
184
|
+
a == null || a.map((r) => {
|
|
185
|
+
r.key && (t[r.key] = r.value);
|
|
186
|
+
}), E.setFieldsValue({
|
|
187
|
+
userPrompts: i,
|
|
188
|
+
systemPrompts: t
|
|
189
|
+
}), re(i), se(t);
|
|
190
|
+
}, [c]);
|
|
191
|
+
const ie = (e, a) => p(void 0, null, function* () {
|
|
192
|
+
!$ || !u || !g || (yield g.patchApplicationIdSessionpromptVariablesId(u, $.id, e, {
|
|
193
|
+
value: a
|
|
194
|
+
}));
|
|
195
|
+
}), me = (e) => {
|
|
196
|
+
q(e.target.value);
|
|
197
|
+
}, ue = () => p(void 0, null, function* () {
|
|
198
|
+
if (!u || !g || !I)
|
|
199
|
+
return;
|
|
200
|
+
N(!0);
|
|
201
|
+
for (const t in U)
|
|
202
|
+
U[t] || (C.config({
|
|
203
|
+
getContainer: () => (P == null ? void 0 : P.current) || document.body
|
|
204
|
+
}), C.error("变量值不能为空"), C.config({
|
|
205
|
+
getContainer: void 0
|
|
206
|
+
}));
|
|
207
|
+
for (const t in B)
|
|
208
|
+
B[t] || (C.config({
|
|
209
|
+
getContainer: () => (P == null ? void 0 : P.current) || document.body
|
|
210
|
+
}), C.error("变量值不能为空"), C.config({
|
|
211
|
+
getContainer: void 0
|
|
212
|
+
}));
|
|
213
|
+
const e = yield g.postApplicationIdSession({
|
|
214
|
+
name: "AI 会话",
|
|
215
|
+
applicationId: u
|
|
216
|
+
});
|
|
217
|
+
j(e);
|
|
218
|
+
const a = A == null ? void 0 : A.map((t) => t.toString());
|
|
219
|
+
yield g.getApplicationIdSessionIdPromptVariables(u, e.id).then((t) => p(void 0, null, function* () {
|
|
220
|
+
if (!c)
|
|
221
|
+
return;
|
|
222
|
+
const r = t.filter((s) => s.key !== "query").map((s) => {
|
|
223
|
+
const m = c.filter((k) => k.key === s.key);
|
|
224
|
+
return s.value = m[0].value, s;
|
|
225
|
+
});
|
|
226
|
+
yield Promise.all(r.map((s) => ie(s.id, s.value))), R(r);
|
|
227
|
+
})).finally(() => {
|
|
228
|
+
N(!1);
|
|
229
|
+
});
|
|
230
|
+
const i = {
|
|
231
|
+
content: v,
|
|
232
|
+
chatMode: 1,
|
|
233
|
+
knowledges: a,
|
|
234
|
+
promptVariables: U,
|
|
235
|
+
systemPromptVariables: B
|
|
236
|
+
};
|
|
237
|
+
le(u, e.id, i, {
|
|
238
|
+
onmessage: (t) => {
|
|
239
|
+
N(!0), b(void 0), x(t.content);
|
|
240
|
+
},
|
|
241
|
+
onclose: (t) => p(void 0, null, function* () {
|
|
242
|
+
if (N(!1), t.code == 200) {
|
|
243
|
+
x(t.content);
|
|
244
|
+
const r = yield Promise.all(t.reference.map((s) => g.getKnowledgeIdFileId(s.knowledgeId, s.docId)));
|
|
245
|
+
t.reference = t.reference.map((s, m) => V(V({}, s), r[m])), b(t);
|
|
246
|
+
}
|
|
247
|
+
}),
|
|
248
|
+
onerror: () => {
|
|
249
|
+
N(!1);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
T(() => {
|
|
254
|
+
if (!S)
|
|
255
|
+
return;
|
|
256
|
+
const e = D.current;
|
|
257
|
+
e && (e.scrollTop = e.scrollHeight);
|
|
258
|
+
}, [S]);
|
|
259
|
+
const fe = (e) => {
|
|
260
|
+
O(e), Y(e.length);
|
|
261
|
+
}, z = (e, a) => {
|
|
262
|
+
c && (c.map((i) => {
|
|
263
|
+
i.id === e && (i.value = a.target.value);
|
|
264
|
+
}), R([...c]));
|
|
265
|
+
}, J = (c == null ? void 0 : c.filter((e) => e.type === y.System)) || [], W = (c == null ? void 0 : c.filter((e) => e.type === y.User)) || [];
|
|
266
|
+
return /* @__PURE__ */ w("div", {
|
|
267
|
+
className: "text-main",
|
|
268
|
+
children: [/* @__PURE__ */ w("div", {
|
|
269
|
+
className: "text-left-sider",
|
|
270
|
+
children: [!!(c != null && c.length) && /* @__PURE__ */ o(M, {
|
|
271
|
+
autoComplete: "off",
|
|
272
|
+
form: E,
|
|
273
|
+
labelWrap: !0,
|
|
274
|
+
labelAlign: "left",
|
|
275
|
+
labelCol: {
|
|
276
|
+
style: {
|
|
277
|
+
width: 120
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
className: "prompt-form",
|
|
281
|
+
children: /* @__PURE__ */ w(_, {
|
|
282
|
+
bordered: !1,
|
|
283
|
+
ghost: !0,
|
|
284
|
+
className: "prompt-variables-collapse",
|
|
285
|
+
defaultActiveKey: [y.System, y.User],
|
|
286
|
+
children: [J.length && /* @__PURE__ */ o(Z, {
|
|
287
|
+
header: "角色设定变量",
|
|
288
|
+
children: J.map((e) => /* @__PURE__ */ o(M.Item, {
|
|
289
|
+
label: e.name,
|
|
290
|
+
name: ["systemPrompts", e.key],
|
|
291
|
+
style: {
|
|
292
|
+
marginBottom: 8
|
|
293
|
+
},
|
|
294
|
+
rules: [{
|
|
295
|
+
required: !0,
|
|
296
|
+
message: "请输入"
|
|
297
|
+
}],
|
|
298
|
+
children: /* @__PURE__ */ o(K, {
|
|
299
|
+
placeholder: "请输入",
|
|
300
|
+
maxLength: I == null ? void 0 : I.questionContextMaxLength,
|
|
301
|
+
onBlur: (a) => z(e.id, a)
|
|
302
|
+
})
|
|
303
|
+
}, e.key))
|
|
304
|
+
}, y.System), W.length && /* @__PURE__ */ o(Z, {
|
|
305
|
+
header: "用户指令变量",
|
|
306
|
+
children: W.map((e) => /* @__PURE__ */ o(M.Item, {
|
|
307
|
+
label: e.name,
|
|
308
|
+
name: ["userPrompts", e.key],
|
|
309
|
+
style: {
|
|
310
|
+
marginBottom: 8
|
|
311
|
+
},
|
|
312
|
+
rules: [{
|
|
313
|
+
required: !0,
|
|
314
|
+
message: "请输入"
|
|
315
|
+
}],
|
|
316
|
+
children: /* @__PURE__ */ o(K, {
|
|
317
|
+
placeholder: "请输入",
|
|
318
|
+
maxLength: I == null ? void 0 : I.questionContextMaxLength,
|
|
319
|
+
onBlur: (a) => z(e.id, a)
|
|
320
|
+
})
|
|
321
|
+
}, e.key))
|
|
322
|
+
}, y.User)]
|
|
323
|
+
})
|
|
324
|
+
}), /* @__PURE__ */ w("div", {
|
|
325
|
+
className: "sider-header",
|
|
326
|
+
children: [/* @__PURE__ */ o("span", {
|
|
327
|
+
className: "header-title",
|
|
328
|
+
children: "文本生成输入"
|
|
329
|
+
}), H.length !== 0 && /* @__PURE__ */ o(Ce, {
|
|
330
|
+
checkedValues: A,
|
|
331
|
+
currKnowledgeList: H,
|
|
332
|
+
selectCount: te,
|
|
333
|
+
onSelectChange: fe,
|
|
334
|
+
disabled: !1
|
|
335
|
+
})]
|
|
336
|
+
}), /* @__PURE__ */ o("div", {
|
|
337
|
+
className: "sider-main",
|
|
338
|
+
children: /* @__PURE__ */ w("div", {
|
|
339
|
+
className: "sider-text",
|
|
340
|
+
children: [/* @__PURE__ */ o(K.TextArea, {
|
|
341
|
+
style: {
|
|
342
|
+
height: "100%",
|
|
343
|
+
resize: "none"
|
|
344
|
+
},
|
|
345
|
+
placeholder: "请输入你的问题,通过shift+enter换行",
|
|
346
|
+
maxLength: ne,
|
|
347
|
+
showCount: !0,
|
|
348
|
+
bordered: !1,
|
|
349
|
+
onChange: me,
|
|
350
|
+
value: v,
|
|
351
|
+
className: "left-input"
|
|
352
|
+
}), /* @__PURE__ */ o(be, {
|
|
353
|
+
type: "primary",
|
|
354
|
+
disabled: !v || L,
|
|
355
|
+
onClick: ue,
|
|
356
|
+
className: "sider-btn",
|
|
357
|
+
loading: L,
|
|
358
|
+
children: L ? "生成中" : "确认生成"
|
|
359
|
+
})]
|
|
360
|
+
})
|
|
361
|
+
})]
|
|
362
|
+
}), /* @__PURE__ */ o("div", {
|
|
363
|
+
className: "text-right-sider",
|
|
364
|
+
children: /* @__PURE__ */ o("div", {
|
|
365
|
+
className: "sider-main",
|
|
366
|
+
children: /* @__PURE__ */ o("div", {
|
|
367
|
+
className: "sider-text",
|
|
368
|
+
ref: D,
|
|
369
|
+
children: S ? /* @__PURE__ */ w(ve, {
|
|
370
|
+
children: [/* @__PURE__ */ o(Ve, {
|
|
371
|
+
children: S
|
|
372
|
+
}), f && (f == null ? void 0 : f.reference.length) !== 0 && /* @__PURE__ */ o("div", {
|
|
373
|
+
style: {
|
|
374
|
+
marginTop: 16
|
|
375
|
+
},
|
|
376
|
+
children: /* @__PURE__ */ o(Ne, {
|
|
377
|
+
history: f,
|
|
378
|
+
docViewerUrl: l
|
|
379
|
+
})
|
|
380
|
+
})]
|
|
381
|
+
}) : /* @__PURE__ */ o("div", {
|
|
382
|
+
className: "text-pannel",
|
|
383
|
+
children: /* @__PURE__ */ o("span", {
|
|
384
|
+
children: "请在左侧输入需要 AI 生成的内容"
|
|
385
|
+
})
|
|
386
|
+
})
|
|
387
|
+
})
|
|
388
|
+
})
|
|
389
|
+
})]
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
export {
|
|
393
|
+
Ee as default
|
|
394
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var W = Object.defineProperty, j = Object.defineProperties;
|
|
2
|
+
var k = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var v = Object.getOwnPropertySymbols;
|
|
4
|
+
var A = Object.prototype.hasOwnProperty, R = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var I = (t, e, a) => e in t ? W(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a, E = (t, e) => {
|
|
6
|
+
for (var a in e || (e = {}))
|
|
7
|
+
A.call(e, a) && I(t, a, e[a]);
|
|
8
|
+
if (v)
|
|
9
|
+
for (var a of v(e))
|
|
10
|
+
R.call(e, a) && I(t, a, e[a]);
|
|
11
|
+
return t;
|
|
12
|
+
}, $ = (t, e) => j(t, k(e));
|
|
13
|
+
var q = (t, e) => {
|
|
14
|
+
var a = {};
|
|
15
|
+
for (var n in t)
|
|
16
|
+
A.call(t, n) && e.indexOf(n) < 0 && (a[n] = t[n]);
|
|
17
|
+
if (t != null && v)
|
|
18
|
+
for (var n of v(t))
|
|
19
|
+
e.indexOf(n) < 0 && R.call(t, n) && (a[n] = t[n]);
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var B = (t, e, a) => new Promise((n, w) => {
|
|
23
|
+
var o = (r) => {
|
|
24
|
+
try {
|
|
25
|
+
c(a.next(r));
|
|
26
|
+
} catch (d) {
|
|
27
|
+
w(d);
|
|
28
|
+
}
|
|
29
|
+
}, i = (r) => {
|
|
30
|
+
try {
|
|
31
|
+
c(a.throw(r));
|
|
32
|
+
} catch (d) {
|
|
33
|
+
w(d);
|
|
34
|
+
}
|
|
35
|
+
}, c = (r) => r.done ? n(r.value) : Promise.resolve(r.value).then(o, i);
|
|
36
|
+
c((a = a.apply(t, e)).next());
|
|
37
|
+
});
|
|
38
|
+
import { getBytes as z, getLines as G, getMessages as H } from "./parse.mjs";
|
|
39
|
+
const g = "text/event-stream", J = 1e3, D = "last-event-id";
|
|
40
|
+
function X(t, N) {
|
|
41
|
+
var u = N, {
|
|
42
|
+
signal: e,
|
|
43
|
+
headers: a,
|
|
44
|
+
onopen: n,
|
|
45
|
+
onmessage: w,
|
|
46
|
+
onclose: o,
|
|
47
|
+
onerror: i,
|
|
48
|
+
openWhenHidden: c,
|
|
49
|
+
fetch: r
|
|
50
|
+
} = u, d = q(u, [
|
|
51
|
+
"signal",
|
|
52
|
+
"headers",
|
|
53
|
+
"onopen",
|
|
54
|
+
"onmessage",
|
|
55
|
+
"onclose",
|
|
56
|
+
"onerror",
|
|
57
|
+
"openWhenHidden",
|
|
58
|
+
"fetch"
|
|
59
|
+
]);
|
|
60
|
+
return new Promise((L, M) => {
|
|
61
|
+
const f = E({}, a);
|
|
62
|
+
f.accept || (f.accept = g);
|
|
63
|
+
let l;
|
|
64
|
+
function C() {
|
|
65
|
+
l.abort(), document.hidden || b();
|
|
66
|
+
}
|
|
67
|
+
c || document.addEventListener("visibilitychange", C);
|
|
68
|
+
let T = J, y = 0;
|
|
69
|
+
function h() {
|
|
70
|
+
document.removeEventListener("visibilitychange", C), window.clearTimeout(y), l.abort();
|
|
71
|
+
}
|
|
72
|
+
e == null || e.addEventListener("abort", () => {
|
|
73
|
+
h(), L();
|
|
74
|
+
});
|
|
75
|
+
const P = r != null ? r : window.fetch, V = n != null ? n : K;
|
|
76
|
+
function b() {
|
|
77
|
+
return B(this, null, function* () {
|
|
78
|
+
var x;
|
|
79
|
+
l = new AbortController();
|
|
80
|
+
try {
|
|
81
|
+
const m = yield P(t, $(E({}, d), {
|
|
82
|
+
headers: f,
|
|
83
|
+
signal: l.signal
|
|
84
|
+
}));
|
|
85
|
+
yield V(m), yield z(m.body, G(H((s) => {
|
|
86
|
+
s ? f[D] = s : delete f[D];
|
|
87
|
+
}, (s) => {
|
|
88
|
+
T = s;
|
|
89
|
+
}, w))), o == null || o(), h(), L();
|
|
90
|
+
} catch (m) {
|
|
91
|
+
if (!l.signal.aborted)
|
|
92
|
+
try {
|
|
93
|
+
const s = (x = i == null ? void 0 : i(m)) != null ? x : T;
|
|
94
|
+
window.clearTimeout(y), y = window.setTimeout(b, s);
|
|
95
|
+
} catch (s) {
|
|
96
|
+
h(), M(s);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
b();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function K(t) {
|
|
105
|
+
const e = t.headers.get("content-type");
|
|
106
|
+
if (!(e != null && e.startsWith(g)))
|
|
107
|
+
throw new Error(`Expected content-type to be ${g}, Actual: ${e}`);
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
g as EventStreamContentType,
|
|
111
|
+
X as fetchEventSource
|
|
112
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var b = (s, t, e) => new Promise((a, c) => {
|
|
2
|
+
var f = (r) => {
|
|
3
|
+
try {
|
|
4
|
+
i(e.next(r));
|
|
5
|
+
} catch (n) {
|
|
6
|
+
c(n);
|
|
7
|
+
}
|
|
8
|
+
}, l = (r) => {
|
|
9
|
+
try {
|
|
10
|
+
i(e.throw(r));
|
|
11
|
+
} catch (n) {
|
|
12
|
+
c(n);
|
|
13
|
+
}
|
|
14
|
+
}, i = (r) => r.done ? a(r.value) : Promise.resolve(r.value).then(f, l);
|
|
15
|
+
i((e = e.apply(s, t)).next());
|
|
16
|
+
});
|
|
17
|
+
function w(s, t) {
|
|
18
|
+
return b(this, null, function* () {
|
|
19
|
+
const e = s.getReader();
|
|
20
|
+
let a;
|
|
21
|
+
for (; !(a = yield e.read()).done; )
|
|
22
|
+
t(a.value);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function g(s) {
|
|
26
|
+
let t, e, a, c = !1, f;
|
|
27
|
+
return function(i) {
|
|
28
|
+
t === void 0 ? (t = i, e = 0, a = -1, f = !1) : t = h(t, i);
|
|
29
|
+
const r = t.length;
|
|
30
|
+
let n = 0;
|
|
31
|
+
for (; e < r; ) {
|
|
32
|
+
c && (t[e] === 10 && (n = ++e), c = !1);
|
|
33
|
+
let o = -1;
|
|
34
|
+
for (; e < r && o === -1; ++e)
|
|
35
|
+
switch (t[e]) {
|
|
36
|
+
case 58:
|
|
37
|
+
a === -1 && (a = e - n);
|
|
38
|
+
break;
|
|
39
|
+
case 13:
|
|
40
|
+
c = !1, e + 4 < r && t[e + 1] === 10 && t[e + 2] !== 13 && t[e - 1] !== 10 && t[e - 2] !== 13 && (f = !0);
|
|
41
|
+
case 10:
|
|
42
|
+
o = e;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
if (o === -1)
|
|
46
|
+
break;
|
|
47
|
+
s(t.subarray(n, o), a, f), n = e, a = -1, f = !1;
|
|
48
|
+
}
|
|
49
|
+
n === r ? t = void 0 : n !== 0 && (t = t.subarray(n), e -= n);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function k(s, t, e) {
|
|
53
|
+
let a = y();
|
|
54
|
+
const c = new TextDecoder();
|
|
55
|
+
return function(l, i, r) {
|
|
56
|
+
if (l.length === 0)
|
|
57
|
+
e == null || e(a), a = y();
|
|
58
|
+
else if (i > 0) {
|
|
59
|
+
const n = c.decode(l.subarray(0, i)), o = i + (l[i + 1] === 32 ? 2 : 1);
|
|
60
|
+
let d = c.decode(l.subarray(o));
|
|
61
|
+
switch (r && (d += `
|
|
62
|
+
`), n) {
|
|
63
|
+
case "data":
|
|
64
|
+
a.data = a.data ? a.data + `
|
|
65
|
+
` + d : d;
|
|
66
|
+
break;
|
|
67
|
+
case "event":
|
|
68
|
+
a.event = d;
|
|
69
|
+
break;
|
|
70
|
+
case "id":
|
|
71
|
+
s(a.id = d);
|
|
72
|
+
break;
|
|
73
|
+
case "retry":
|
|
74
|
+
const u = parseInt(d, 10);
|
|
75
|
+
isNaN(u) || t(a.retry = u);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function h(s, t) {
|
|
82
|
+
const e = new Uint8Array(s.length + t.length);
|
|
83
|
+
return e.set(s), e.set(t, s.length), e;
|
|
84
|
+
}
|
|
85
|
+
function y() {
|
|
86
|
+
return {
|
|
87
|
+
data: "",
|
|
88
|
+
event: "",
|
|
89
|
+
id: "",
|
|
90
|
+
retry: void 0
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
w as getBytes,
|
|
95
|
+
g as getLines,
|
|
96
|
+
k as getMessages
|
|
97
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
var A = Object.defineProperty, L = Object.defineProperties;
|
|
2
|
+
var M = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var i = Object.getOwnPropertySymbols;
|
|
4
|
+
var P = Object.prototype.hasOwnProperty, j = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var s = (o, e, t) => e in o ? A(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, a = (o, e) => {
|
|
6
|
+
for (var t in e || (e = {}))
|
|
7
|
+
P.call(e, t) && s(o, t, e[t]);
|
|
8
|
+
if (i)
|
|
9
|
+
for (var t of i(e))
|
|
10
|
+
j.call(e, t) && s(o, t, e[t]);
|
|
11
|
+
return o;
|
|
12
|
+
}, d = (o, e) => L(o, M(e));
|
|
13
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
14
|
+
import { useRef as w, useState as l, useEffect as z } from "react";
|
|
15
|
+
/* empty css */import { ConfigProvider as m } from "antd";
|
|
16
|
+
import B from "antd/es/locale/zh_CN";
|
|
17
|
+
import E from "./components/TextSiders/index.mjs";
|
|
18
|
+
import { JWT as J } from "../utils/index.mjs";
|
|
19
|
+
import { AgentClientProvider as V } from "../context.mjs";
|
|
20
|
+
const Z = (o) => {
|
|
21
|
+
const {
|
|
22
|
+
application: e,
|
|
23
|
+
theme: t,
|
|
24
|
+
token: r,
|
|
25
|
+
footer: f,
|
|
26
|
+
defaultInput: c,
|
|
27
|
+
onComment: p,
|
|
28
|
+
onSessionLoad: u,
|
|
29
|
+
onSessionUnload: g,
|
|
30
|
+
onMessage: h,
|
|
31
|
+
beforeMessageSend: C,
|
|
32
|
+
bodyStyle: S,
|
|
33
|
+
sessionId: v,
|
|
34
|
+
disabled: x,
|
|
35
|
+
transform: I,
|
|
36
|
+
features: b,
|
|
37
|
+
agentClient: N,
|
|
38
|
+
docViewerUrl: R
|
|
39
|
+
} = o, T = w(null), [U, W] = l(!1), [q, k] = l();
|
|
40
|
+
return z(() => {
|
|
41
|
+
if (!r)
|
|
42
|
+
return;
|
|
43
|
+
const y = J(r);
|
|
44
|
+
k(y.rid);
|
|
45
|
+
}, [r]), m.config({
|
|
46
|
+
theme: t
|
|
47
|
+
}), /* @__PURE__ */ n(m, {
|
|
48
|
+
locale: B,
|
|
49
|
+
children: /* @__PURE__ */ n(V, {
|
|
50
|
+
value: d(a({}, o), {
|
|
51
|
+
popupContainer: T,
|
|
52
|
+
agentClient: N,
|
|
53
|
+
footer: f,
|
|
54
|
+
defaultInput: c,
|
|
55
|
+
onComment: p,
|
|
56
|
+
onSessionLoad: u,
|
|
57
|
+
onSessionUnload: g,
|
|
58
|
+
onMessage: h,
|
|
59
|
+
beforeMessageSend: C,
|
|
60
|
+
bodyStyle: S,
|
|
61
|
+
disabled: x,
|
|
62
|
+
transform: I,
|
|
63
|
+
features: b
|
|
64
|
+
}),
|
|
65
|
+
children: !U && /* @__PURE__ */ n("div", {
|
|
66
|
+
className: "gbot-dialog-modal chat-text",
|
|
67
|
+
children: /* @__PURE__ */ n("div", {
|
|
68
|
+
className: "text-pannel",
|
|
69
|
+
children: /* @__PURE__ */ n(E, {
|
|
70
|
+
application: e,
|
|
71
|
+
sessionId: v,
|
|
72
|
+
docViewerUrl: R
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
Z as default
|
|
81
|
+
};
|