@szjy/ai-coms 0.1.3 → 0.1.5

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 CHANGED
@@ -1,17 +1,41 @@
1
- import { computed as q, createElementBlock as O, openBlock as P, normalizeStyle as K, createElementVNode as k, normalizeClass as H, getCurrentInstance as ne, ref as C, watch as ie, onUnmounted as ce, createBlock as J, Transition as re, withCtx as F, createCommentVNode as D, createVNode as $, nextTick as oe, resolveComponent as X, toDisplayString as V, createTextVNode as ue, Fragment as G, renderList as Y, unref as de, withKeys as fe, defineComponent as pe, withModifiers as me } from "vue";
2
- const he = "/images/ai-round.png", ve = "/images/ai-sqrt.png", ge = "/images/bars-loading.svg";
3
- function ye(t, n = location.href) {
4
- return new URLSearchParams(new URL(n).search).get(t);
5
- }
6
- function be(t) {
1
+ import { computed as q, openBlock as P, createElementBlock as L, normalizeStyle as K, createElementVNode as x, normalizeClass as W, getCurrentInstance as re, ref as C, watch as ue, onUnmounted as de, createBlock as J, Transition as oe, withCtx as M, createVNode as E, createCommentVNode as B, nextTick as ae, resolveComponent as X, toDisplayString as D, createTextVNode as fe, Fragment as Y, renderList as Z, withKeys as pe, defineComponent as me, withModifiers as he } from "vue";
2
+ const ve = "/images/ai-round.png", ye = "/images/ai-sqrt.png", ge = "/images/bars-loading.svg";
3
+ function se(t) {
7
4
  return t.startsWith("http://") || t.startsWith("https://") ? t : `${location.protocol}//${location.host}${t}`;
8
5
  }
6
+ async function be(t, n, a, s = "") {
7
+ const r = se(s), e = new URL(`${r}/v1/chat/completions`), i = new Request(e, {
8
+ method: "post",
9
+ headers: {
10
+ "Content-Type": "application/json",
11
+ Authorization: "Bearer app-oLZVFFdYyJX2QK3rdOLWsC2u"
12
+ },
13
+ body: JSON.stringify({
14
+ model: "dify",
15
+ stream: !0,
16
+ inputs: {
17
+ token: n
18
+ },
19
+ messages: [
20
+ {
21
+ role: "system",
22
+ content: "你是一个专业的AI助手,请用中文回答问题。"
23
+ },
24
+ {
25
+ role: "user",
26
+ content: t
27
+ }
28
+ ]
29
+ })
30
+ });
31
+ return fetch(i);
32
+ }
9
33
  async function we(t) {
10
- const n = new URL("http://localhost:11434/api/chat"), o = {};
11
- Object.keys(o).forEach((r) => {
12
- n.searchParams.append(r, o[r]);
34
+ const n = new URL("http://localhost:11434/api/chat"), a = {};
35
+ Object.keys(a).forEach((r) => {
36
+ n.searchParams.append(r, a[r]);
13
37
  });
14
- const a = new Request(n, {
38
+ const s = new Request(n, {
15
39
  mode: "cors",
16
40
  method: "post",
17
41
  headers: {
@@ -32,14 +56,14 @@ async function we(t) {
32
56
  ]
33
57
  })
34
58
  });
35
- return fetch(a);
59
+ return fetch(s);
36
60
  }
37
61
  async function xe(t, n) {
38
- const o = new URL(`${location.origin}/spark/v1/chat/completions`), a = {};
39
- Object.keys(a).forEach((e) => {
40
- o.searchParams.append(e, a[e]);
62
+ const a = new URL(`${location.origin}/spark/v1/chat/completions`), s = {};
63
+ Object.keys(s).forEach((e) => {
64
+ a.searchParams.append(e, s[e]);
41
65
  });
42
- const r = new Request(o, {
66
+ const r = new Request(a, {
43
67
  method: "post",
44
68
  headers: {
45
69
  "Content-Type": "application/json",
@@ -59,11 +83,11 @@ async function xe(t, n) {
59
83
  return fetch(r);
60
84
  }
61
85
  async function ke(t, n) {
62
- const o = new URL(`${location.origin}/siliconflow/v1/chat/completions`), a = {};
63
- Object.keys(a).forEach((e) => {
64
- o.searchParams.append(e, a[e]);
86
+ const a = new URL(`${location.origin}/siliconflow/v1/chat/completions`), s = {};
87
+ Object.keys(s).forEach((e) => {
88
+ a.searchParams.append(e, s[e]);
65
89
  });
66
- const r = new Request(o, {
90
+ const r = new Request(a, {
67
91
  method: "post",
68
92
  headers: {
69
93
  "Content-Type": "application/json",
@@ -84,11 +108,11 @@ async function ke(t, n) {
84
108
  return fetch(r);
85
109
  }
86
110
  async function Se(t, n) {
87
- const o = new URL(`${location.origin}/moonshot/v1/chat/completions`), a = {};
88
- Object.keys(a).forEach((e) => {
89
- o.searchParams.append(e, a[e]);
111
+ const a = new URL(`${location.origin}/moonshot/v1/chat/completions`), s = {};
112
+ Object.keys(s).forEach((e) => {
113
+ a.searchParams.append(e, s[e]);
90
114
  });
91
- const r = new Request(o, {
115
+ const r = new Request(a, {
92
116
  method: "post",
93
117
  headers: {
94
118
  "Content-Type": "application/json",
@@ -112,11 +136,11 @@ async function Se(t, n) {
112
136
  return fetch(r);
113
137
  }
114
138
  async function _e(t, n) {
115
- const o = new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`), a = {};
116
- Object.keys(a).forEach((e) => {
117
- o.searchParams.append(e, a[e]);
139
+ const a = new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`), s = {};
140
+ Object.keys(s).forEach((e) => {
141
+ a.searchParams.append(e, s[e]);
118
142
  });
119
- const r = new Request(o, {
143
+ const r = new Request(a, {
120
144
  method: "post",
121
145
  headers: {
122
146
  "Content-Type": "application/json",
@@ -139,12 +163,12 @@ async function _e(t, n) {
139
163
  });
140
164
  return fetch(r);
141
165
  }
142
- async function Ce(t, n, o, a = "") {
143
- const r = be(a), e = new URL(`${r}/support/${o}/a`), i = {};
144
- Object.keys(i).forEach((h) => {
145
- e.searchParams.append(h, i[h]);
166
+ async function Ce(t, n, a, s = "") {
167
+ const r = se(s), e = new URL(`${r}/support/${a}/a`), i = {};
168
+ Object.keys(i).forEach((v) => {
169
+ e.searchParams.append(v, i[v]);
146
170
  });
147
- const v = new Request(e, {
171
+ const f = new Request(e, {
148
172
  method: "post",
149
173
  headers: {
150
174
  "Content-Type": "application/json",
@@ -154,7 +178,7 @@ async function Ce(t, n, o, a = "") {
154
178
  content: t
155
179
  })
156
180
  });
157
- return fetch(v);
181
+ return fetch(f);
158
182
  }
159
183
  const Te = (t) => {
160
184
  if (t.startsWith("data:")) {
@@ -165,12 +189,12 @@ const Te = (t) => {
165
189
  };
166
190
  try {
167
191
  return JSON.parse(n);
168
- } catch (o) {
169
- console.error("JSON parsing error:", o);
192
+ } catch (a) {
193
+ console.error("JSON parsing error:", a);
170
194
  }
171
195
  }
172
196
  return null;
173
- }, Re = [
197
+ }, G = [
174
198
  {
175
199
  label: "模拟数据模型",
176
200
  modelName: "standard",
@@ -205,14 +229,19 @@ const Te = (t) => {
205
229
  label: "数智建管大模型",
206
230
  modelName: "szjy",
207
231
  api: Ce
232
+ },
233
+ {
234
+ label: "Dify (OpenAI 兼容)",
235
+ modelName: "dify-openai",
236
+ api: be
208
237
  }
209
- ], Z = {
238
+ ], ee = {
210
239
  standard(t, n) {
211
- let o = "";
212
- return t instanceof Uint8Array ? o = n.decode(t, {
240
+ let a = "";
241
+ return t instanceof Uint8Array ? a = n.decode(t, {
213
242
  stream: !0
214
- }) : o = t, {
215
- content: o
243
+ }) : a = t, {
244
+ content: a
216
245
  };
217
246
  },
218
247
  spark(t) {
@@ -235,52 +264,55 @@ const Te = (t) => {
235
264
  szjy(t) {
236
265
  return this.spark(t);
237
266
  },
267
+ "dify-openai"(t) {
268
+ return this.spark(t);
269
+ },
238
270
  ollama3(t) {
239
271
  return {
240
272
  content: JSON.parse(t).message.content
241
273
  };
242
274
  }
243
- }, ee = (t, n, o) => {
244
- const a = t.split(o);
245
- return a.slice(0, -1).forEach((r) => {
275
+ }, te = (t, n, a) => {
276
+ const s = t.split(a);
277
+ return s.slice(0, -1).forEach((r) => {
246
278
  r.trim() !== "" && n.enqueue(r);
247
- }), a[a.length - 1];
248
- }, Pe = (t) => {
279
+ }), s[s.length - 1];
280
+ }, Re = (t) => {
249
281
  let n = "";
250
282
  return new TransformStream({
251
- transform(o, a) {
252
- if (n += o, n.trim().startsWith("data:"))
253
- n = ee(n, a, t);
283
+ transform(a, s) {
284
+ if (n += a, n.trim().startsWith("data:"))
285
+ n = te(n, s, t);
254
286
  else
255
287
  try {
256
- JSON.parse(n), n = ee(n, a, t);
288
+ JSON.parse(n), n = te(n, s, t);
257
289
  } catch {
258
- a.enqueue(o), n = "";
290
+ s.enqueue(a), n = "";
259
291
  }
260
292
  },
261
- flush(o) {
262
- n.trim() !== "" && o.enqueue(n);
293
+ flush(a) {
294
+ n.trim() !== "" && a.enqueue(n);
263
295
  }
264
296
  });
265
297
  };
266
- async function Le(t, n) {
267
- const o = t.api;
268
- return o ? new Promise((a) => {
269
- o(n.text, n.token, n.identifier, n.baseUrl).then((r) => {
298
+ async function Pe(t, n) {
299
+ const a = t.api;
300
+ return a ? new Promise((s) => {
301
+ a(n.text, n.token, n.identifier, n.baseUrl).then((r) => {
270
302
  if (r.body) {
271
- const e = r.body.pipeThrough(new TextDecoderStream()).pipeThrough(Pe(`
303
+ const e = r.body.pipeThrough(new TextDecoderStream()).pipeThrough(Re(`
272
304
  `)).getReader();
273
- console.log("reader from response:", e), a({
305
+ console.log("reader from response:", e), s({
274
306
  error: 0,
275
307
  reader: e
276
308
  });
277
309
  } else
278
- a({
310
+ s({
279
311
  error: 1,
280
312
  reader: null
281
313
  });
282
314
  }).catch((r) => {
283
- a({
315
+ s({
284
316
  error: 1,
285
317
  reader: null
286
318
  });
@@ -290,20 +322,20 @@ async function Le(t, n) {
290
322
  reader: null
291
323
  };
292
324
  }
293
- let B = null;
325
+ let F = null;
294
326
  function Ne() {
295
- return B || (window.markdownit ? B = new window.markdownit({
327
+ return F || (window.markdownit ? F = new window.markdownit({
296
328
  html: !0,
297
329
  linkify: !0,
298
330
  typographer: !0
299
- }) : console.log("markdownit is not loaded"), B);
331
+ }) : console.log("markdownit is not loaded"), F);
300
332
  }
301
- const ae = (t, n) => {
302
- const o = t.__vccOpts || t;
303
- for (const [a, r] of n)
304
- o[a] = r;
305
- return o;
306
- }, Oe = ["src", "alt"], ze = {
333
+ const le = (t, n) => {
334
+ const a = t.__vccOpts || t;
335
+ for (const [s, r] of n)
336
+ a[s] = r;
337
+ return a;
338
+ }, Oe = ["src", "alt"], Le = {
307
339
  __name: "SvgIcon",
308
340
  props: {
309
341
  // 图标名称或完整URL
@@ -333,12 +365,12 @@ const ae = (t, n) => {
333
365
  }
334
366
  },
335
367
  setup(t) {
336
- const n = t, o = q(() => {
368
+ const n = t, a = q(() => {
337
369
  if (n.name.startsWith("http://") || n.name.startsWith("https://") || n.name.startsWith("/"))
338
370
  return n.name;
339
371
  const e = n.name.endsWith(".svg") ? n.name : `${n.name}.svg`;
340
372
  return `${n.basePath}${e}`;
341
- }), a = q(() => {
373
+ }), s = q(() => {
342
374
  const e = typeof n.size == "number" ? `${n.size}px` : n.size;
343
375
  return {
344
376
  width: e,
@@ -354,26 +386,26 @@ const ae = (t, n) => {
354
386
  };
355
387
  return n.color && (e.filter = `drop-shadow(0 0 0 ${n.color})`), e;
356
388
  });
357
- return (e, i) => (P(), O("div", {
389
+ return (e, i) => (P(), L("div", {
358
390
  class: "svg-icon-wrapper",
359
- style: K(a.value)
391
+ style: K(s.value)
360
392
  }, [
361
- k("img", {
362
- src: o.value,
393
+ x("img", {
394
+ src: a.value,
363
395
  alt: t.name,
364
- class: H(["svg-icon", t.className]),
396
+ class: W(["svg-icon", t.className]),
365
397
  style: K(r.value)
366
398
  }, null, 14, Oe)
367
399
  ], 4));
368
400
  }
369
- }, W = /* @__PURE__ */ ae(ze, [["__scopeId", "data-v-490b11c1"]]), je = async (t) => {
401
+ }, V = /* @__PURE__ */ le(Le, [["__scopeId", "data-v-490b11c1"]]), ze = async (t) => {
370
402
  if (navigator.clipboard && navigator.permissions)
371
403
  await navigator.clipboard.writeText(t);
372
404
  else {
373
405
  const n = document.createElement("textArea");
374
406
  n.value = t, 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);
375
407
  }
376
- }, Ee = ["innerHTML"], Ie = {
408
+ }, je = ["innerHTML"], Ie = {
377
409
  __name: "Previewer",
378
410
  props: {
379
411
  reader: null,
@@ -390,145 +422,145 @@ const ae = (t, n) => {
390
422
  "completed",
391
423
  "updating"
392
424
  ],
393
- setup(t, { expose: n, emit: o }) {
394
- const { appContext: a } = ne(), { $message: r } = a.config.globalProperties, e = t, i = C(e.displayText || ""), v = C(""), h = C(!0), y = C(!1), L = C(!!e.displayText), N = o, A = C(null);
395
- let _ = null;
396
- const j = q(() => B ? B.render(i.value) : i.value), E = () => {
397
- e.reader && e.reader.cancel(), y.value = !0, l.value = !1, d(), L.value = !0, N("completed", i.value), h.value = !1, _ && (cancelAnimationFrame(_), _ = null);
398
- }, M = q(() => `${j.value}`), f = C(!1), u = () => {
399
- f.value = !0;
425
+ setup(t, { expose: n, emit: a }) {
426
+ const { appContext: s } = re(), { $message: r } = s.config.globalProperties, e = t, i = C(e.displayText || ""), f = C(""), v = C(!0), b = C(!1), _ = C(!!e.displayText), $ = a, N = C(null);
427
+ let T = null;
428
+ const U = q(() => F ? F.render(i.value) : i.value), I = () => {
429
+ e.reader && e.reader.cancel(), b.value = !0, c.value = !1, d(), _.value = !0, $("completed", i.value), v.value = !1, T && (cancelAnimationFrame(T), T = null);
430
+ }, z = q(() => `${U.value}`), p = C(!1), u = () => {
431
+ p.value = !0;
400
432
  }, d = () => {
401
- f.value = !1;
402
- }, l = C(!1), s = async () => {
433
+ p.value = !1;
434
+ }, c = C(!1), l = async () => {
403
435
  if (!e.reader) return;
404
- const b = new TextDecoder("utf-8");
405
- for (h.value = !0; !y.value; )
436
+ const g = new TextDecoder("utf-8");
437
+ for (v.value = !0; !b.value; )
406
438
  try {
407
439
  if (!e.reader) {
408
- l.value = !0;
440
+ c.value = !0;
409
441
  break;
410
442
  }
411
- const { value: c, done: m } = await e.reader.read();
443
+ const { value: o, done: y } = await e.reader.read();
412
444
  if (!e.reader) {
413
- l.value = !0;
445
+ c.value = !0;
414
446
  break;
415
447
  }
416
- if (m) {
417
- l.value = !0;
448
+ if (y) {
449
+ c.value = !0;
418
450
  break;
419
451
  }
420
- const w = Z[e.model];
421
- if (!w)
452
+ const S = ee[e.model];
453
+ if (!S)
422
454
  break;
423
- const T = w.call(Z, c, b);
424
- if (T.done) {
425
- l.value = !0;
455
+ const O = S.call(ee, o, g);
456
+ if (O.done) {
457
+ c.value = !0;
426
458
  break;
427
459
  }
428
- v.value += T.content, _ === null && S();
429
- } catch (c) {
430
- l.value = !0, console.log(3333, c), N("failed", c), E();
460
+ f.value += O.content, T === null && k();
461
+ } catch (o) {
462
+ c.value = !0, console.log(3333, o), $("failed", o), I();
431
463
  break;
432
464
  } finally {
433
465
  d();
434
466
  }
435
- }, g = async () => {
467
+ }, m = async () => {
436
468
  e.scrollToBottomFn && e.scrollToBottomFn();
437
- }, p = (b = () => {
438
- }, c = () => {
469
+ }, h = (g = () => {
470
+ }, o = () => {
439
471
  }) => {
440
- if (v.value.length > 0) {
441
- const m = v.value.substring(0, 10);
442
- i.value += m, v.value = v.value.substring(10), b();
472
+ if (f.value.length > 0) {
473
+ const y = f.value.substring(0, 10);
474
+ i.value += y, f.value = f.value.substring(10), g();
443
475
  } else
444
- c();
445
- }, S = () => {
446
- if (y.value && _) {
447
- cancelAnimationFrame(_), _ = null, h.value = !1;
476
+ o();
477
+ }, k = () => {
478
+ if (b.value && T) {
479
+ cancelAnimationFrame(T), T = null, v.value = !1;
448
480
  return;
449
481
  }
450
- l.value ? p(
482
+ c.value ? h(
451
483
  () => {
452
- _ = requestAnimationFrame(S), N("updating", null);
484
+ T = requestAnimationFrame(k), $("updating", null);
453
485
  },
454
486
  () => {
455
- N("completed", i.value), h.value = !1, L.value = !0, oe(() => {
456
- if (l.value = !1, e.messagePostRender && A.value)
487
+ $("completed", i.value), v.value = !1, _.value = !0, ae(() => {
488
+ if (c.value = !1, e.messagePostRender && N.value)
457
489
  try {
458
- e.messagePostRender(A.value, i.value);
459
- } catch (b) {
460
- console.error("messagePostRender 执行失败:", b);
490
+ e.messagePostRender(N.value, i.value);
491
+ } catch (g) {
492
+ console.error("messagePostRender 执行失败:", g);
461
493
  }
462
- }), _ = null;
494
+ }), T = null;
463
495
  }
464
- ) : (p(), _ = requestAnimationFrame(S)), g();
496
+ ) : (h(), T = requestAnimationFrame(k)), m();
465
497
  };
466
- ie(
498
+ ue(
467
499
  () => e.reader,
468
500
  () => {
469
- e.reader && s();
501
+ e.reader && l();
470
502
  },
471
503
  {
472
504
  immediate: !0,
473
505
  deep: !0
474
506
  }
475
- ), ce(() => {
476
- E();
507
+ ), de(() => {
508
+ I();
477
509
  }), n({
478
- abortReader: E,
510
+ abortReader: I,
479
511
  initializeStart: u,
480
512
  initializeEnd: d
481
- }), q(() => f.value ? !0 : (!e.reader || !h || i.value, !1));
482
- const x = async () => {
513
+ }), q(() => p.value ? !0 : (!e.reader || !v || i.value, !1));
514
+ const w = async () => {
483
515
  try {
484
- const b = i.value;
485
- await je(b), r.success("复制成功");
486
- } catch (b) {
487
- console.error("复制失败:", b), r.error("复制失败");
516
+ const g = i.value;
517
+ await ze(g), r.success("复制成功");
518
+ } catch (g) {
519
+ console.error("复制失败:", g), r.error("复制失败");
488
520
  }
489
521
  };
490
- return (b, c) => (P(), J(re, { name: "fade" }, {
491
- default: F(() => [
492
- M.value ? (P(), O("div", {
522
+ return (g, o) => (P(), J(oe, { name: "fade" }, {
523
+ default: M(() => [
524
+ z.value ? (P(), L("div", {
493
525
  key: 0,
494
526
  ref_key: "refWrapperContent",
495
- ref: A,
527
+ ref: N,
496
528
  "text-16": "",
497
529
  class: "w-full h-full overflow-y-auto relative",
498
530
  "p-24px": ""
499
531
  }, [
500
- k("div", {
532
+ x("div", {
501
533
  class: "markdown-wrapper",
502
- innerHTML: M.value
503
- }, null, 8, Ee),
504
- L.value ? (P(), O("div", {
534
+ innerHTML: z.value
535
+ }, null, 8, je),
536
+ _.value ? (P(), L("div", {
505
537
  key: 0,
506
538
  class: "ai-copy-btn-wrapper",
507
- onClick: x
539
+ onClick: w
508
540
  }, [
509
- $(W, {
541
+ E(V, {
510
542
  name: "/images/svg/copy.svg",
511
543
  color: "#666666"
512
544
  }),
513
- c[0] || (c[0] = k("span", { class: "copy-text" }, "复制", -1))
514
- ])) : D("", !0)
515
- ], 512)) : D("", !0)
545
+ o[0] || (o[0] = x("span", { class: "copy-text" }, "复制", -1))
546
+ ])) : B("", !0)
547
+ ], 512)) : B("", !0)
516
548
  ]),
517
549
  _: 1
518
550
  }));
519
551
  }
520
- }, Ue = { class: "panel-header" }, $e = { class: "header-actions" }, Ae = { class: "header-title" }, Me = { class: "action-icons" }, qe = { class: "body-content" }, Fe = {
552
+ }, Ae = { class: "panel-header" }, Ee = { class: "header-actions" }, $e = { class: "header-title" }, Ue = { class: "action-icons" }, qe = { class: "body-content" }, Me = {
521
553
  key: 0,
522
554
  class: "welcome-content"
523
- }, Be = { class: "subtitle" }, De = { class: "highlight" }, Ve = { class: "quick-questions" }, We = ["onClick"], He = {
555
+ }, Fe = { class: "subtitle" }, Be = { class: "highlight" }, De = { class: "quick-questions" }, Ve = ["onClick"], We = {
524
556
  key: 1,
525
557
  class: "message-content user-content"
526
- }, Je = { class: "panel-footer" }, Qe = {
558
+ }, Je = { class: "panel-footer" }, He = {
527
559
  key: 0,
528
560
  src: ge,
529
561
  alt: "加载中",
530
562
  class: "loading-icon"
531
- }, Ke = { class: "input-box" }, Xe = ["src"], Ge = {
563
+ }, Qe = { class: "input-box" }, Ke = ["src"], Xe = {
532
564
  __name: "ChatPanel",
533
565
  props: {
534
566
  modelValue: {
@@ -551,6 +583,14 @@ const ae = (t, n) => {
551
583
  type: String,
552
584
  default: "数智AI助理"
553
585
  },
586
+ /**
587
+ * 大模型名称,对应 LLMTypes 中的 modelName
588
+ * 例如: 'szjy' | 'spark' | 'dify-openai' | 'siliconflow' 等
589
+ */
590
+ llmName: {
591
+ type: String,
592
+ default: "szjy"
593
+ },
554
594
  messagePostRender: {
555
595
  type: Function,
556
596
  default: null
@@ -558,106 +598,106 @@ const ae = (t, n) => {
558
598
  },
559
599
  emits: ["update:modelValue", "submit"],
560
600
  setup(t, { emit: n }) {
561
- const { appContext: o } = ne(), { $message: a } = o.config.globalProperties, r = ye("llmName") || "szjy", e = q(() => Re.find((m) => m.modelName === r)), i = t, v = n, h = C(""), y = C(null), L = C(!1), N = C([]), A = C([
601
+ const { appContext: a } = re(), { $message: s } = a.config.globalProperties, r = t, e = q(() => G.find((o) => o.modelName === r.llmName) ?? G.find((o) => o.modelName === "szjy")), i = n, f = C(""), v = C(null), b = C(!1), _ = C([]), $ = C([
562
602
  "什么是AI助理,能做什么?",
563
603
  "当前项目的基本情况?",
564
604
  "当前项目的进度情况?",
565
605
  "当前项目的参建方有哪些?",
566
606
  "数智建管平台有哪些功能?能做什么?"
567
- ]), _ = C([]), j = C(!1), E = C(null), M = () => {
568
- oe(() => {
569
- if (E.value) {
570
- const m = E.value, w = m.scrollHeight, T = m.scrollTop, I = m.clientHeight;
571
- w - T - I < 100 ? m.scrollTop = w : m.scrollTo({
572
- top: w
607
+ ]), N = C([]), T = C(!1), U = C(null), I = () => {
608
+ ae(() => {
609
+ if (U.value) {
610
+ const o = U.value, y = o.scrollHeight, S = o.scrollTop, O = o.clientHeight;
611
+ y - S - O < 100 ? o.scrollTop = y : o.scrollTo({
612
+ top: y
573
613
  });
574
614
  }
575
615
  });
576
- }, f = C(!1), u = q(() => f.value ? "/images/ai-stop.png" : "/images/ai-send.png"), d = (m, w) => {
577
- console.log("onFailedReader", m, w), j.value = !1;
578
- const T = b();
579
- T && T.initializeEnd(), a.error("转换失败,请重试"), f.value = !1, setTimeout(() => {
580
- y.value && y.value.focus();
616
+ }, z = C(!1), p = q(() => z.value ? "/images/ai-stop.png" : "/images/ai-send.png"), u = (o, y) => {
617
+ console.log("onFailedReader", o, y), T.value = !1;
618
+ const S = w();
619
+ S && S.initializeEnd(), s.error("转换失败,请重试"), z.value = !1, setTimeout(() => {
620
+ v.value && v.value.focus();
581
621
  });
582
- }, l = (m, w) => {
583
- j.value = !1, f.value = !1, M(), w && N.value[m] && (N.value[m].displayText = w), setTimeout(() => {
584
- y.value && y.value.focus();
622
+ }, d = (o, y) => {
623
+ T.value = !1, z.value = !1, I(), y && _.value[o] && (_.value[o].displayText = y), setTimeout(() => {
624
+ v.value && v.value.focus();
585
625
  });
586
- }, s = (m) => {
587
- f.value = !0;
588
- }, g = () => {
589
- f.value = !1, v("update:modelValue", !1), L.value = !1, N.value = [];
590
- }, p = C(!1), S = () => {
591
- p.value = !p.value;
592
- }, x = (m) => {
593
- h.value = m, c();
594
- }, b = () => {
595
- for (let m = _.value.length - 1; m >= 0; m--)
596
- if (_.value[m])
597
- return _.value[m];
626
+ }, c = (o) => {
627
+ z.value = !0;
628
+ }, l = () => {
629
+ z.value = !1, i("update:modelValue", !1), b.value = !1, _.value = [];
630
+ }, m = C(!1), h = () => {
631
+ m.value = !m.value;
632
+ }, k = (o) => {
633
+ f.value = o, g();
634
+ }, w = () => {
635
+ for (let o = N.value.length - 1; o >= 0; o--)
636
+ if (N.value[o])
637
+ return N.value[o];
598
638
  return null;
599
- }, c = async () => {
600
- if (console.log("stylizingLoading:", j.value), j.value) {
601
- const R = b();
639
+ }, g = async () => {
640
+ if (console.log("stylizingLoading:", T.value), T.value) {
641
+ const R = w();
602
642
  console.log("lastPreviewer:", R), R && (console.log("abortReader"), R.abortReader());
603
643
  return;
604
644
  }
605
- if (!h.value.trim()) {
606
- console.log("no input, return"), y.value.focus();
645
+ if (!f.value.trim()) {
646
+ console.log("no input, return"), v.value.focus();
607
647
  return;
608
648
  }
609
- N.value.push({
649
+ _.value.push({
610
650
  type: "user",
611
- content: h.value
612
- }), f.value = !0, L.value = !0, v("submit", h.value), M();
613
- const m = h.value;
614
- h.value = "";
615
- const w = N.value.length;
616
- _.value[w] && _.value[w].initializeStart(), j.value = !0, N.value.push({
651
+ content: f.value
652
+ }), z.value = !0, b.value = !0, i("submit", f.value), I();
653
+ const o = f.value;
654
+ f.value = "";
655
+ const y = _.value.length;
656
+ N.value[y] && N.value[y].initializeStart(), T.value = !0, _.value.push({
617
657
  type: "ai"
618
658
  });
619
- const { error: T, reader: I } = await Le(e.value, {
620
- text: m,
621
- token: i.token,
622
- identifier: i.identifier,
623
- baseUrl: i.baseUrl
659
+ const { error: S, reader: O } = await Pe(e.value, {
660
+ text: o,
661
+ token: r.token,
662
+ identifier: r.identifier,
663
+ baseUrl: r.baseUrl
624
664
  });
625
- if (T) {
626
- console.log(45455, T), d(w, T);
665
+ if (S) {
666
+ console.log(45455, S), u(y, S);
627
667
  return;
628
668
  }
629
- I && (N.value[w].reader = I);
669
+ O && (_.value[y].reader = O);
630
670
  };
631
- return (m, w) => {
632
- const T = X("el-icon"), I = X("el-input");
633
- return P(), J(re, { name: "slide" }, {
634
- default: F(() => [
635
- t.modelValue ? (P(), O("div", {
671
+ return (o, y) => {
672
+ const S = X("el-icon"), O = X("el-input");
673
+ return P(), J(oe, { name: "slide" }, {
674
+ default: M(() => [
675
+ t.modelValue ? (P(), L("div", {
636
676
  key: 0,
637
- class: H(["ai-panel", { "drawer-mode": p.value }])
677
+ class: W(["ai-panel", { "drawer-mode": m.value }])
638
678
  }, [
639
- k("div", Ue, [
640
- k("div", $e, [
641
- k("div", Ae, V(t.title), 1),
642
- k("div", Me, [
643
- $(T, {
679
+ x("div", Ae, [
680
+ x("div", Ee, [
681
+ x("div", $e, D(t.title), 1),
682
+ x("div", Ue, [
683
+ E(S, {
644
684
  class: "action-icon",
645
- onClick: S
685
+ onClick: h
646
686
  }, {
647
- default: F(() => [
648
- $(W, {
687
+ default: M(() => [
688
+ E(V, {
649
689
  name: "/images/svg/drawer-layout.svg",
650
690
  color: "#999999"
651
691
  })
652
692
  ]),
653
693
  _: 1
654
694
  }),
655
- $(T, {
695
+ E(S, {
656
696
  class: "action-icon",
657
- onClick: g
697
+ onClick: l
658
698
  }, {
659
- default: F(() => [
660
- $(W, {
699
+ default: M(() => [
700
+ E(V, {
661
701
  name: "/images/svg/close.svg",
662
702
  color: "#999999"
663
703
  })
@@ -667,123 +707,123 @@ const ae = (t, n) => {
667
707
  ])
668
708
  ])
669
709
  ]),
670
- k("div", qe, [
671
- L.value ? (P(), O("div", {
710
+ x("div", qe, [
711
+ b.value ? (P(), L("div", {
672
712
  key: 1,
673
713
  class: "chat-messages",
674
714
  ref_key: "messageContainerRef",
675
- ref: E
715
+ ref: U
676
716
  }, [
677
- (P(!0), O(G, null, Y(N.value, (R, U) => (P(), O("div", {
678
- key: U,
679
- class: H(["message-item", R.type === "user" ? "user-message" : "ai-message"])
717
+ (P(!0), L(Y, null, Z(_.value, (R, A) => (P(), L("div", {
718
+ key: A,
719
+ class: W(["message-item", R.type === "user" ? "user-message" : "ai-message"])
680
720
  }, [
681
721
  R.type === "ai" ? (P(), J(Ie, {
682
722
  key: 0,
683
723
  ref_for: !0,
684
- ref: (z) => _.value[U] = z,
724
+ ref: (j) => N.value[A] = j,
685
725
  reader: R.reader,
686
- "onUpdate:reader": (z) => R.reader = z,
687
- model: de(r),
726
+ "onUpdate:reader": (j) => R.reader = j,
727
+ model: r.llmName,
688
728
  displayText: R.displayText,
689
- scrollToBottomFn: M,
729
+ scrollToBottomFn: I,
690
730
  messagePostRender: t.messagePostRender,
691
- onFailed: (z) => d(U, z),
692
- onCompleted: (z) => l(U, z),
693
- onUpdating: () => s()
694
- }, null, 8, ["reader", "onUpdate:reader", "model", "displayText", "messagePostRender", "onFailed", "onCompleted", "onUpdating"])) : (P(), O("div", He, V(R.content), 1))
731
+ onFailed: (j) => u(A, j),
732
+ onCompleted: (j) => d(A, j),
733
+ onUpdating: () => c()
734
+ }, null, 8, ["reader", "onUpdate:reader", "model", "displayText", "messagePostRender", "onFailed", "onCompleted", "onUpdating"])) : (P(), L("div", We, D(R.content), 1))
695
735
  ], 2))), 128))
696
- ], 512)) : (P(), O("div", Fe, [
697
- w[2] || (w[2] = k("div", { class: "title" }, [
698
- k("img", {
699
- src: ve,
736
+ ], 512)) : (P(), L("div", Me, [
737
+ y[2] || (y[2] = x("div", { class: "title" }, [
738
+ x("img", {
739
+ src: ye,
700
740
  alt: "AI助手",
701
741
  class: "panel-icon"
702
742
  }),
703
- k("h3", { class: "title-text" }, "Hi, 您好")
743
+ x("h3", { class: "title-text" }, "Hi, 您好")
704
744
  ], -1)),
705
- k("div", Be, [
706
- w[1] || (w[1] = ue(" 我是", -1)),
707
- k("span", De, V(t.title), 1)
745
+ x("div", Fe, [
746
+ y[1] || (y[1] = fe(" 我是", -1)),
747
+ x("span", Be, D(t.title), 1)
708
748
  ]),
709
- k("div", Ve, [
710
- (P(!0), O(G, null, Y(A.value, (R, U) => (P(), O("div", {
711
- key: U,
749
+ x("div", De, [
750
+ (P(!0), L(Y, null, Z($.value, (R, A) => (P(), L("div", {
751
+ key: A,
712
752
  class: "question-item",
713
- onClick: (z) => x(R)
753
+ onClick: (j) => k(R)
714
754
  }, [
715
- k("span", null, V(R), 1),
716
- $(T, null, {
717
- default: F(() => [
718
- $(W, {
755
+ x("span", null, D(R), 1),
756
+ E(S, null, {
757
+ default: M(() => [
758
+ E(V, {
719
759
  name: "/images/svg/arrow-right.svg",
720
760
  color: "#999999"
721
761
  })
722
762
  ]),
723
763
  _: 1
724
764
  })
725
- ], 8, We))), 128))
765
+ ], 8, Ve))), 128))
726
766
  ])
727
767
  ]))
728
768
  ]),
729
- k("div", Je, [
730
- f.value ? (P(), O("img", Qe)) : D("", !0),
731
- k("div", Ke, [
732
- $(I, {
733
- modelValue: h.value,
734
- "onUpdate:modelValue": w[0] || (w[0] = (R) => h.value = R),
769
+ x("div", Je, [
770
+ z.value ? (P(), L("img", He)) : B("", !0),
771
+ x("div", Qe, [
772
+ E(O, {
773
+ modelValue: f.value,
774
+ "onUpdate:modelValue": y[0] || (y[0] = (R) => f.value = R),
735
775
  ref_key: "refInputTextString",
736
- ref: y,
776
+ ref: v,
737
777
  placeholder: "请输入您的问题",
738
778
  autofocus: "",
739
- onKeyup: fe(c, ["enter"])
779
+ onKeyup: pe(g, ["enter"])
740
780
  }, {
741
- append: F(() => [
742
- k("div", {
781
+ append: M(() => [
782
+ x("div", {
743
783
  class: "send-icon-box",
744
- onClick: c
784
+ onClick: g
745
785
  }, [
746
- k("img", {
747
- src: u.value,
786
+ x("img", {
787
+ src: p.value,
748
788
  alt: "发送",
749
789
  class: "send-icon"
750
- }, null, 8, Xe)
790
+ }, null, 8, Ke)
751
791
  ])
752
792
  ]),
753
793
  _: 1
754
794
  }, 8, ["modelValue"])
755
795
  ])
756
796
  ])
757
- ], 2)) : D("", !0)
797
+ ], 2)) : B("", !0)
758
798
  ]),
759
799
  _: 1
760
800
  });
761
801
  };
762
802
  }
763
803
  };
764
- var se = { exports: {} };
804
+ var ie = { exports: {} };
765
805
  (function(t, n) {
766
- (function(o, a) {
767
- t.exports = a();
806
+ (function(a, s) {
807
+ t.exports = s();
768
808
  })(window, function() {
769
- return function(o) {
770
- var a = {};
809
+ return function(a) {
810
+ var s = {};
771
811
  function r(e) {
772
- if (a[e]) return a[e].exports;
773
- var i = a[e] = { i: e, l: !1, exports: {} };
774
- return o[e].call(i.exports, i, i.exports, r), i.l = !0, i.exports;
812
+ if (s[e]) return s[e].exports;
813
+ var i = s[e] = { i: e, l: !1, exports: {} };
814
+ return a[e].call(i.exports, i, i.exports, r), i.l = !0, i.exports;
775
815
  }
776
- return r.m = o, r.c = a, r.d = function(e, i, v) {
777
- r.o(e, i) || Object.defineProperty(e, i, { enumerable: !0, get: v });
816
+ return r.m = a, r.c = s, r.d = function(e, i, f) {
817
+ r.o(e, i) || Object.defineProperty(e, i, { enumerable: !0, get: f });
778
818
  }, r.r = function(e) {
779
819
  typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 });
780
820
  }, r.t = function(e, i) {
781
821
  if (1 & i && (e = r(e)), 8 & i || 4 & i && typeof e == "object" && e && e.__esModule) return e;
782
- var v = /* @__PURE__ */ Object.create(null);
783
- if (r.r(v), Object.defineProperty(v, "default", { enumerable: !0, value: e }), 2 & i && typeof e != "string") for (var h in e) r.d(v, h, (function(y) {
784
- return e[y];
785
- }).bind(null, h));
786
- return v;
822
+ var f = /* @__PURE__ */ Object.create(null);
823
+ if (r.r(f), Object.defineProperty(f, "default", { enumerable: !0, value: e }), 2 & i && typeof e != "string") for (var v in e) r.d(f, v, (function(b) {
824
+ return e[b];
825
+ }).bind(null, v));
826
+ return f;
787
827
  }, r.n = function(e) {
788
828
  var i = e && e.__esModule ? function() {
789
829
  return e.default;
@@ -794,241 +834,241 @@ var se = { exports: {} };
794
834
  }, r.o = function(e, i) {
795
835
  return Object.prototype.hasOwnProperty.call(e, i);
796
836
  }, r.p = "", r(r.s = 0);
797
- }([function(o, a, r) {
798
- function e(f, u, d, l) {
799
- d.push(f), l.push([].concat(u[f] || []));
837
+ }([function(a, s, r) {
838
+ function e(p, u, d, c) {
839
+ d.push(p), c.push([].concat(u[p] || []));
800
840
  }
801
- function i(f, u) {
802
- if (!f) throw new Error("[getMaxDepsChain] dep 参数不能为空");
803
- var d = [], l = [], s = [];
804
- for (e(f, u, l, s); l.length; ) {
805
- var g = s.pop();
806
- if (g && g.length) {
807
- var p = g.shift();
808
- if (s.push(g), ~l.indexOf(p)) throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: " + p + ", mainStack: " + l);
809
- e(p, u, l, s);
810
- } else d.push([].concat(l)), l.pop();
841
+ function i(p, u) {
842
+ if (!p) throw new Error("[getMaxDepsChain] dep 参数不能为空");
843
+ var d = [], c = [], l = [];
844
+ for (e(p, u, c, l); c.length; ) {
845
+ var m = l.pop();
846
+ if (m && m.length) {
847
+ var h = m.shift();
848
+ if (l.push(m), ~c.indexOf(h)) throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: " + h + ", mainStack: " + c);
849
+ e(h, u, c, l);
850
+ } else d.push([].concat(c)), c.pop();
811
851
  }
812
- return d.reduce(function(S, x) {
813
- return x.length > S.length ? x : S;
852
+ return d.reduce(function(k, w) {
853
+ return w.length > k.length ? w : k;
814
854
  }, []);
815
855
  }
816
- function v(f) {
817
- if (!f) throw new Error("[depsParser] 入参不能为空");
856
+ function f(p) {
857
+ if (!p) throw new Error("[depsParser] 入参不能为空");
818
858
  var u = {};
819
- f.forEach(function(l) {
820
- u[l.name] = l.deps || [];
859
+ p.forEach(function(c) {
860
+ u[c.name] = c.deps || [];
821
861
  });
822
862
  var d = [];
823
- return f.forEach(function(l) {
824
- var s = i(l.name, u).length - 1;
825
- l.priority = s, d[s] = (d[s] || []).concat(l);
863
+ return p.forEach(function(c) {
864
+ var l = i(c.name, u).length - 1;
865
+ c.priority = l, d[l] = (d[l] || []).concat(c);
826
866
  }), d;
827
867
  }
828
- r.r(a), r.d(a, "loadScript", function() {
829
- return A;
830
- }), r.d(a, "loadScripts", function() {
831
- return _;
832
- }), r.d(a, "dynamicLoadScripts", function() {
833
- return j;
834
- }), r.d(a, "createScriptsLoadIterator", function() {
835
- return E;
836
- }), r.d(a, "loadScriptsQueue", function() {
837
- return M;
838
- }), r.d(a, "getMaxDepsChain", function() {
868
+ r.r(s), r.d(s, "loadScript", function() {
869
+ return N;
870
+ }), r.d(s, "loadScripts", function() {
871
+ return T;
872
+ }), r.d(s, "dynamicLoadScripts", function() {
873
+ return U;
874
+ }), r.d(s, "createScriptsLoadIterator", function() {
875
+ return I;
876
+ }), r.d(s, "loadScriptsQueue", function() {
877
+ return z;
878
+ }), r.d(s, "getMaxDepsChain", function() {
839
879
  return i;
840
- }), r.d(a, "depsParser", function() {
841
- return v;
880
+ }), r.d(s, "depsParser", function() {
881
+ return f;
842
882
  });
843
- var h = function() {
844
- return (h = Object.assign || function(f) {
845
- for (var u, d = 1, l = arguments.length; d < l; d++) for (var s in u = arguments[d]) Object.prototype.hasOwnProperty.call(u, s) && (f[s] = u[s]);
846
- return f;
883
+ var v = function() {
884
+ return (v = Object.assign || function(p) {
885
+ for (var u, d = 1, c = arguments.length; d < c; d++) for (var l in u = arguments[d]) Object.prototype.hasOwnProperty.call(u, l) && (p[l] = u[l]);
886
+ return p;
847
887
  }).apply(this, arguments);
848
- }, y = function(f, u, d, l) {
849
- return new (d || (d = Promise))(function(s, g) {
850
- function p(b) {
888
+ }, b = function(p, u, d, c) {
889
+ return new (d || (d = Promise))(function(l, m) {
890
+ function h(g) {
851
891
  try {
852
- x(l.next(b));
853
- } catch (c) {
854
- g(c);
892
+ w(c.next(g));
893
+ } catch (o) {
894
+ m(o);
855
895
  }
856
896
  }
857
- function S(b) {
897
+ function k(g) {
858
898
  try {
859
- x(l.throw(b));
860
- } catch (c) {
861
- g(c);
899
+ w(c.throw(g));
900
+ } catch (o) {
901
+ m(o);
862
902
  }
863
903
  }
864
- function x(b) {
865
- var c;
866
- b.done ? s(b.value) : (c = b.value, c instanceof d ? c : new d(function(m) {
867
- m(c);
868
- })).then(p, S);
904
+ function w(g) {
905
+ var o;
906
+ g.done ? l(g.value) : (o = g.value, o instanceof d ? o : new d(function(y) {
907
+ y(o);
908
+ })).then(h, k);
869
909
  }
870
- x((l = l.apply(f, [])).next());
910
+ w((c = c.apply(p, [])).next());
871
911
  });
872
- }, L = function(f, u) {
873
- var d, l, s, g, p = { label: 0, sent: function() {
874
- if (1 & s[0]) throw s[1];
875
- return s[1];
912
+ }, _ = function(p, u) {
913
+ var d, c, l, m, h = { label: 0, sent: function() {
914
+ if (1 & l[0]) throw l[1];
915
+ return l[1];
876
916
  }, trys: [], ops: [] };
877
- return g = { next: S(0), throw: S(1), return: S(2) }, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
917
+ return m = { next: k(0), throw: k(1), return: k(2) }, typeof Symbol == "function" && (m[Symbol.iterator] = function() {
878
918
  return this;
879
- }), g;
880
- function S(x) {
881
- return function(b) {
882
- return function(c) {
919
+ }), m;
920
+ function k(w) {
921
+ return function(g) {
922
+ return function(o) {
883
923
  if (d) throw new TypeError("Generator is already executing.");
884
- for (; p; ) try {
885
- if (d = 1, l && (s = 2 & c[0] ? l.return : c[0] ? l.throw || ((s = l.return) && s.call(l), 0) : l.next) && !(s = s.call(l, c[1])).done) return s;
886
- switch (l = 0, s && (c = [2 & c[0], s.value]), c[0]) {
924
+ for (; h; ) try {
925
+ if (d = 1, c && (l = 2 & o[0] ? c.return : o[0] ? c.throw || ((l = c.return) && l.call(c), 0) : c.next) && !(l = l.call(c, o[1])).done) return l;
926
+ switch (c = 0, l && (o = [2 & o[0], l.value]), o[0]) {
887
927
  case 0:
888
928
  case 1:
889
- s = c;
929
+ l = o;
890
930
  break;
891
931
  case 4:
892
- return p.label++, { value: c[1], done: !1 };
932
+ return h.label++, { value: o[1], done: !1 };
893
933
  case 5:
894
- p.label++, l = c[1], c = [0];
934
+ h.label++, c = o[1], o = [0];
895
935
  continue;
896
936
  case 7:
897
- c = p.ops.pop(), p.trys.pop();
937
+ o = h.ops.pop(), h.trys.pop();
898
938
  continue;
899
939
  default:
900
- if (s = p.trys, !((s = s.length > 0 && s[s.length - 1]) || c[0] !== 6 && c[0] !== 2)) {
901
- p = 0;
940
+ if (l = h.trys, !((l = l.length > 0 && l[l.length - 1]) || o[0] !== 6 && o[0] !== 2)) {
941
+ h = 0;
902
942
  continue;
903
943
  }
904
- if (c[0] === 3 && (!s || c[1] > s[0] && c[1] < s[3])) {
905
- p.label = c[1];
944
+ if (o[0] === 3 && (!l || o[1] > l[0] && o[1] < l[3])) {
945
+ h.label = o[1];
906
946
  break;
907
947
  }
908
- if (c[0] === 6 && p.label < s[1]) {
909
- p.label = s[1], s = c;
948
+ if (o[0] === 6 && h.label < l[1]) {
949
+ h.label = l[1], l = o;
910
950
  break;
911
951
  }
912
- if (s && p.label < s[2]) {
913
- p.label = s[2], p.ops.push(c);
952
+ if (l && h.label < l[2]) {
953
+ h.label = l[2], h.ops.push(o);
914
954
  break;
915
955
  }
916
- s[2] && p.ops.pop(), p.trys.pop();
956
+ l[2] && h.ops.pop(), h.trys.pop();
917
957
  continue;
918
958
  }
919
- c = u.call(f, p);
920
- } catch (m) {
921
- c = [6, m], l = 0;
959
+ o = u.call(p, h);
960
+ } catch (y) {
961
+ o = [6, y], c = 0;
922
962
  } finally {
923
- d = s = 0;
963
+ d = l = 0;
924
964
  }
925
- if (5 & c[0]) throw c[1];
926
- return { value: c[0] ? c[1] : void 0, done: !0 };
927
- }([x, b]);
965
+ if (5 & o[0]) throw o[1];
966
+ return { value: o[0] ? o[1] : void 0, done: !0 };
967
+ }([w, g]);
928
968
  };
929
969
  }
930
- }, N = function(f) {
970
+ }, $ = function(p) {
931
971
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
932
- var u, d = f[Symbol.asyncIterator];
933
- return d ? d.call(f) : (f = typeof __values == "function" ? __values(f) : f[Symbol.iterator](), u = {}, l("next"), l("throw"), l("return"), u[Symbol.asyncIterator] = function() {
972
+ var u, d = p[Symbol.asyncIterator];
973
+ return d ? d.call(p) : (p = typeof __values == "function" ? __values(p) : p[Symbol.iterator](), u = {}, c("next"), c("throw"), c("return"), u[Symbol.asyncIterator] = function() {
934
974
  return this;
935
975
  }, u);
936
- function l(s) {
937
- u[s] = f[s] && function(g) {
938
- return new Promise(function(p, S) {
939
- (function(x, b, c, m) {
940
- Promise.resolve(m).then(function(w) {
941
- x({ value: w, done: c });
942
- }, b);
943
- })(p, S, (g = f[s](g)).done, g.value);
976
+ function c(l) {
977
+ u[l] = p[l] && function(m) {
978
+ return new Promise(function(h, k) {
979
+ (function(w, g, o, y) {
980
+ Promise.resolve(y).then(function(S) {
981
+ w({ value: S, done: o });
982
+ }, g);
983
+ })(h, k, (m = p[l](m)).done, m.value);
944
984
  });
945
985
  };
946
986
  }
947
987
  };
948
- function A(f, u) {
949
- return u === void 0 && (u = !1), new Promise(function(d, l) {
950
- var s = u ? document.head : document.body, g = document.createElement("script");
951
- g.type = "text/javascript", g.src = f, g.crossOrigin = "anonymous", g.onreadystatechange = d, g.onload = d, g.onerror = l, s.appendChild(g);
988
+ function N(p, u) {
989
+ return u === void 0 && (u = !1), new Promise(function(d, c) {
990
+ var l = u ? document.head : document.body, m = document.createElement("script");
991
+ m.type = "text/javascript", m.src = p, m.crossOrigin = "anonymous", m.onreadystatechange = d, m.onload = d, m.onerror = c, l.appendChild(m);
952
992
  });
953
993
  }
954
- var _ = function(f, u) {
955
- return u === void 0 && (u = {}), y(void 0, void 0, void 0, function() {
956
- var d, l, s, g, p;
957
- return L(this, function(S) {
958
- switch (S.label) {
994
+ var T = function(p, u) {
995
+ return u === void 0 && (u = {}), b(void 0, void 0, void 0, function() {
996
+ var d, c, l, m, h;
997
+ return _(this, function(k) {
998
+ switch (k.label) {
959
999
  case 0:
960
- return d = u.baseUrl, l = d === void 0 ? "" : d, s = u.lastLoadResult, g = u.inHead, p = g !== void 0 && g, [4, Promise.all(f.map(function(x) {
961
- return y(void 0, void 0, void 0, function() {
962
- var b, c, m, w, T, I, R, U;
963
- return L(this, function(z) {
964
- switch (z.label) {
1000
+ return d = u.baseUrl, c = d === void 0 ? "" : d, l = u.lastLoadResult, m = u.inHead, h = m !== void 0 && m, [4, Promise.all(p.map(function(w) {
1001
+ return b(void 0, void 0, void 0, function() {
1002
+ var g, o, y, S, O, R, A, j;
1003
+ return _(this, function(Q) {
1004
+ switch (Q.label) {
965
1005
  case 0:
966
- return b = x.name, c = x.path, m = x.deps, (R = {})[b] = !0, w = R, (U = {})[b] = !1, T = U, window[b] ? [2, w] : [3, 1];
1006
+ return g = w.name, o = w.path, y = w.deps, (A = {})[g] = !0, S = A, (j = {})[g] = !1, O = j, window[g] ? [2, S] : [3, 1];
967
1007
  case 1:
968
- return I = !0, m && s && [].concat(m).forEach(function(le) {
969
- s[le] !== !1 && (I = !0);
970
- }), I ? [4, A(c.indexOf("http") === 0 || c.indexOf("//:") === 0 ? c : l + c, p).then(function() {
971
- return w;
1008
+ return R = !0, y && l && [].concat(y).forEach(function(ce) {
1009
+ l[ce] !== !1 && (R = !0);
1010
+ }), R ? [4, N(o.indexOf("http") === 0 || o.indexOf("//:") === 0 ? o : c + o, h).then(function() {
1011
+ return S;
972
1012
  }).catch(function() {
973
- return T;
1013
+ return O;
974
1014
  })] : [3, 3];
975
1015
  case 2:
976
- return [2, z.sent()];
1016
+ return [2, Q.sent()];
977
1017
  case 3:
978
- return [2, T];
1018
+ return [2, O];
979
1019
  }
980
1020
  });
981
1021
  });
982
1022
  }))];
983
1023
  case 1:
984
- return [2, S.sent()];
1024
+ return [2, k.sent()];
985
1025
  }
986
1026
  });
987
1027
  });
988
- }, j = function(f, u) {
1028
+ }, U = function(p, u) {
989
1029
  return u === void 0 && (u = {}), function() {
990
- var d = [].concat(v(f));
1030
+ var d = [].concat(f(p));
991
1031
  return { next: function() {
992
1032
  if (d.length) {
993
- var l = d.shift();
994
- return _(l, u).then(function(s) {
995
- return { value: s, done: !1 };
1033
+ var c = d.shift();
1034
+ return T(c, u).then(function(l) {
1035
+ return { value: l, done: !1 };
996
1036
  });
997
1037
  }
998
1038
  return Promise.resolve({ done: !0 });
999
1039
  } };
1000
1040
  };
1001
- }, E = function(f, u) {
1041
+ }, I = function(p, u) {
1002
1042
  var d;
1003
- return u === void 0 && (u = {}), (d = {})[Symbol.asyncIterator] = j(f, u), d;
1004
- }, M = function(f, u) {
1005
- return u === void 0 && (u = {}), y(void 0, void 0, void 0, function() {
1006
- var d, l, s, g, p, S;
1007
- return L(this, function(x) {
1008
- switch (x.label) {
1043
+ return u === void 0 && (u = {}), (d = {})[Symbol.asyncIterator] = U(p, u), d;
1044
+ }, z = function(p, u) {
1045
+ return u === void 0 && (u = {}), b(void 0, void 0, void 0, function() {
1046
+ var d, c, l, m, h, k;
1047
+ return _(this, function(w) {
1048
+ switch (w.label) {
1009
1049
  case 0:
1010
- x.trys.push([0, 5, 6, 11]), d = N(E(f, u)), x.label = 1;
1050
+ w.trys.push([0, 5, 6, 11]), d = $(I(p, u)), w.label = 1;
1011
1051
  case 1:
1012
1052
  return [4, d.next()];
1013
1053
  case 2:
1014
- if ((l = x.sent()).done) return [3, 4];
1015
- s = l.value, u.lastLoadResult = u.lastLoadResult || {}, console.log("current load: ", s), s.forEach(function(b) {
1016
- u.lastLoadResult = h(h({}, u.lastLoadResult), b);
1017
- }), x.label = 3;
1054
+ if ((c = w.sent()).done) return [3, 4];
1055
+ l = c.value, u.lastLoadResult = u.lastLoadResult || {}, console.log("current load: ", l), l.forEach(function(g) {
1056
+ u.lastLoadResult = v(v({}, u.lastLoadResult), g);
1057
+ }), w.label = 3;
1018
1058
  case 3:
1019
1059
  return [3, 1];
1020
1060
  case 4:
1021
1061
  return [3, 11];
1022
1062
  case 5:
1023
- return g = x.sent(), p = { error: g }, [3, 11];
1063
+ return m = w.sent(), h = { error: m }, [3, 11];
1024
1064
  case 6:
1025
- return x.trys.push([6, , 9, 10]), l && !l.done && (S = d.return) ? [4, S.call(d)] : [3, 8];
1065
+ return w.trys.push([6, , 9, 10]), c && !c.done && (k = d.return) ? [4, k.call(d)] : [3, 8];
1026
1066
  case 7:
1027
- x.sent(), x.label = 8;
1067
+ w.sent(), w.label = 8;
1028
1068
  case 8:
1029
1069
  return [3, 10];
1030
1070
  case 9:
1031
- if (p) throw p.error;
1071
+ if (h) throw h.error;
1032
1072
  return [7];
1033
1073
  case 10:
1034
1074
  return [7];
@@ -1040,16 +1080,16 @@ var se = { exports: {} };
1040
1080
  };
1041
1081
  }]);
1042
1082
  });
1043
- })(se);
1044
- var Ye = se.exports;
1083
+ })(ie);
1084
+ var Ye = ie.exports;
1045
1085
  const Ze = {
1046
1086
  key: 0,
1047
1087
  class: "ai-assistant"
1048
- }, et = {
1088
+ }, Ge = {
1049
1089
  name: "AiChat"
1050
1090
  //这个⾮常重要,就是未来你放到其他项⽬中,组件标签的名字,⽐如:<sz-workflow></sz-workflow>
1051
- }, tt = /* @__PURE__ */ pe({
1052
- ...et,
1091
+ }, et = /* @__PURE__ */ me({
1092
+ ...Ge,
1053
1093
  props: {
1054
1094
  token: {
1055
1095
  type: String,
@@ -1067,6 +1107,15 @@ const Ze = {
1067
1107
  type: String,
1068
1108
  default: "数智AI助理"
1069
1109
  },
1110
+ /**
1111
+ * 大模型名称,对应 LLMTypes 中的 modelName
1112
+ * 例如: 'szjy' | 'spark' | 'dify-openai' | 'siliconflow' 等
1113
+ * 默认使用 'szjy'
1114
+ */
1115
+ llmName: {
1116
+ type: String,
1117
+ default: "szjy"
1118
+ },
1070
1119
  /**
1071
1120
  * 消息后处理回调函数
1072
1121
  * 在 AI 消息渲染完成后调用,可用于自定义处理渲染后的内容
@@ -1079,12 +1128,12 @@ const Ze = {
1079
1128
  }
1080
1129
  },
1081
1130
  setup(t) {
1082
- const n = C(!1), o = C(!1), a = () => {
1131
+ const n = C(!1), a = C(!1), s = () => {
1083
1132
  n.value = !n.value;
1084
1133
  }, r = () => {
1085
- o.value = !0, n.value = !1;
1086
- }, e = (h) => {
1087
- console.log("用户输入:", h);
1134
+ a.value = !0, n.value = !1;
1135
+ }, e = (v) => {
1136
+ console.log("用户输入:", v);
1088
1137
  }, i = [
1089
1138
  {
1090
1139
  name: "markdownit",
@@ -1095,155 +1144,160 @@ const Ze = {
1095
1144
  path: "highlight.11.11.1.min.js"
1096
1145
  }
1097
1146
  ];
1098
- let v = {};
1147
+ let f = {};
1099
1148
  return Ye.loadScriptsQueue(i, {
1100
1149
  baseUrl: "/scripts/ai/",
1101
- lastLoadResult: v,
1150
+ lastLoadResult: f,
1102
1151
  inHead: !1
1103
- }).then((h) => {
1104
- if (console.log("load ai deps: ", h), window.markdownit) {
1105
- const y = window.markdownit();
1106
- console.log("markdownit: ", y), Ne();
1152
+ }).then((v) => {
1153
+ if (console.log("load ai deps: ", v), window.markdownit) {
1154
+ const b = window.markdownit();
1155
+ console.log("markdownit: ", b), Ne();
1107
1156
  }
1108
- }), (h, y) => o.value ? D("", !0) : (P(), O("div", Ze, [
1109
- $(Ge, {
1157
+ }), (v, b) => a.value ? B("", !0) : (P(), L("div", Ze, [
1158
+ E(Xe, {
1110
1159
  modelValue: n.value,
1111
- "onUpdate:modelValue": y[0] || (y[0] = (L) => n.value = L),
1160
+ "onUpdate:modelValue": b[0] || (b[0] = (_) => n.value = _),
1112
1161
  onSubmit: e,
1113
1162
  token: t.token,
1114
1163
  identifier: t.identifier,
1115
1164
  baseUrl: t.baseUrl,
1116
1165
  title: t.title,
1166
+ llmName: t.llmName,
1117
1167
  messagePostRender: t.messagePostRender
1118
- }, null, 8, ["modelValue", "token", "identifier", "baseUrl", "title", "messagePostRender"]),
1119
- k("div", {
1168
+ }, null, 8, ["modelValue", "token", "identifier", "baseUrl", "title", "llmName", "messagePostRender"]),
1169
+ x("div", {
1120
1170
  class: "ai-icon",
1121
- onClick: a
1171
+ onClick: s
1122
1172
  }, [
1123
- k("div", {
1173
+ x("div", {
1124
1174
  class: "close-icon",
1125
- onClick: me(r, ["stop"])
1126
- }, [...y[1] || (y[1] = [
1127
- k("svg", {
1175
+ onClick: he(r, ["stop"])
1176
+ }, [...b[1] || (b[1] = [
1177
+ x("svg", {
1128
1178
  viewBox: "0 0 1024 1024",
1129
1179
  width: "8",
1130
1180
  height: "8"
1131
1181
  }, [
1132
- k("path", {
1182
+ x("path", {
1133
1183
  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",
1134
1184
  fill: "currentColor"
1135
1185
  })
1136
1186
  ], -1)
1137
1187
  ])]),
1138
- y[2] || (y[2] = k("img", {
1139
- src: he,
1188
+ b[2] || (b[2] = x("img", {
1189
+ src: ve,
1140
1190
  alt: "AI助手"
1141
1191
  }, null, -1)),
1142
- y[3] || (y[3] = k("span", { class: "ai-icon-text" }, "AI助手", -1))
1192
+ b[3] || (b[3] = x("span", { class: "ai-icon-text" }, "AI助手", -1))
1143
1193
  ])
1144
1194
  ]));
1145
1195
  }
1146
- }), nt = /* @__PURE__ */ ae(tt, [["__scopeId", "data-v-a4639f2d"]]), te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1196
+ }), tt = /* @__PURE__ */ le(et, [["__scopeId", "data-v-9d212a48"]]), ne = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1147
1197
  __proto__: null,
1148
- SzAiChat: nt
1149
- }, Symbol.toStringTag, { value: "Module" })), Q = function(t) {
1150
- if (!Q.installed) {
1151
- Q.installed = !0;
1152
- for (let n in te) {
1153
- const o = Reflect.get(te, n);
1154
- t.component(o.name, o);
1198
+ SzAiChat: tt
1199
+ }, Symbol.toStringTag, { value: "Module" })), H = function(t) {
1200
+ if (!H.installed) {
1201
+ H.installed = !0;
1202
+ for (let n in ne) {
1203
+ const a = Reflect.get(ne, n);
1204
+ t.component(a.name, a);
1155
1205
  }
1156
1206
  }
1157
- }, rt = (t) => {
1207
+ }, nt = (t) => {
1158
1208
  console.log(`点击了路由链接: ${t}`);
1159
- }, ot = {
1209
+ }, rt = {
1160
1210
  color: "#536fec",
1161
1211
  fontWeight: "bold",
1162
1212
  textDecoration: "underline",
1163
1213
  cursor: "pointer",
1164
1214
  padding: "0 3px"
1165
- }, at = (t) => {
1166
- const n = /#router:([^#]+)#/g, o = [];
1167
- let a = 0, r;
1215
+ }, ot = (t) => {
1216
+ const n = /#router:([^#]+)#/g, a = [];
1217
+ let s = 0, r;
1168
1218
  for (; (r = n.exec(t)) !== null; ) {
1169
- r.index > a && o.push({ text: t.substring(a, r.index) });
1219
+ r.index > s && a.push({ text: t.substring(s, r.index) });
1170
1220
  const e = r[1];
1171
- o.push({ text: e, routeName: e }), a = n.lastIndex;
1221
+ a.push({ text: e, routeName: e }), s = n.lastIndex;
1172
1222
  }
1173
- return a < t.length && o.push({ text: t.substring(a) }), o;
1174
- }, st = (t, n, o = {}) => {
1175
- const { onRouteClick: a = rt, linkStyle: r = {} } = o, e = document.createElement("a");
1223
+ return s < t.length && a.push({ text: t.substring(s) }), a;
1224
+ }, at = (t, n, a = {}) => {
1225
+ const { onRouteClick: s = nt, linkStyle: r = {} } = a, e = document.createElement("a");
1176
1226
  e.href = "#", e.textContent = t;
1177
- const i = { ...ot, ...r };
1178
- return Object.assign(e.style, i), e.addEventListener("click", (v) => {
1179
- v.preventDefault(), a(n);
1227
+ const i = { ...rt, ...r };
1228
+ return Object.assign(e.style, i), e.addEventListener("click", (f) => {
1229
+ f.preventDefault(), s(n);
1180
1230
  }), e;
1181
- }, lt = (t) => {
1182
- const n = /#router:([^#]+)#/g, o = [], a = document.createTreeWalker(
1231
+ }, st = (t) => {
1232
+ const n = /#router:([^#]+)#/g, a = [], s = document.createTreeWalker(
1183
1233
  t,
1184
1234
  NodeFilter.SHOW_TEXT,
1185
1235
  null
1186
1236
  );
1187
- let r = a.nextNode();
1237
+ let r = s.nextNode();
1188
1238
  for (; r; ) {
1189
1239
  const e = r, i = e.textContent || "";
1190
1240
  if (n.test(i)) {
1191
1241
  n.lastIndex = 0;
1192
- const v = at(i);
1193
- v.length > 0 && o.push({ node: e, replacements: v });
1242
+ const f = ot(i);
1243
+ f.length > 0 && a.push({ node: e, replacements: f });
1194
1244
  }
1195
- r = a.nextNode();
1245
+ r = s.nextNode();
1196
1246
  }
1197
- return o;
1198
- }, dt = (t, n, o = {}) => {
1199
- lt(t).forEach(({ node: r, replacements: e }) => {
1200
- var v;
1247
+ return a;
1248
+ }, ut = (t, n, a = {}) => {
1249
+ const s = st(t);
1250
+ s.forEach(({ node: r, replacements: e }) => {
1251
+ var f;
1201
1252
  const i = document.createDocumentFragment();
1202
- e.forEach(({ text: h, routeName: y }) => {
1203
- if (y) {
1204
- const L = st(h, y, o);
1205
- i.appendChild(L);
1253
+ e.forEach(({ text: v, routeName: b }) => {
1254
+ if (b) {
1255
+ const _ = at(v, b, a);
1256
+ i.appendChild(_);
1206
1257
  } else
1207
- i.appendChild(document.createTextNode(h));
1208
- }), (v = r.parentNode) == null || v.replaceChild(i, r);
1258
+ i.appendChild(document.createTextNode(v));
1259
+ }), (f = r.parentNode) == null || f.replaceChild(i, r);
1260
+ }), a != null && a.nodeCallback && s.forEach(({ node: r, replacements: e }) => {
1261
+ var i;
1262
+ (i = a.nodeCallback) == null || i.call(a, r, e);
1209
1263
  });
1210
- }, it = "0.1.3", ct = "Sz";
1211
- function ft({
1212
- componentPrefix: t = ct,
1264
+ }, lt = "0.1.5", it = "Sz";
1265
+ function dt({
1266
+ componentPrefix: t = it,
1213
1267
  components: n = []
1214
1268
  } = {}) {
1215
- const o = [];
1216
- function a(e, i, v) {
1269
+ const a = [];
1270
+ function s(e, i, f) {
1217
1271
  e.component(t + i) || e.component(
1218
1272
  t + i,
1219
- v
1273
+ f
1220
1274
  );
1221
1275
  }
1222
1276
  function r(e) {
1223
- o.includes(e) || (o.push(e), n.forEach((i) => {
1224
- const { name: v, alias: h } = i;
1225
- a(e, v, i), h && h.forEach((y) => {
1226
- a(e, y, i);
1277
+ a.includes(e) || (a.push(e), n.forEach((i) => {
1278
+ const { name: f, alias: v } = i;
1279
+ s(e, f, i), v && v.forEach((b) => {
1280
+ s(e, b, i);
1227
1281
  });
1228
1282
  }));
1229
1283
  }
1230
1284
  return {
1231
- version: it,
1285
+ version: lt,
1232
1286
  componentPrefix: t,
1233
1287
  install: r
1234
1288
  };
1235
1289
  }
1236
- const pt = {
1290
+ const ft = {
1237
1291
  install(t) {
1238
- Q(t);
1292
+ H(t);
1239
1293
  }
1240
1294
  };
1241
1295
  export {
1242
- nt as SzAiChat,
1243
- ft as create,
1244
- st as createRouteLink,
1245
- pt as default,
1246
- lt as findRouteTextNodes,
1247
- at as parseRouteMarkers,
1248
- dt as routeLinkRender
1296
+ tt as SzAiChat,
1297
+ dt as create,
1298
+ at as createRouteLink,
1299
+ ft as default,
1300
+ st as findRouteTextNodes,
1301
+ ot as parseRouteMarkers,
1302
+ ut as routeLinkRender
1249
1303
  };