@glodon-aiot/agent-cli-ui 3.3.2-beta.10 → 3.3.2-beta.12
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 +2 -2
- package/dist/es/ReactTextGenerationUI/components/TextSiders/index.mjs +354 -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 +79 -0
- package/dist/es/index.mjs +406 -256
- 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/index.mjs +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/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/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 +67 -56
- package/dist/src/ReactTextGenerationUI/components/TextSiders/index.d.ts +21 -0
- package/dist/src/ReactTextGenerationUI/components/fetchEventSource/fetch.d.ts +44 -0
- package/dist/src/ReactTextGenerationUI/components/fetchEventSource/index.d.ts +1 -0
- package/dist/src/ReactTextGenerationUI/components/fetchEventSource/parse.d.ts +36 -0
- package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/fetch.d.ts +44 -0
- package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/index.d.ts +1 -0
- package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/parse.d.ts +36 -0
- package/dist/src/ReactTextGenerationUI/index.d.ts +4 -0
- package/dist/src/index.d.ts +4 -1
- package/dist/src/types.d.ts +3 -2
- package/package.json +3 -3
|
@@ -95,8 +95,8 @@ const ye = (n) => {
|
|
|
95
95
|
features: G
|
|
96
96
|
}),
|
|
97
97
|
children: [/* @__PURE__ */ s(ne, {
|
|
98
|
-
height: i == null ? void 0 : i.height,
|
|
99
|
-
width: i == null ? void 0 : i.width,
|
|
98
|
+
height: (i == null ? void 0 : i.height) || "100%",
|
|
99
|
+
width: (i == null ? void 0 : i.width) || "100%",
|
|
100
100
|
maxConstraints: [document.body.clientWidth - 45],
|
|
101
101
|
minConstraints: [Number(t == null ? void 0 : t.minWidth)],
|
|
102
102
|
onResize: Y,
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
var me = Object.defineProperty, ue = Object.defineProperties;
|
|
2
|
+
var ge = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var j = Object.getOwnPropertySymbols;
|
|
4
|
+
var fe = Object.prototype.hasOwnProperty, he = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var z = (r, l, s) => l in r ? me(r, l, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[l] = s, L = (r, l) => {
|
|
6
|
+
for (var s in l || (l = {}))
|
|
7
|
+
fe.call(l, s) && z(r, s, l[s]);
|
|
8
|
+
if (j)
|
|
9
|
+
for (var s of j(l))
|
|
10
|
+
he.call(l, s) && z(r, s, l[s]);
|
|
11
|
+
return r;
|
|
12
|
+
}, E = (r, l) => ue(r, ge(l));
|
|
13
|
+
var R = (r, l, s) => new Promise((C, N) => {
|
|
14
|
+
var x = (u) => {
|
|
15
|
+
try {
|
|
16
|
+
h(s.next(u));
|
|
17
|
+
} catch (I) {
|
|
18
|
+
N(I);
|
|
19
|
+
}
|
|
20
|
+
}, w = (u) => {
|
|
21
|
+
try {
|
|
22
|
+
h(s.throw(u));
|
|
23
|
+
} catch (I) {
|
|
24
|
+
N(I);
|
|
25
|
+
}
|
|
26
|
+
}, h = (u) => u.done ? C(u.value) : Promise.resolve(u.value).then(x, w);
|
|
27
|
+
h((s = s.apply(r, l)).next());
|
|
28
|
+
});
|
|
29
|
+
import { jsxs as v, jsx as o, Fragment as ye } from "react/jsx-runtime";
|
|
30
|
+
import { useState as m, useRef as Ie, useContext as ke, useEffect as b } from "react";
|
|
31
|
+
import { Form as q, Space as ve, Button as K, Input as J, message as F, notification as xe } from "antd";
|
|
32
|
+
import { v4 as Ce } from "uuid";
|
|
33
|
+
import Se from "../../../context.mjs";
|
|
34
|
+
import U from "../../../components/Iconfont/index.mjs";
|
|
35
|
+
import be 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 we from "../../../node_modules/moment/dist/moment.mjs";
|
|
39
|
+
/* empty css */import { fetchEventSource as pe } from "../fetchEventSource/fetch.mjs";
|
|
40
|
+
import { Markdown as Me } from "../../../packages/react-components/dist/es/components/Markdown/index.mjs";
|
|
41
|
+
const Ee = ({
|
|
42
|
+
application: r,
|
|
43
|
+
sessionId: l
|
|
44
|
+
}) => {
|
|
45
|
+
const s = r.id, [C, N] = m(""), [x, w] = m(""), [h, u] = m(), [I, S] = m(!1), B = Ie(null), [D, W] = m([]), [p, H] = m([]), [G, O] = m(0), [Q, Y] = m(), [c, M] = m(), [$] = q.useForm(), [T, X] = m(!1), [A, Z] = m({}), [_, ee] = m(0), {
|
|
46
|
+
service: y,
|
|
47
|
+
agentClient: k,
|
|
48
|
+
beforeMessageSend: Te,
|
|
49
|
+
popupContainer: P,
|
|
50
|
+
icon: Ae,
|
|
51
|
+
token: ne,
|
|
52
|
+
apiUrl: te
|
|
53
|
+
} = ke(Se), se = (n, a, i, e) => {
|
|
54
|
+
const t = {
|
|
55
|
+
messageId: Ce(),
|
|
56
|
+
content: "",
|
|
57
|
+
role: 1,
|
|
58
|
+
sessionId: "",
|
|
59
|
+
reference: [],
|
|
60
|
+
messageTime: "",
|
|
61
|
+
llmModel: "",
|
|
62
|
+
searchReference: []
|
|
63
|
+
}, g = E(L({}, i), {
|
|
64
|
+
stream: !0
|
|
65
|
+
});
|
|
66
|
+
pe(`${te}/chat/v2/chat?applicationId=${n}&sessionId=${a}`, {
|
|
67
|
+
method: "POST",
|
|
68
|
+
headers: {
|
|
69
|
+
Authorization: `Bearer ${ne}`,
|
|
70
|
+
"Content-Type": "application/json"
|
|
71
|
+
},
|
|
72
|
+
body: JSON.stringify(g),
|
|
73
|
+
openWhenHidden: !0,
|
|
74
|
+
onopen(d) {
|
|
75
|
+
return console.log("onopen"), d.ok && e != null && e.onopen && e.onopen(), Promise.resolve();
|
|
76
|
+
},
|
|
77
|
+
onmessage(d) {
|
|
78
|
+
if (!d.id && !d.data && !d.event && !d.retry)
|
|
79
|
+
return;
|
|
80
|
+
if (!d.data.includes('{"code": ')) {
|
|
81
|
+
t.content = t.content + d.data;
|
|
82
|
+
const V = {
|
|
83
|
+
content: t.content,
|
|
84
|
+
role: 1,
|
|
85
|
+
reference: t.reference,
|
|
86
|
+
messageId: t.messageId,
|
|
87
|
+
sessionId: a,
|
|
88
|
+
messageTime: we(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:mm:ss"),
|
|
89
|
+
searchReference: []
|
|
90
|
+
};
|
|
91
|
+
return (e == null ? void 0 : e.onmessage) && e.onmessage(V);
|
|
92
|
+
}
|
|
93
|
+
const f = JSON.parse(d.data);
|
|
94
|
+
if (t.reference = f.data.reference, t.messageTime = f.data.messageTime, t.messageId = f.data.messageId, t.llmModel = f.data.llmModel, t.content = f.data.content, t.code = f.code, f.code === 200) {
|
|
95
|
+
const V = {
|
|
96
|
+
code: t.code,
|
|
97
|
+
content: t.content,
|
|
98
|
+
role: 1,
|
|
99
|
+
reference: t.reference,
|
|
100
|
+
messageId: t.messageId,
|
|
101
|
+
sessionId: a,
|
|
102
|
+
messageTime: t.messageTime,
|
|
103
|
+
searchReference: []
|
|
104
|
+
};
|
|
105
|
+
e != null && e.onmessage && e.onmessage(V);
|
|
106
|
+
} else
|
|
107
|
+
return xe.error({
|
|
108
|
+
message: f.message
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
onerror() {
|
|
112
|
+
e != null && e.onerror && e.onerror();
|
|
113
|
+
},
|
|
114
|
+
onclose() {
|
|
115
|
+
console.log("onclose");
|
|
116
|
+
const d = {
|
|
117
|
+
code: t.code,
|
|
118
|
+
content: t.content,
|
|
119
|
+
role: 1,
|
|
120
|
+
reference: t.reference,
|
|
121
|
+
messageId: t.messageId,
|
|
122
|
+
sessionId: a,
|
|
123
|
+
messageTime: t.messageTime,
|
|
124
|
+
comment: {
|
|
125
|
+
isAgree: 0
|
|
126
|
+
},
|
|
127
|
+
searchReference: []
|
|
128
|
+
};
|
|
129
|
+
e != null && e.onclose && e.onclose(d);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
b(() => {
|
|
134
|
+
if (!(r != null && r.id))
|
|
135
|
+
return;
|
|
136
|
+
const n = r.arrange;
|
|
137
|
+
if (!(n != null && n.length))
|
|
138
|
+
return;
|
|
139
|
+
const i = n[0].knowledges || [];
|
|
140
|
+
W(i), O(i.length);
|
|
141
|
+
const e = i.map((t) => t.id);
|
|
142
|
+
H(e);
|
|
143
|
+
}, [r]), b(() => {
|
|
144
|
+
if (!(r != null && r.id) || !k)
|
|
145
|
+
return;
|
|
146
|
+
const n = k.questionContextMaxLength || 4e3;
|
|
147
|
+
ee(n), re();
|
|
148
|
+
}, [r, k]);
|
|
149
|
+
const re = () => R(void 0, null, function* () {
|
|
150
|
+
if (!y || !s)
|
|
151
|
+
return;
|
|
152
|
+
const n = yield y.postApplicationIdSession({
|
|
153
|
+
name: "AI 会话",
|
|
154
|
+
applicationId: s
|
|
155
|
+
});
|
|
156
|
+
debugger;
|
|
157
|
+
Y(n);
|
|
158
|
+
});
|
|
159
|
+
b(() => {
|
|
160
|
+
s && (y == null || y.getApplicationIdPromptVariables(s, {
|
|
161
|
+
status: 1
|
|
162
|
+
}).then((n) => {
|
|
163
|
+
const i = n.filter((e) => e.key !== "query").map((e) => ({
|
|
164
|
+
id: e.id,
|
|
165
|
+
key: e.key,
|
|
166
|
+
name: e.name,
|
|
167
|
+
value: ""
|
|
168
|
+
}));
|
|
169
|
+
M(i);
|
|
170
|
+
}));
|
|
171
|
+
}, [y]), b(() => {
|
|
172
|
+
if (!c)
|
|
173
|
+
return;
|
|
174
|
+
const n = {};
|
|
175
|
+
c == null || c.map((a) => {
|
|
176
|
+
a.key && (n[a.key] = a.value);
|
|
177
|
+
}), $.setFieldsValue(L({}, n)), Z(n);
|
|
178
|
+
}, [c]);
|
|
179
|
+
const oe = (n, a) => {
|
|
180
|
+
}, ae = (n) => {
|
|
181
|
+
N(n.target.value);
|
|
182
|
+
}, ce = () => R(void 0, null, function* () {
|
|
183
|
+
if (S(!0), !s || !y || !k)
|
|
184
|
+
return;
|
|
185
|
+
for (const e in A)
|
|
186
|
+
A[e] || (S(!1), F.config({
|
|
187
|
+
getContainer: () => (P == null ? void 0 : P.current) || document.body
|
|
188
|
+
}), F.error("变量值不能为空"), F.config({
|
|
189
|
+
getContainer: void 0
|
|
190
|
+
}));
|
|
191
|
+
const n = yield y.postApplicationIdSession({
|
|
192
|
+
name: "AI 会话",
|
|
193
|
+
applicationId: s
|
|
194
|
+
});
|
|
195
|
+
debugger;
|
|
196
|
+
Y(n);
|
|
197
|
+
const a = p == null ? void 0 : p.map((e) => e.toString()), i = {
|
|
198
|
+
content: C,
|
|
199
|
+
chatMode: 1,
|
|
200
|
+
knowledges: a,
|
|
201
|
+
promptVariables: A
|
|
202
|
+
};
|
|
203
|
+
se(s, n.id, i, {
|
|
204
|
+
onmessage: (e) => {
|
|
205
|
+
S(!0), u(void 0), w(e.content);
|
|
206
|
+
},
|
|
207
|
+
onclose: (e) => {
|
|
208
|
+
S(!1), e.code == 200 && (w(e.content), u(e));
|
|
209
|
+
},
|
|
210
|
+
onerror: () => {
|
|
211
|
+
S(!1);
|
|
212
|
+
}
|
|
213
|
+
}), c && y.getApplicationIdSessionIdPromptVariables(s, n.id).then((e) => {
|
|
214
|
+
const t = e.filter((g) => g.key !== "query").map((g) => {
|
|
215
|
+
const d = c.filter((f) => f.key === g.key);
|
|
216
|
+
return g.value = d[0].value, g;
|
|
217
|
+
});
|
|
218
|
+
Promise.all(t.map((g) => {
|
|
219
|
+
oe(g.id, g.value);
|
|
220
|
+
})), M(t);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
b(() => {
|
|
224
|
+
if (!x)
|
|
225
|
+
return;
|
|
226
|
+
const n = B.current;
|
|
227
|
+
n && (n.scrollTop = n.scrollHeight);
|
|
228
|
+
}, [x]);
|
|
229
|
+
const le = (n) => {
|
|
230
|
+
H(n), O(n.length);
|
|
231
|
+
}, de = (n, a) => {
|
|
232
|
+
c && (c.map((i) => {
|
|
233
|
+
i.id === n && (i.value = a.target.value);
|
|
234
|
+
}), M([...c]));
|
|
235
|
+
}, ie = () => {
|
|
236
|
+
X(!T);
|
|
237
|
+
};
|
|
238
|
+
return /* @__PURE__ */ v("div", {
|
|
239
|
+
className: "text-main",
|
|
240
|
+
children: [/* @__PURE__ */ v("div", {
|
|
241
|
+
className: "text-left-sider",
|
|
242
|
+
children: [/* @__PURE__ */ v("div", {
|
|
243
|
+
className: "text-prompts",
|
|
244
|
+
children: [/* @__PURE__ */ o("div", {
|
|
245
|
+
className: "prompts-header",
|
|
246
|
+
children: /* @__PURE__ */ v(ve, {
|
|
247
|
+
children: [/* @__PURE__ */ o(K, {
|
|
248
|
+
className: "prompts-btn",
|
|
249
|
+
icon: T ? /* @__PURE__ */ o(U, {
|
|
250
|
+
type: "icon-biaoge-shouqi"
|
|
251
|
+
}) : /* @__PURE__ */ o(U, {
|
|
252
|
+
type: "icon-biaoge-zhankai"
|
|
253
|
+
}),
|
|
254
|
+
type: "link",
|
|
255
|
+
onClick: () => ie()
|
|
256
|
+
}), /* @__PURE__ */ o("span", {
|
|
257
|
+
className: "prompts-title",
|
|
258
|
+
children: "文本生成设置"
|
|
259
|
+
})]
|
|
260
|
+
})
|
|
261
|
+
}), !T && (c != null && c.length ? /* @__PURE__ */ o(q, {
|
|
262
|
+
autoComplete: "off",
|
|
263
|
+
form: $,
|
|
264
|
+
labelWrap: !0,
|
|
265
|
+
labelAlign: "left",
|
|
266
|
+
labelCol: {
|
|
267
|
+
style: {
|
|
268
|
+
width: 194
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
className: "prompts-form",
|
|
272
|
+
children: c == null ? void 0 : c.map((n) => /* @__PURE__ */ o(q.Item, {
|
|
273
|
+
label: n.name,
|
|
274
|
+
name: n.key,
|
|
275
|
+
style: {
|
|
276
|
+
marginBottom: 8
|
|
277
|
+
},
|
|
278
|
+
rules: [{
|
|
279
|
+
required: !0,
|
|
280
|
+
message: "请输入"
|
|
281
|
+
}],
|
|
282
|
+
children: /* @__PURE__ */ o(J, {
|
|
283
|
+
placeholder: "请输入",
|
|
284
|
+
maxLength: k == null ? void 0 : k.questionContextMaxLength,
|
|
285
|
+
onBlur: (a) => de(n.id, a)
|
|
286
|
+
})
|
|
287
|
+
}, n.key))
|
|
288
|
+
}) : null)]
|
|
289
|
+
}), /* @__PURE__ */ v("div", {
|
|
290
|
+
className: "sider-header",
|
|
291
|
+
children: [/* @__PURE__ */ o("span", {
|
|
292
|
+
className: "header-title",
|
|
293
|
+
children: "文本生成输入"
|
|
294
|
+
}), D.length !== 0 && /* @__PURE__ */ o(be, {
|
|
295
|
+
checkedValues: p,
|
|
296
|
+
currKnowledgeList: D,
|
|
297
|
+
selectCount: G,
|
|
298
|
+
onSelectChange: le,
|
|
299
|
+
disabled: !1
|
|
300
|
+
})]
|
|
301
|
+
}), /* @__PURE__ */ o("div", {
|
|
302
|
+
className: "sider-main",
|
|
303
|
+
children: /* @__PURE__ */ v("div", {
|
|
304
|
+
className: "sider-text",
|
|
305
|
+
children: [/* @__PURE__ */ o(J.TextArea, {
|
|
306
|
+
style: {
|
|
307
|
+
height: "100%",
|
|
308
|
+
resize: "none"
|
|
309
|
+
},
|
|
310
|
+
placeholder: "请输入你的问题,通过shift+enter换行",
|
|
311
|
+
maxLength: _,
|
|
312
|
+
showCount: !0,
|
|
313
|
+
bordered: !1,
|
|
314
|
+
onChange: ae,
|
|
315
|
+
value: C,
|
|
316
|
+
className: "left-input"
|
|
317
|
+
}), /* @__PURE__ */ o(K, {
|
|
318
|
+
type: "primary",
|
|
319
|
+
disabled: !C || I,
|
|
320
|
+
onClick: ce,
|
|
321
|
+
className: "sider-btn",
|
|
322
|
+
loading: I,
|
|
323
|
+
children: I ? "生成中" : "确认生成"
|
|
324
|
+
})]
|
|
325
|
+
})
|
|
326
|
+
})]
|
|
327
|
+
}), /* @__PURE__ */ o("div", {
|
|
328
|
+
className: "text-right-sider",
|
|
329
|
+
children: /* @__PURE__ */ o("div", {
|
|
330
|
+
className: "sider-main",
|
|
331
|
+
children: /* @__PURE__ */ o("div", {
|
|
332
|
+
className: "sider-text",
|
|
333
|
+
ref: B,
|
|
334
|
+
children: x ? /* @__PURE__ */ v(ye, {
|
|
335
|
+
children: [/* @__PURE__ */ o(Me, {
|
|
336
|
+
children: x
|
|
337
|
+
}), h && (h == null ? void 0 : h.reference.length) !== 0 && /* @__PURE__ */ o(Ne, {
|
|
338
|
+
history: h,
|
|
339
|
+
docViewerUrl: ""
|
|
340
|
+
})]
|
|
341
|
+
}) : /* @__PURE__ */ o("div", {
|
|
342
|
+
className: "text-pannel",
|
|
343
|
+
children: /* @__PURE__ */ o("span", {
|
|
344
|
+
children: "请在左侧输入需要 AI 生成的内容"
|
|
345
|
+
})
|
|
346
|
+
})
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
})]
|
|
350
|
+
});
|
|
351
|
+
};
|
|
352
|
+
export {
|
|
353
|
+
Ee as default
|
|
354
|
+
};
|
|
@@ -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,79 @@
|
|
|
1
|
+
var A = Object.defineProperty, L = Object.defineProperties;
|
|
2
|
+
var M = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var i = Object.getOwnPropertySymbols;
|
|
4
|
+
var P = Object.prototype.hasOwnProperty, U = 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
|
+
U.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 j, useState as l, useEffect as z } from "react";
|
|
15
|
+
/* empty css */import { ConfigProvider as f } 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 W } from "../context.mjs";
|
|
20
|
+
const Y = (o) => {
|
|
21
|
+
const {
|
|
22
|
+
application: e,
|
|
23
|
+
theme: t,
|
|
24
|
+
token: r,
|
|
25
|
+
footer: m,
|
|
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
|
+
} = o, R = j(null), [T, q] = l(!1), [w, k] = l();
|
|
39
|
+
return z(() => {
|
|
40
|
+
if (!r)
|
|
41
|
+
return;
|
|
42
|
+
const y = J(r);
|
|
43
|
+
k(y.rid);
|
|
44
|
+
}, [r]), f.config({
|
|
45
|
+
theme: t
|
|
46
|
+
}), /* @__PURE__ */ n(f, {
|
|
47
|
+
locale: B,
|
|
48
|
+
children: /* @__PURE__ */ n(W, {
|
|
49
|
+
value: d(a({}, o), {
|
|
50
|
+
popupContainer: R,
|
|
51
|
+
agentClient: N,
|
|
52
|
+
footer: m,
|
|
53
|
+
defaultInput: c,
|
|
54
|
+
onComment: p,
|
|
55
|
+
onSessionLoad: u,
|
|
56
|
+
onSessionUnload: g,
|
|
57
|
+
onMessage: h,
|
|
58
|
+
beforeMessageSend: C,
|
|
59
|
+
bodyStyle: S,
|
|
60
|
+
disabled: x,
|
|
61
|
+
transform: I,
|
|
62
|
+
features: b
|
|
63
|
+
}),
|
|
64
|
+
children: !T && /* @__PURE__ */ n("div", {
|
|
65
|
+
className: "chat-text",
|
|
66
|
+
children: /* @__PURE__ */ n("div", {
|
|
67
|
+
className: "text-pannel",
|
|
68
|
+
children: /* @__PURE__ */ n(E, {
|
|
69
|
+
application: e,
|
|
70
|
+
sessionId: v
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
Y as default
|
|
79
|
+
};
|