@szjy/ai-coms 0.1.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/dist/index.mjs ADDED
@@ -0,0 +1,1145 @@
1
+ import { defineComponent as ne, computed as N, createElementBlock as R, openBlock as P, mergeProps as ie, createElementVNode as S, getCurrentInstance as re, ref as C, watch as ce, onUnmounted as ue, createBlock as Q, Transition as oe, withCtx as q, createCommentVNode as H, createVNode as E, nextTick as ae, resolveComponent as Z, normalizeClass as K, toDisplayString as F, createTextVNode as de, Fragment as G, renderList as X, unref as fe, withKeys as pe, withModifiers as me } from "vue";
2
+ const ve = "/images/ai-round.png", he = "/images/ai-sqrt.png", ye = "/images/bars-loading.svg";
3
+ function ge(e, n = location.href) {
4
+ return new URLSearchParams(new URL(n).search).get(e);
5
+ }
6
+ function we(e) {
7
+ return e.startsWith("http://") || e.startsWith("https://") ? e : `${location.protocol}//${location.host}${e}`;
8
+ }
9
+ async function be(e) {
10
+ const n = new URL("http://localhost:11434/api/chat"), r = {};
11
+ Object.keys(r).forEach((s) => {
12
+ n.searchParams.append(s, r[s]);
13
+ });
14
+ const i = new Request(n, {
15
+ mode: "cors",
16
+ method: "post",
17
+ headers: {
18
+ "Content-Type": "application/json"
19
+ },
20
+ body: JSON.stringify({
21
+ model: "llama3",
22
+ stream: !0,
23
+ messages: [
24
+ {
25
+ role: "system",
26
+ content: "全程使用中文回答问题。"
27
+ },
28
+ {
29
+ role: "user",
30
+ content: e
31
+ }
32
+ ]
33
+ })
34
+ });
35
+ return fetch(i);
36
+ }
37
+ async function _e(e, n) {
38
+ const r = new URL(`${location.origin}/spark/v1/chat/completions`), i = {};
39
+ Object.keys(i).forEach((t) => {
40
+ r.searchParams.append(t, i[t]);
41
+ });
42
+ const s = new Request(r, {
43
+ method: "post",
44
+ headers: {
45
+ "Content-Type": "application/json",
46
+ Authorization: `Bearer ${n}`
47
+ },
48
+ body: JSON.stringify({
49
+ model: "generalv4.0Ultra",
50
+ stream: !0,
51
+ messages: [
52
+ {
53
+ role: "user",
54
+ content: e
55
+ }
56
+ ]
57
+ })
58
+ });
59
+ return fetch(s);
60
+ }
61
+ async function Se(e, n) {
62
+ const r = new URL(`${location.origin}/siliconflow/v1/chat/completions`), i = {};
63
+ Object.keys(i).forEach((t) => {
64
+ r.searchParams.append(t, i[t]);
65
+ });
66
+ const s = new Request(r, {
67
+ method: "post",
68
+ headers: {
69
+ "Content-Type": "application/json",
70
+ Authorization: `Bearer ${n}`
71
+ },
72
+ body: JSON.stringify({
73
+ // 集成了大部分模型,可以免费使用
74
+ model: "Qwen/Qwen1.5-110B-Chat",
75
+ stream: !0,
76
+ messages: [
77
+ {
78
+ role: "user",
79
+ content: e
80
+ }
81
+ ]
82
+ })
83
+ });
84
+ return fetch(s);
85
+ }
86
+ async function xe(e, n) {
87
+ const r = new URL(`${location.origin}/moonshot/v1/chat/completions`), i = {};
88
+ Object.keys(i).forEach((t) => {
89
+ r.searchParams.append(t, i[t]);
90
+ });
91
+ const s = new Request(r, {
92
+ method: "post",
93
+ headers: {
94
+ "Content-Type": "application/json",
95
+ Authorization: `Bearer ${n}`
96
+ },
97
+ body: JSON.stringify({
98
+ model: "moonshot-v1-8k",
99
+ stream: !0,
100
+ messages: [
101
+ {
102
+ role: "system",
103
+ content: "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。"
104
+ },
105
+ {
106
+ role: "user",
107
+ content: e
108
+ }
109
+ ]
110
+ })
111
+ });
112
+ return fetch(s);
113
+ }
114
+ async function ke(e, n) {
115
+ const r = new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`), i = {};
116
+ Object.keys(i).forEach((t) => {
117
+ r.searchParams.append(t, i[t]);
118
+ });
119
+ const s = new Request(r, {
120
+ method: "post",
121
+ headers: {
122
+ "Content-Type": "application/json",
123
+ Authorization: `Bearer ${n}`
124
+ },
125
+ body: JSON.stringify({
126
+ model: "qwq-32b-preview",
127
+ stream: !0,
128
+ messages: [
129
+ {
130
+ role: "system",
131
+ content: "全程使用中文回答问题"
132
+ },
133
+ {
134
+ role: "user",
135
+ content: e
136
+ }
137
+ ]
138
+ })
139
+ });
140
+ return fetch(s);
141
+ }
142
+ async function Ce(e, n, r, i = "") {
143
+ console.log(12342, n, r);
144
+ const s = we(i), t = new URL(`${s}/support/${r}/a`), d = {};
145
+ Object.keys(d).forEach((v) => {
146
+ t.searchParams.append(v, d[v]);
147
+ });
148
+ const _ = new Request(t, {
149
+ method: "post",
150
+ headers: {
151
+ "Content-Type": "application/json",
152
+ Authorization: `Bearer ${n}`
153
+ },
154
+ body: JSON.stringify({
155
+ content: e
156
+ })
157
+ });
158
+ return fetch(_);
159
+ }
160
+ const Te = (e) => {
161
+ if (e.startsWith("data:")) {
162
+ const n = e.substring(5).trim();
163
+ if (n === "[DONE]")
164
+ return {
165
+ done: !0
166
+ };
167
+ try {
168
+ return JSON.parse(n);
169
+ } catch (r) {
170
+ console.error("JSON parsing error:", r);
171
+ }
172
+ }
173
+ return null;
174
+ }, Le = [
175
+ {
176
+ label: "模拟数据模型",
177
+ modelName: "standard",
178
+ api: null
179
+ },
180
+ {
181
+ label: "Spark 星火大模型",
182
+ modelName: "spark",
183
+ api: _e
184
+ },
185
+ {
186
+ label: "Ollama 3 大模型",
187
+ modelName: "ollama3",
188
+ api: be
189
+ },
190
+ {
191
+ label: "SiliconFlow 硅基流动大模型",
192
+ modelName: "siliconflow",
193
+ api: Se
194
+ },
195
+ {
196
+ label: "Kimi Moonshot 月之暗面大模型",
197
+ modelName: "moonshot",
198
+ api: xe
199
+ },
200
+ {
201
+ label: "通义千问大模型",
202
+ modelName: "dashscope",
203
+ api: ke
204
+ },
205
+ {
206
+ label: "数智建管大模型",
207
+ modelName: "szjy",
208
+ api: Ce
209
+ }
210
+ ], Y = {
211
+ standard(e, n) {
212
+ let r = "";
213
+ return e instanceof Uint8Array ? r = n.decode(e, {
214
+ stream: !0
215
+ }) : r = e, {
216
+ content: r
217
+ };
218
+ },
219
+ spark(e) {
220
+ const n = Te(e);
221
+ return n.done ? {
222
+ done: !0
223
+ } : {
224
+ content: n.choices[0].delta.content || ""
225
+ };
226
+ },
227
+ siliconflow(e) {
228
+ return this.spark(e);
229
+ },
230
+ moonshot(e) {
231
+ return this.spark(e);
232
+ },
233
+ dashscope(e) {
234
+ return this.spark(e);
235
+ },
236
+ szjy(e) {
237
+ return this.spark(e);
238
+ },
239
+ ollama3(e) {
240
+ return {
241
+ content: JSON.parse(e).message.content
242
+ };
243
+ }
244
+ }, ee = (e, n, r) => {
245
+ const i = e.split(r);
246
+ return i.slice(0, -1).forEach((s) => {
247
+ s.trim() !== "" && n.enqueue(s);
248
+ }), i[i.length - 1];
249
+ }, Pe = (e) => {
250
+ let n = "";
251
+ return new TransformStream({
252
+ transform(r, i) {
253
+ if (n += r, n.trim().startsWith("data:"))
254
+ n = ee(n, i, e);
255
+ else
256
+ try {
257
+ JSON.parse(n), n = ee(n, i, e);
258
+ } catch {
259
+ i.enqueue(r), n = "";
260
+ }
261
+ },
262
+ flush(r) {
263
+ n.trim() !== "" && r.enqueue(n);
264
+ }
265
+ });
266
+ };
267
+ async function Oe(e, n) {
268
+ const r = e.api;
269
+ return r ? new Promise((i) => {
270
+ r(n.text, n.token, n.identifier, n.baseUrl).then((s) => {
271
+ if (s.body) {
272
+ const t = s.body.pipeThrough(new TextDecoderStream()).pipeThrough(Pe(`
273
+ `)).getReader();
274
+ console.log("reader from response:", t), i({
275
+ error: 0,
276
+ reader: t
277
+ });
278
+ } else
279
+ i({
280
+ error: 1,
281
+ reader: null
282
+ });
283
+ }).catch((s) => {
284
+ i({
285
+ error: 1,
286
+ reader: null
287
+ });
288
+ });
289
+ }) : {
290
+ error: 1,
291
+ reader: null
292
+ };
293
+ }
294
+ let V = null;
295
+ function ze() {
296
+ return V || (window.markdownit ? V = new window.markdownit({
297
+ html: !0,
298
+ linkify: !0,
299
+ typographer: !0
300
+ }) : console.log("markdownit is not loaded"), V);
301
+ }
302
+ const J = (e, n) => {
303
+ const r = e.__vccOpts || e;
304
+ for (const [i, s] of n)
305
+ r[i] = s;
306
+ return r;
307
+ }, Re = ne({
308
+ name: "SvgIcon",
309
+ props: {
310
+ prefix: {
311
+ type: String,
312
+ default: "icon"
313
+ },
314
+ name: {
315
+ type: String,
316
+ required: !0
317
+ },
318
+ color: {
319
+ type: String,
320
+ default: "#333"
321
+ }
322
+ },
323
+ setup(e) {
324
+ const n = N(() => `#${e.prefix}-${e.name}`), r = N(() => e.name ? `svg-icon icon-${e.name}` : "svg-icon");
325
+ return { symbolId: n, svgClass: r };
326
+ }
327
+ }), Me = ["xlink:href", "fill"];
328
+ function $e(e, n, r, i, s, t) {
329
+ return P(), R("svg", ie({
330
+ class: e.svgClass,
331
+ "aria-hidden": "true"
332
+ }, e.$attrs), [
333
+ S("use", {
334
+ "xlink:href": e.symbolId,
335
+ fill: e.color
336
+ }, null, 8, Me)
337
+ ], 16);
338
+ }
339
+ const D = /* @__PURE__ */ J(Re, [["render", $e], ["__scopeId", "data-v-349f049f"]]), Ie = async (e) => {
340
+ if (navigator.clipboard && navigator.permissions)
341
+ await navigator.clipboard.writeText(e);
342
+ else {
343
+ const n = document.createElement("textArea");
344
+ n.value = e, n.style.width = 0, n.style.position = "fixed", n.style.left = "-999px", n.style.top = "10px", n.setAttribute("readonly", "readonly"), document.body.appendChild(n), n.select(), document.execCommand("copy"), document.body.removeChild(n);
345
+ }
346
+ }, Ae = ["innerHTML"], je = {
347
+ __name: "Previewer",
348
+ props: {
349
+ reader: null,
350
+ model: "szjy",
351
+ scrollToBottomFn: null,
352
+ displayText: ""
353
+ },
354
+ emits: [
355
+ "failed",
356
+ "completed",
357
+ "updating"
358
+ ],
359
+ setup(e, { expose: n, emit: r }) {
360
+ const { appContext: i } = re(), { $message: s } = i.config.globalProperties, t = e, d = C(t.displayText || ""), _ = C(""), v = C(!0), g = C(!1), z = C(!!t.displayText), O = r, B = C(null);
361
+ let k = null;
362
+ const $ = N(() => V ? V.render(d.value) : d.value), I = () => {
363
+ t.reader && t.reader.cancel(), g.value = !0, a.value = !1, u(), z.value = !0, O("completed", d.value), v.value = !1, k && (cancelAnimationFrame(k), k = null);
364
+ }, U = N(() => `${$.value}`), f = C(!1), c = () => {
365
+ f.value = !0;
366
+ }, u = () => {
367
+ f.value = !1;
368
+ }, a = C(!1), o = async () => {
369
+ if (!t.reader) return;
370
+ const y = new TextDecoder("utf-8");
371
+ for (v.value = !0; !g.value; )
372
+ try {
373
+ if (!t.reader) {
374
+ a.value = !0;
375
+ break;
376
+ }
377
+ const { value: l, done: m } = await t.reader.read();
378
+ if (!t.reader) {
379
+ a.value = !0;
380
+ break;
381
+ }
382
+ if (m) {
383
+ a.value = !0;
384
+ break;
385
+ }
386
+ const w = Y[t.model];
387
+ if (!w)
388
+ break;
389
+ const T = w.call(Y, l, y);
390
+ if (T.done) {
391
+ a.value = !0;
392
+ break;
393
+ }
394
+ _.value += T.content, k === null && x();
395
+ } catch (l) {
396
+ a.value = !0, console.log(3333, l), O("failed", l), I();
397
+ break;
398
+ } finally {
399
+ u();
400
+ }
401
+ }, h = async () => {
402
+ t.scrollToBottomFn && t.scrollToBottomFn();
403
+ }, p = (y = () => {
404
+ }, l = () => {
405
+ }) => {
406
+ if (_.value.length > 0) {
407
+ const m = _.value.substring(0, 10);
408
+ d.value += m, _.value = _.value.substring(10), y();
409
+ } else
410
+ l();
411
+ }, x = () => {
412
+ if (g.value && k) {
413
+ cancelAnimationFrame(k), k = null, v.value = !1;
414
+ return;
415
+ }
416
+ a.value ? p(
417
+ () => {
418
+ k = requestAnimationFrame(x), O("updating", null);
419
+ },
420
+ () => {
421
+ O("completed", d.value), v.value = !1, z.value = !0, ae(() => {
422
+ a.value = !1;
423
+ }), k = null;
424
+ }
425
+ ) : (p(), k = requestAnimationFrame(x)), h();
426
+ };
427
+ ce(
428
+ () => t.reader,
429
+ () => {
430
+ t.reader && o();
431
+ },
432
+ {
433
+ immediate: !0,
434
+ deep: !0
435
+ }
436
+ ), ue(() => {
437
+ I();
438
+ }), n({
439
+ abortReader: I,
440
+ initializeStart: c,
441
+ initializeEnd: u
442
+ }), N(() => f.value ? !0 : (!t.reader || !v || d.value, !1));
443
+ const b = async () => {
444
+ try {
445
+ const y = d.value;
446
+ await Ie(y), s.success("复制成功");
447
+ } catch (y) {
448
+ console.error("复制失败:", y), s.error("复制失败");
449
+ }
450
+ };
451
+ return (y, l) => (P(), Q(oe, { name: "fade" }, {
452
+ default: q(() => [
453
+ U.value ? (P(), R("div", {
454
+ key: 0,
455
+ ref_key: "refWrapperContent",
456
+ ref: B,
457
+ "text-16": "",
458
+ class: "w-full h-full overflow-y-auto relative",
459
+ "p-24px": ""
460
+ }, [
461
+ S("div", {
462
+ class: "markdown-wrapper",
463
+ innerHTML: U.value
464
+ }, null, 8, Ae),
465
+ z.value ? (P(), R("div", {
466
+ key: 0,
467
+ class: "copy-btn-wrapper",
468
+ onClick: b
469
+ }, [
470
+ E(D, {
471
+ name: "copy",
472
+ color: "#666666"
473
+ }),
474
+ l[0] || (l[0] = S("span", { class: "copy-text" }, "复制", -1))
475
+ ])) : H("", !0)
476
+ ], 512)) : H("", !0)
477
+ ]),
478
+ _: 1
479
+ }));
480
+ }
481
+ }, Ee = /* @__PURE__ */ J(je, [["__scopeId", "data-v-c3f65f53"]]), Ue = { class: "panel-header" }, Ne = { class: "header-actions" }, Be = { class: "header-title" }, qe = { class: "action-icons" }, Ve = { class: "body-content" }, He = {
482
+ key: 0,
483
+ class: "welcome-content"
484
+ }, Fe = { class: "subtitle" }, De = { class: "highlight" }, Je = { class: "quick-questions" }, Qe = ["onClick"], We = {
485
+ key: 1,
486
+ class: "message-content user-content"
487
+ }, Ze = { class: "panel-footer" }, Ke = {
488
+ key: 0,
489
+ src: ye,
490
+ alt: "加载中",
491
+ class: "loading-icon"
492
+ }, Ge = { class: "input-box" }, Xe = ["src"], Ye = {
493
+ __name: "ChatPanel",
494
+ props: {
495
+ modelValue: {
496
+ type: Boolean,
497
+ default: !1
498
+ },
499
+ token: {
500
+ type: String,
501
+ default: ""
502
+ },
503
+ identifier: {
504
+ type: String,
505
+ default: ""
506
+ },
507
+ baseUrl: {
508
+ type: String,
509
+ default: ""
510
+ },
511
+ title: {
512
+ type: String,
513
+ default: "数智AI助理"
514
+ }
515
+ },
516
+ emits: ["update:modelValue", "submit"],
517
+ setup(e, { emit: n }) {
518
+ const { appContext: r } = re(), { $message: i } = r.config.globalProperties, s = ge("llmName") || "szjy", t = N(() => Le.find((m) => m.modelName === s)), d = e, _ = n, v = C(""), g = C(null), z = C(!1), O = C([]), B = C([
519
+ "什么是AI助理,能做什么?",
520
+ "当前项目的基本情况?",
521
+ "当前项目的进度情况?",
522
+ "当前项目的参建方有哪些?",
523
+ "数智建管平台有哪些功能?能做什么?"
524
+ ]), k = C([]), $ = C(!1), I = C(null), U = () => {
525
+ ae(() => {
526
+ if (I.value) {
527
+ const m = I.value, w = m.scrollHeight, T = m.scrollTop, A = m.clientHeight;
528
+ w - T - A < 100 ? m.scrollTop = w : m.scrollTo({
529
+ top: w
530
+ });
531
+ }
532
+ });
533
+ }, f = C(!1), c = N(() => f.value ? "/images/ai-stop.png" : "/images/ai-send.png"), u = (m, w) => {
534
+ console.log("onFailedReader", m, w), $.value = !1;
535
+ const T = y();
536
+ T && T.initializeEnd(), i.error("转换失败,请重试"), f.value = !1, setTimeout(() => {
537
+ g.value && g.value.focus();
538
+ });
539
+ }, a = (m, w) => {
540
+ $.value = !1, f.value = !1, U(), w && O.value[m] && (O.value[m].displayText = w), setTimeout(() => {
541
+ g.value && g.value.focus();
542
+ });
543
+ }, o = (m) => {
544
+ f.value = !0;
545
+ }, h = () => {
546
+ f.value = !1, _("update:modelValue", !1), z.value = !1, O.value = [];
547
+ }, p = C(!1), x = () => {
548
+ p.value = !p.value;
549
+ }, b = (m) => {
550
+ v.value = m, l();
551
+ }, y = () => {
552
+ for (let m = k.value.length - 1; m >= 0; m--)
553
+ if (k.value[m])
554
+ return k.value[m];
555
+ return null;
556
+ }, l = async () => {
557
+ if (console.log("stylizingLoading:", $.value), $.value) {
558
+ const L = y();
559
+ console.log("lastPreviewer:", L), L && (console.log("abortReader"), L.abortReader());
560
+ return;
561
+ }
562
+ if (!v.value.trim()) {
563
+ console.log("no input, return"), g.value.focus();
564
+ return;
565
+ }
566
+ O.value.push({
567
+ type: "user",
568
+ content: v.value
569
+ }), f.value = !0, z.value = !0, _("submit", v.value), U();
570
+ const m = v.value;
571
+ v.value = "";
572
+ const w = O.value.length;
573
+ k.value[w] && k.value[w].initializeStart(), $.value = !0, O.value.push({
574
+ type: "ai"
575
+ });
576
+ const { error: T, reader: A } = await Oe(t.value, {
577
+ text: m,
578
+ token: d.token,
579
+ identifier: d.identifier,
580
+ baseUrl: d.baseUrl
581
+ });
582
+ if (T) {
583
+ console.log(45455, T), u(w, T);
584
+ return;
585
+ }
586
+ A && (O.value[w].reader = A);
587
+ };
588
+ return (m, w) => {
589
+ const T = Z("el-icon"), A = Z("el-input");
590
+ return P(), Q(oe, { name: "slide" }, {
591
+ default: q(() => [
592
+ e.modelValue ? (P(), R("div", {
593
+ key: 0,
594
+ class: K(["ai-panel", { "drawer-mode": p.value }])
595
+ }, [
596
+ S("div", Ue, [
597
+ S("div", Ne, [
598
+ S("div", Be, F(e.title), 1),
599
+ S("div", qe, [
600
+ E(T, {
601
+ class: "action-icon",
602
+ onClick: x
603
+ }, {
604
+ default: q(() => [
605
+ E(D, {
606
+ name: "drawer-layout",
607
+ color: "#999999"
608
+ })
609
+ ]),
610
+ _: 1
611
+ }),
612
+ E(T, {
613
+ class: "action-icon",
614
+ onClick: h
615
+ }, {
616
+ default: q(() => [
617
+ E(D, {
618
+ name: "close",
619
+ color: "#999999"
620
+ })
621
+ ]),
622
+ _: 1
623
+ })
624
+ ])
625
+ ])
626
+ ]),
627
+ S("div", Ve, [
628
+ z.value ? (P(), R("div", {
629
+ key: 1,
630
+ class: "chat-messages",
631
+ ref_key: "messageContainerRef",
632
+ ref: I
633
+ }, [
634
+ (P(!0), R(G, null, X(O.value, (L, j) => (P(), R("div", {
635
+ key: j,
636
+ class: K(["message-item", L.type === "user" ? "user-message" : "ai-message"])
637
+ }, [
638
+ L.type === "ai" ? (P(), Q(Ee, {
639
+ key: 0,
640
+ ref_for: !0,
641
+ ref: (M) => k.value[j] = M,
642
+ reader: L.reader,
643
+ "onUpdate:reader": (M) => L.reader = M,
644
+ model: fe(s),
645
+ displayText: L.displayText,
646
+ scrollToBottomFn: U,
647
+ onFailed: (M) => u(j, M),
648
+ onCompleted: (M) => a(j, M),
649
+ onUpdating: () => o()
650
+ }, null, 8, ["reader", "onUpdate:reader", "model", "displayText", "onFailed", "onCompleted", "onUpdating"])) : (P(), R("div", We, F(L.content), 1))
651
+ ], 2))), 128))
652
+ ], 512)) : (P(), R("div", He, [
653
+ w[2] || (w[2] = S("div", { class: "title" }, [
654
+ S("img", {
655
+ src: he,
656
+ alt: "AI助手",
657
+ class: "panel-icon"
658
+ }),
659
+ S("h3", { class: "title-text" }, "Hi, 您好")
660
+ ], -1)),
661
+ S("div", Fe, [
662
+ w[1] || (w[1] = de(" 我是")),
663
+ S("span", De, F(e.title), 1)
664
+ ]),
665
+ S("div", Je, [
666
+ (P(!0), R(G, null, X(B.value, (L, j) => (P(), R("div", {
667
+ key: j,
668
+ class: "question-item",
669
+ onClick: (M) => b(L)
670
+ }, [
671
+ S("span", null, F(L), 1),
672
+ E(T, null, {
673
+ default: q(() => [
674
+ E(D, {
675
+ name: "arrow-right",
676
+ color: "#999999"
677
+ })
678
+ ]),
679
+ _: 1
680
+ })
681
+ ], 8, Qe))), 128))
682
+ ])
683
+ ]))
684
+ ]),
685
+ S("div", Ze, [
686
+ f.value ? (P(), R("img", Ke)) : H("", !0),
687
+ S("div", Ge, [
688
+ E(A, {
689
+ modelValue: v.value,
690
+ "onUpdate:modelValue": w[0] || (w[0] = (L) => v.value = L),
691
+ ref_key: "refInputTextString",
692
+ ref: g,
693
+ placeholder: "请输入您的问题",
694
+ autofocus: "",
695
+ onKeyup: pe(l, ["enter"])
696
+ }, {
697
+ append: q(() => [
698
+ S("div", {
699
+ class: "send-icon-box",
700
+ onClick: l
701
+ }, [
702
+ S("img", {
703
+ src: c.value,
704
+ alt: "发送",
705
+ class: "send-icon"
706
+ }, null, 8, Xe)
707
+ ])
708
+ ]),
709
+ _: 1
710
+ }, 8, ["modelValue"])
711
+ ])
712
+ ])
713
+ ], 2)) : H("", !0)
714
+ ]),
715
+ _: 1
716
+ });
717
+ };
718
+ }
719
+ }, et = /* @__PURE__ */ J(Ye, [["__scopeId", "data-v-fe7b1f6c"]]);
720
+ var se = { exports: {} };
721
+ (function(e, n) {
722
+ (function(r, i) {
723
+ e.exports = i();
724
+ })(window, function() {
725
+ return function(r) {
726
+ var i = {};
727
+ function s(t) {
728
+ if (i[t]) return i[t].exports;
729
+ var d = i[t] = { i: t, l: !1, exports: {} };
730
+ return r[t].call(d.exports, d, d.exports, s), d.l = !0, d.exports;
731
+ }
732
+ return s.m = r, s.c = i, s.d = function(t, d, _) {
733
+ s.o(t, d) || Object.defineProperty(t, d, { enumerable: !0, get: _ });
734
+ }, s.r = function(t) {
735
+ typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t, "__esModule", { value: !0 });
736
+ }, s.t = function(t, d) {
737
+ if (1 & d && (t = s(t)), 8 & d || 4 & d && typeof t == "object" && t && t.__esModule) return t;
738
+ var _ = /* @__PURE__ */ Object.create(null);
739
+ if (s.r(_), Object.defineProperty(_, "default", { enumerable: !0, value: t }), 2 & d && typeof t != "string") for (var v in t) s.d(_, v, (function(g) {
740
+ return t[g];
741
+ }).bind(null, v));
742
+ return _;
743
+ }, s.n = function(t) {
744
+ var d = t && t.__esModule ? function() {
745
+ return t.default;
746
+ } : function() {
747
+ return t;
748
+ };
749
+ return s.d(d, "a", d), d;
750
+ }, s.o = function(t, d) {
751
+ return Object.prototype.hasOwnProperty.call(t, d);
752
+ }, s.p = "", s(s.s = 0);
753
+ }([function(r, i, s) {
754
+ function t(f, c, u, a) {
755
+ u.push(f), a.push([].concat(c[f] || []));
756
+ }
757
+ function d(f, c) {
758
+ if (!f) throw new Error("[getMaxDepsChain] dep 参数不能为空");
759
+ var u = [], a = [], o = [];
760
+ for (t(f, c, a, o); a.length; ) {
761
+ var h = o.pop();
762
+ if (h && h.length) {
763
+ var p = h.shift();
764
+ if (o.push(h), ~a.indexOf(p)) throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: " + p + ", mainStack: " + a);
765
+ t(p, c, a, o);
766
+ } else u.push([].concat(a)), a.pop();
767
+ }
768
+ return u.reduce(function(x, b) {
769
+ return b.length > x.length ? b : x;
770
+ }, []);
771
+ }
772
+ function _(f) {
773
+ if (!f) throw new Error("[depsParser] 入参不能为空");
774
+ var c = {};
775
+ f.forEach(function(a) {
776
+ c[a.name] = a.deps || [];
777
+ });
778
+ var u = [];
779
+ return f.forEach(function(a) {
780
+ var o = d(a.name, c).length - 1;
781
+ a.priority = o, u[o] = (u[o] || []).concat(a);
782
+ }), u;
783
+ }
784
+ s.r(i), s.d(i, "loadScript", function() {
785
+ return B;
786
+ }), s.d(i, "loadScripts", function() {
787
+ return k;
788
+ }), s.d(i, "dynamicLoadScripts", function() {
789
+ return $;
790
+ }), s.d(i, "createScriptsLoadIterator", function() {
791
+ return I;
792
+ }), s.d(i, "loadScriptsQueue", function() {
793
+ return U;
794
+ }), s.d(i, "getMaxDepsChain", function() {
795
+ return d;
796
+ }), s.d(i, "depsParser", function() {
797
+ return _;
798
+ });
799
+ var v = function() {
800
+ return (v = Object.assign || function(f) {
801
+ for (var c, u = 1, a = arguments.length; u < a; u++) for (var o in c = arguments[u]) Object.prototype.hasOwnProperty.call(c, o) && (f[o] = c[o]);
802
+ return f;
803
+ }).apply(this, arguments);
804
+ }, g = function(f, c, u, a) {
805
+ return new (u || (u = Promise))(function(o, h) {
806
+ function p(y) {
807
+ try {
808
+ b(a.next(y));
809
+ } catch (l) {
810
+ h(l);
811
+ }
812
+ }
813
+ function x(y) {
814
+ try {
815
+ b(a.throw(y));
816
+ } catch (l) {
817
+ h(l);
818
+ }
819
+ }
820
+ function b(y) {
821
+ var l;
822
+ y.done ? o(y.value) : (l = y.value, l instanceof u ? l : new u(function(m) {
823
+ m(l);
824
+ })).then(p, x);
825
+ }
826
+ b((a = a.apply(f, [])).next());
827
+ });
828
+ }, z = function(f, c) {
829
+ var u, a, o, h, p = { label: 0, sent: function() {
830
+ if (1 & o[0]) throw o[1];
831
+ return o[1];
832
+ }, trys: [], ops: [] };
833
+ return h = { next: x(0), throw: x(1), return: x(2) }, typeof Symbol == "function" && (h[Symbol.iterator] = function() {
834
+ return this;
835
+ }), h;
836
+ function x(b) {
837
+ return function(y) {
838
+ return function(l) {
839
+ if (u) throw new TypeError("Generator is already executing.");
840
+ for (; p; ) try {
841
+ if (u = 1, a && (o = 2 & l[0] ? a.return : l[0] ? a.throw || ((o = a.return) && o.call(a), 0) : a.next) && !(o = o.call(a, l[1])).done) return o;
842
+ switch (a = 0, o && (l = [2 & l[0], o.value]), l[0]) {
843
+ case 0:
844
+ case 1:
845
+ o = l;
846
+ break;
847
+ case 4:
848
+ return p.label++, { value: l[1], done: !1 };
849
+ case 5:
850
+ p.label++, a = l[1], l = [0];
851
+ continue;
852
+ case 7:
853
+ l = p.ops.pop(), p.trys.pop();
854
+ continue;
855
+ default:
856
+ if (o = p.trys, !((o = o.length > 0 && o[o.length - 1]) || l[0] !== 6 && l[0] !== 2)) {
857
+ p = 0;
858
+ continue;
859
+ }
860
+ if (l[0] === 3 && (!o || l[1] > o[0] && l[1] < o[3])) {
861
+ p.label = l[1];
862
+ break;
863
+ }
864
+ if (l[0] === 6 && p.label < o[1]) {
865
+ p.label = o[1], o = l;
866
+ break;
867
+ }
868
+ if (o && p.label < o[2]) {
869
+ p.label = o[2], p.ops.push(l);
870
+ break;
871
+ }
872
+ o[2] && p.ops.pop(), p.trys.pop();
873
+ continue;
874
+ }
875
+ l = c.call(f, p);
876
+ } catch (m) {
877
+ l = [6, m], a = 0;
878
+ } finally {
879
+ u = o = 0;
880
+ }
881
+ if (5 & l[0]) throw l[1];
882
+ return { value: l[0] ? l[1] : void 0, done: !0 };
883
+ }([b, y]);
884
+ };
885
+ }
886
+ }, O = function(f) {
887
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
888
+ var c, u = f[Symbol.asyncIterator];
889
+ return u ? u.call(f) : (f = typeof __values == "function" ? __values(f) : f[Symbol.iterator](), c = {}, a("next"), a("throw"), a("return"), c[Symbol.asyncIterator] = function() {
890
+ return this;
891
+ }, c);
892
+ function a(o) {
893
+ c[o] = f[o] && function(h) {
894
+ return new Promise(function(p, x) {
895
+ (function(b, y, l, m) {
896
+ Promise.resolve(m).then(function(w) {
897
+ b({ value: w, done: l });
898
+ }, y);
899
+ })(p, x, (h = f[o](h)).done, h.value);
900
+ });
901
+ };
902
+ }
903
+ };
904
+ function B(f, c) {
905
+ return c === void 0 && (c = !1), new Promise(function(u, a) {
906
+ var o = c ? document.head : document.body, h = document.createElement("script");
907
+ h.type = "text/javascript", h.src = f, h.crossOrigin = "anonymous", h.onreadystatechange = u, h.onload = u, h.onerror = a, o.appendChild(h);
908
+ });
909
+ }
910
+ var k = function(f, c) {
911
+ return c === void 0 && (c = {}), g(void 0, void 0, void 0, function() {
912
+ var u, a, o, h, p;
913
+ return z(this, function(x) {
914
+ switch (x.label) {
915
+ case 0:
916
+ return u = c.baseUrl, a = u === void 0 ? "" : u, o = c.lastLoadResult, h = c.inHead, p = h !== void 0 && h, [4, Promise.all(f.map(function(b) {
917
+ return g(void 0, void 0, void 0, function() {
918
+ var y, l, m, w, T, A, L, j;
919
+ return z(this, function(M) {
920
+ switch (M.label) {
921
+ case 0:
922
+ return y = b.name, l = b.path, m = b.deps, (L = {})[y] = !0, w = L, (j = {})[y] = !1, T = j, window[y] ? [2, w] : [3, 1];
923
+ case 1:
924
+ return A = !0, m && o && [].concat(m).forEach(function(le) {
925
+ o[le] !== !1 && (A = !0);
926
+ }), A ? [4, B(l.indexOf("http") === 0 || l.indexOf("//:") === 0 ? l : a + l, p).then(function() {
927
+ return w;
928
+ }).catch(function() {
929
+ return T;
930
+ })] : [3, 3];
931
+ case 2:
932
+ return [2, M.sent()];
933
+ case 3:
934
+ return [2, T];
935
+ }
936
+ });
937
+ });
938
+ }))];
939
+ case 1:
940
+ return [2, x.sent()];
941
+ }
942
+ });
943
+ });
944
+ }, $ = function(f, c) {
945
+ return c === void 0 && (c = {}), function() {
946
+ var u = [].concat(_(f));
947
+ return { next: function() {
948
+ if (u.length) {
949
+ var a = u.shift();
950
+ return k(a, c).then(function(o) {
951
+ return { value: o, done: !1 };
952
+ });
953
+ }
954
+ return Promise.resolve({ done: !0 });
955
+ } };
956
+ };
957
+ }, I = function(f, c) {
958
+ var u;
959
+ return c === void 0 && (c = {}), (u = {})[Symbol.asyncIterator] = $(f, c), u;
960
+ }, U = function(f, c) {
961
+ return c === void 0 && (c = {}), g(void 0, void 0, void 0, function() {
962
+ var u, a, o, h, p, x;
963
+ return z(this, function(b) {
964
+ switch (b.label) {
965
+ case 0:
966
+ b.trys.push([0, 5, 6, 11]), u = O(I(f, c)), b.label = 1;
967
+ case 1:
968
+ return [4, u.next()];
969
+ case 2:
970
+ if ((a = b.sent()).done) return [3, 4];
971
+ o = a.value, c.lastLoadResult = c.lastLoadResult || {}, console.log("current load: ", o), o.forEach(function(y) {
972
+ c.lastLoadResult = v(v({}, c.lastLoadResult), y);
973
+ }), b.label = 3;
974
+ case 3:
975
+ return [3, 1];
976
+ case 4:
977
+ return [3, 11];
978
+ case 5:
979
+ return h = b.sent(), p = { error: h }, [3, 11];
980
+ case 6:
981
+ return b.trys.push([6, , 9, 10]), a && !a.done && (x = u.return) ? [4, x.call(u)] : [3, 8];
982
+ case 7:
983
+ b.sent(), b.label = 8;
984
+ case 8:
985
+ return [3, 10];
986
+ case 9:
987
+ if (p) throw p.error;
988
+ return [7];
989
+ case 10:
990
+ return [7];
991
+ case 11:
992
+ return [2, c.lastLoadResult];
993
+ }
994
+ });
995
+ });
996
+ };
997
+ }]);
998
+ });
999
+ })(se);
1000
+ var tt = se.exports;
1001
+ const nt = {
1002
+ key: 0,
1003
+ class: "ai-assistant"
1004
+ }, rt = {
1005
+ name: "AiChat"
1006
+ //这个⾮常重要,就是未来你放到其他项⽬中,组件标签的名字,⽐如:<sz-workflow></sz-workflow>
1007
+ }, ot = /* @__PURE__ */ ne({
1008
+ ...rt,
1009
+ props: {
1010
+ token: {
1011
+ type: String,
1012
+ default: ""
1013
+ },
1014
+ identifier: {
1015
+ type: String,
1016
+ default: ""
1017
+ },
1018
+ baseUrl: {
1019
+ type: String,
1020
+ default: ""
1021
+ },
1022
+ title: {
1023
+ type: String,
1024
+ default: "数智AI助理"
1025
+ }
1026
+ },
1027
+ setup(e) {
1028
+ const n = C(!1), r = C(!1), i = () => {
1029
+ n.value = !n.value;
1030
+ }, s = () => {
1031
+ r.value = !0, n.value = !1;
1032
+ }, t = (v) => {
1033
+ console.log("用户输入:", v);
1034
+ }, d = [
1035
+ {
1036
+ name: "markdownit",
1037
+ path: "markdown-it.min.js"
1038
+ },
1039
+ {
1040
+ name: "hljs",
1041
+ path: "highlight.11.11.1.min.js"
1042
+ }
1043
+ ];
1044
+ let _ = {};
1045
+ return tt.loadScriptsQueue(d, {
1046
+ baseUrl: "/scripts/ai/",
1047
+ lastLoadResult: _,
1048
+ inHead: !1
1049
+ }).then((v) => {
1050
+ if (console.log("load ai deps: ", v), window.markdownit) {
1051
+ const g = window.markdownit();
1052
+ console.log("markdownit: ", g), ze();
1053
+ }
1054
+ }), (v, g) => r.value ? H("", !0) : (P(), R("div", nt, [
1055
+ E(et, {
1056
+ modelValue: n.value,
1057
+ "onUpdate:modelValue": g[0] || (g[0] = (z) => n.value = z),
1058
+ onSubmit: t,
1059
+ token: e.token,
1060
+ identifier: e.identifier,
1061
+ baseUrl: e.baseUrl,
1062
+ title: e.title
1063
+ }, null, 8, ["modelValue", "token", "identifier", "baseUrl", "title"]),
1064
+ S("div", {
1065
+ class: "ai-icon",
1066
+ onClick: i
1067
+ }, [
1068
+ S("div", {
1069
+ class: "close-icon",
1070
+ onClick: me(s, ["stop"])
1071
+ }, g[1] || (g[1] = [
1072
+ S("svg", {
1073
+ viewBox: "0 0 1024 1024",
1074
+ width: "8",
1075
+ height: "8"
1076
+ }, [
1077
+ S("path", {
1078
+ d: "M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",
1079
+ fill: "currentColor"
1080
+ })
1081
+ ], -1)
1082
+ ])),
1083
+ g[2] || (g[2] = S("img", {
1084
+ src: ve,
1085
+ alt: "AI助手"
1086
+ }, null, -1)),
1087
+ g[3] || (g[3] = S("span", { class: "ai-icon-text" }, "AI助手", -1))
1088
+ ])
1089
+ ]));
1090
+ }
1091
+ }), at = /* @__PURE__ */ J(ot, [["__scopeId", "data-v-4b85f480"]]);
1092
+ if (typeof window < "u") {
1093
+ let e = function() {
1094
+ var n = document.body, r = document.getElementById("__svg__icons__dom__");
1095
+ r || (r = document.createElementNS("http://www.w3.org/2000/svg", "svg"), r.style.position = "absolute", r.style.width = "0", r.style.height = "0", r.id = "__svg__icons__dom__", r.setAttribute("xmlns", "http://www.w3.org/2000/svg"), r.setAttribute("xmlns:link", "http://www.w3.org/1999/xlink")), r.innerHTML = '<symbol viewBox="0 0 16 16" id="icon-arrow-right"><g fill="none" fill-rule="evenodd"><path d="M0 0h16v16H0Z" /><path d="m8.44 3.854.706-.707 4.642 4.641a.3.3 0 0 1 0 .424l-4.642 4.642-.707-.708L12.086 8.5H2v-1h10.086L8.439 3.854Z" fill="currentColor" fill-rule="nonzero" /></g></symbol><symbol viewBox="0 0 24 24" id="icon-close"><g fill="none" fill-rule="evenodd"><path d="M0 0h24v24H0z" /><path d="m12.865 12 3.956-3.955a.61.61 0 1 0-.864-.864L12 11.135 8.043 7.179a.61.61 0 1 0-.863.864L11.134 12 7.18 15.956a.61.61 0 1 0 .864.864L12 12.864l3.957 3.957c.12.12.275.179.432.179a.61.61 0 0 0 .432-1.042L12.865 12Z" fill-opacity=".65" fill="currentColor" fill-rule="nonzero" /></g></symbol><symbol viewBox="0 0 32 32" id="icon-copy"><path fill="currentColor" d="m27.4 14.7-6.1-6.1C21 8.2 20.5 8 20 8h-8c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V16.1c0-.5-.2-1-.6-1.4M20 10l5.9 6H20zm-8 18V10h6v6c0 1.1.9 2 2 2h6v10z" /><path fill="currentColor" d="M6 18H4V4c0-1.1.9-2 2-2h14v2H6z" /></symbol><symbol viewBox="0 0 24 24" id="icon-drawer-layout"><path d="M4.813 4.188a.624.624 0 0 0-.625.625v14.375c0 .345.279.625.625.625h14.375c.345 0 .625-.28.625-.625V4.813a.624.624 0 0 0-.625-.625ZM15.75 5.593h2.656v12.812H15.75V5.594Zm-10.156 0H14.5v12.812H5.594V5.594Z" fill="#999" fill-rule="nonzero" /></symbol>', n.insertBefore(r, n.lastChild);
1096
+ };
1097
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : e();
1098
+ }
1099
+ const te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1100
+ __proto__: null,
1101
+ SzAiChat: at
1102
+ }, Symbol.toStringTag, { value: "Module" })), W = function(e) {
1103
+ if (!W.installed) {
1104
+ W.installed = !0;
1105
+ for (let n in te) {
1106
+ const r = Reflect.get(te, n);
1107
+ e.component(r.name, r);
1108
+ }
1109
+ }
1110
+ }, st = "0.1.1", lt = "Sz";
1111
+ function ct({
1112
+ componentPrefix: e = lt,
1113
+ components: n = []
1114
+ } = {}) {
1115
+ const r = [];
1116
+ function i(t, d, _) {
1117
+ t.component(e + d) || t.component(
1118
+ e + d,
1119
+ _
1120
+ );
1121
+ }
1122
+ function s(t) {
1123
+ r.includes(t) || (r.push(t), n.forEach((d) => {
1124
+ const { name: _, alias: v } = d;
1125
+ console.log(444, _, v), i(t, _, d), v && v.forEach((g) => {
1126
+ i(t, g, d);
1127
+ });
1128
+ }));
1129
+ }
1130
+ return {
1131
+ version: st,
1132
+ componentPrefix: e,
1133
+ install: s
1134
+ };
1135
+ }
1136
+ const ut = {
1137
+ install(e) {
1138
+ W(e);
1139
+ }
1140
+ };
1141
+ export {
1142
+ at as SzAiChat,
1143
+ ct as create,
1144
+ ut as default
1145
+ };