@szjy/ai-coms 0.1.4 → 0.1.6

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 A, 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`), l = 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(l);
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",
@@ -58,12 +82,12 @@ async function xe(t, n) {
58
82
  });
59
83
  return fetch(r);
60
84
  }
61
- 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]);
85
+ async function Se(t, n) {
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",
@@ -83,12 +107,12 @@ async function ke(t, n) {
83
107
  });
84
108
  return fetch(r);
85
109
  }
86
- 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]);
110
+ async function ke(t, n) {
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`), l = {};
168
+ Object.keys(l).forEach((m) => {
169
+ e.searchParams.append(m, l[m]);
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,9 +178,9 @@ 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
- const Te = (t) => {
183
+ const Re = (t) => {
160
184
  if (t.startsWith("data:")) {
161
185
  const n = t.substring(5).trim();
162
186
  if (n === "[DONE]")
@@ -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",
@@ -189,12 +213,12 @@ const Te = (t) => {
189
213
  {
190
214
  label: "SiliconFlow 硅基流动大模型",
191
215
  modelName: "siliconflow",
192
- api: ke
216
+ api: Se
193
217
  },
194
218
  {
195
219
  label: "Kimi Moonshot 月之暗面大模型",
196
220
  modelName: "moonshot",
197
- api: Se
221
+ api: ke
198
222
  },
199
223
  {
200
224
  label: "通义千问大模型",
@@ -205,18 +229,23 @@ 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) {
219
- const n = Te(t);
248
+ const n = Re(t);
220
249
  return n.done ? {
221
250
  done: !0
222
251
  } : {
@@ -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
+ }, Te = (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(Te(`
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,19 +386,19 @@ 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, l) => (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"]]), Ee = 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 {
@@ -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 E = q(() => B ? B.render(i.value) : i.value), j = () => {
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(() => `${E.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, l = C(e.displayText || ""), f = C(""), m = C(!0), b = C(!1), _ = C(!!e.displayText), I = a, N = C(null);
427
+ let R = null;
428
+ const U = q(() => F ? F.render(l.value) : l.value), E = () => {
429
+ e.reader && e.reader.cancel(), b.value = !0, c.value = !1, d(), _.value = !0, I("completed", l.value), m.value = !1, R && (cancelAnimationFrame(R), R = 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), i = 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 (m.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 k = ee[e.model];
453
+ if (!k)
422
454
  break;
423
- const T = w.call(Z, c, b);
424
- if (T.done) {
425
- l.value = !0;
455
+ const O = k.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), j();
460
+ f.value += O.content, R === null && S();
461
+ } catch (o) {
462
+ c.value = !0, console.log(3333, o), I("failed", o), E();
431
463
  break;
432
464
  } finally {
433
465
  d();
434
466
  }
435
- }, g = async () => {
467
+ }, h = async () => {
436
468
  e.scrollToBottomFn && e.scrollToBottomFn();
437
- }, p = (b = () => {
438
- }, c = () => {
469
+ }, v = (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
+ l.value += y, f.value = f.value.substring(10), g();
443
475
  } else
444
- c();
476
+ o();
445
477
  }, S = () => {
446
- if (y.value && _) {
447
- cancelAnimationFrame(_), _ = null, h.value = !1;
478
+ if (b.value && R) {
479
+ cancelAnimationFrame(R), R = null, m.value = !1;
448
480
  return;
449
481
  }
450
- l.value ? p(
482
+ c.value ? v(
451
483
  () => {
452
- _ = requestAnimationFrame(S), N("updating", null);
484
+ R = requestAnimationFrame(S), I("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
+ I("completed", l.value), m.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, l.value);
491
+ } catch (g) {
492
+ console.error("messagePostRender 执行失败:", g);
461
493
  }
462
- }), _ = null;
494
+ }), R = null;
463
495
  }
464
- ) : (p(), _ = requestAnimationFrame(S)), g();
496
+ ) : (v(), R = requestAnimationFrame(S)), h();
465
497
  };
466
- ie(
498
+ ue(
467
499
  () => e.reader,
468
500
  () => {
469
- e.reader && s();
501
+ e.reader && i();
470
502
  },
471
503
  {
472
504
  immediate: !0,
473
505
  deep: !0
474
506
  }
475
- ), ce(() => {
476
- j();
507
+ ), de(() => {
508
+ E();
477
509
  }), n({
478
- abortReader: j,
510
+ abortReader: E,
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 || !m || l.value, !1));
514
+ const w = async () => {
483
515
  try {
484
- const b = i.value;
485
- await Ee(b), r.success("复制成功");
486
- } catch (b) {
487
- console.error("复制失败:", b), r.error("复制失败");
516
+ const g = l.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
534
+ innerHTML: z.value
503
535
  }, null, 8, je),
504
- L.value ? (P(), O("div", {
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
+ A(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
+ }, Ee = { class: "panel-header" }, $e = { class: "header-actions" }, Ae = { 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")), l = n, f = C(""), m = C(null), b = C(!1), _ = C([]), I = C([
562
602
  "什么是AI助理,能做什么?",
563
603
  "当前项目的基本情况?",
564
604
  "当前项目的进度情况?",
565
605
  "当前项目的参建方有哪些?",
566
606
  "数智建管平台有哪些功能?能做什么?"
567
- ]), _ = C([]), E = C(!1), j = C(null), M = () => {
568
- oe(() => {
569
- if (j.value) {
570
- const m = j.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([]), R = C(!1), U = C(null), E = () => {
608
+ ae(() => {
609
+ if (U.value) {
610
+ const o = U.value, y = o.scrollHeight, k = o.scrollTop, O = o.clientHeight;
611
+ y - k - 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), E.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), R.value = !1;
618
+ const k = w();
619
+ k && k.initializeEnd(), s.error("转换失败,请重试"), z.value = !1, setTimeout(() => {
620
+ m.value && m.value.focus();
581
621
  });
582
- }, l = (m, w) => {
583
- E.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
+ R.value = !1, z.value = !1, E(), y && _.value[o] && (_.value[o].displayText = y), setTimeout(() => {
624
+ m.value && m.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
+ }, i = () => {
629
+ z.value = !1, l("update:modelValue", !1), b.value = !1, _.value = [];
630
+ }, h = C(!1), v = () => {
631
+ h.value = !h.value;
632
+ }, S = (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:", E.value), E.value) {
601
- const R = b();
602
- console.log("lastPreviewer:", R), R && (console.log("abortReader"), R.abortReader());
639
+ }, g = async () => {
640
+ if (console.log("stylizingLoading:", R.value), R.value) {
641
+ const T = w();
642
+ console.log("lastPreviewer:", T), T && (console.log("abortReader"), T.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"), m.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(), E.value = !0, N.value.push({
651
+ content: f.value
652
+ }), z.value = !0, b.value = !0, l("submit", f.value), E();
653
+ const o = f.value;
654
+ f.value = "";
655
+ const y = _.value.length;
656
+ N.value[y] && N.value[y].initializeStart(), R.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: k, 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 (k) {
666
+ console.log(45455, k), u(y, k);
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 k = 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": h.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", Ee, [
680
+ x("div", $e, [
681
+ x("div", Ae, D(t.title), 1),
682
+ x("div", Ue, [
683
+ A(k, {
644
684
  class: "action-icon",
645
- onClick: S
685
+ onClick: v
646
686
  }, {
647
- default: F(() => [
648
- $(W, {
687
+ default: M(() => [
688
+ A(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
+ A(k, {
656
696
  class: "action-icon",
657
- onClick: g
697
+ onClick: i
658
698
  }, {
659
- default: F(() => [
660
- $(W, {
699
+ default: M(() => [
700
+ A(V, {
661
701
  name: "/images/svg/close.svg",
662
702
  color: "#999999"
663
703
  })
@@ -667,315 +707,315 @@ 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: j
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, (T, $) => (P(), L("div", {
718
+ key: $,
719
+ class: W(["message-item", T.type === "user" ? "user-message" : "ai-message"])
680
720
  }, [
681
- R.type === "ai" ? (P(), J(Ie, {
721
+ T.type === "ai" ? (P(), J(Ie, {
682
722
  key: 0,
683
723
  ref_for: !0,
684
- ref: (z) => _.value[U] = z,
685
- reader: R.reader,
686
- "onUpdate:reader": (z) => R.reader = z,
687
- model: de(r),
688
- displayText: R.displayText,
689
- scrollToBottomFn: M,
724
+ ref: (j) => N.value[$] = j,
725
+ reader: T.reader,
726
+ "onUpdate:reader": (j) => T.reader = j,
727
+ model: r.llmName,
728
+ displayText: T.displayText,
729
+ scrollToBottomFn: E,
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($, j),
732
+ onCompleted: (j) => d($, j),
733
+ onUpdating: () => c()
734
+ }, null, 8, ["reader", "onUpdate:reader", "model", "displayText", "messagePostRender", "onFailed", "onCompleted", "onUpdating"])) : (P(), L("div", We, D(T.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(I.value, (T, $) => (P(), L("div", {
751
+ key: $,
712
752
  class: "question-item",
713
- onClick: (z) => x(R)
753
+ onClick: (j) => S(T)
714
754
  }, [
715
- k("span", null, V(R), 1),
716
- $(T, null, {
717
- default: F(() => [
718
- $(W, {
755
+ x("span", null, D(T), 1),
756
+ A(k, null, {
757
+ default: M(() => [
758
+ A(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
+ A(O, {
773
+ modelValue: f.value,
774
+ "onUpdate:modelValue": y[0] || (y[0] = (T) => f.value = T),
735
775
  ref_key: "refInputTextString",
736
- ref: y,
776
+ ref: m,
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 l = s[e] = { i: e, l: !1, exports: {} };
814
+ return a[e].call(l.exports, l, l.exports, r), l.l = !0, l.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, l, f) {
817
+ r.o(e, l) || Object.defineProperty(e, l, { 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
- }, r.t = function(e, i) {
781
- 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;
820
+ }, r.t = function(e, l) {
821
+ if (1 & l && (e = r(e)), 8 & l || 4 & l && typeof e == "object" && e && e.__esModule) return e;
822
+ var f = /* @__PURE__ */ Object.create(null);
823
+ if (r.r(f), Object.defineProperty(f, "default", { enumerable: !0, value: e }), 2 & l && typeof e != "string") for (var m in e) r.d(f, m, (function(b) {
824
+ return e[b];
825
+ }).bind(null, m));
826
+ return f;
787
827
  }, r.n = function(e) {
788
- var i = e && e.__esModule ? function() {
828
+ var l = e && e.__esModule ? function() {
789
829
  return e.default;
790
830
  } : function() {
791
831
  return e;
792
832
  };
793
- return r.d(i, "a", i), i;
794
- }, r.o = function(e, i) {
795
- return Object.prototype.hasOwnProperty.call(e, i);
833
+ return r.d(l, "a", l), l;
834
+ }, r.o = function(e, l) {
835
+ return Object.prototype.hasOwnProperty.call(e, l);
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 l(p, u) {
842
+ if (!p) throw new Error("[getMaxDepsChain] dep 参数不能为空");
843
+ var d = [], c = [], i = [];
844
+ for (e(p, u, c, i); c.length; ) {
845
+ var h = i.pop();
846
+ if (h && h.length) {
847
+ var v = h.shift();
848
+ if (i.push(h), ~c.indexOf(v)) throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: " + v + ", mainStack: " + c);
849
+ e(v, u, c, i);
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(S, w) {
853
+ return w.length > S.length ? w : S;
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 i = l(c.name, u).length - 1;
865
+ c.priority = i, d[i] = (d[i] || []).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() {
868
+ r.r(s), r.d(s, "loadScript", function() {
869
+ return N;
870
+ }), r.d(s, "loadScripts", function() {
871
+ return R;
872
+ }), r.d(s, "dynamicLoadScripts", function() {
873
+ return U;
874
+ }), r.d(s, "createScriptsLoadIterator", function() {
833
875
  return E;
834
- }), r.d(a, "createScriptsLoadIterator", function() {
835
- return j;
836
- }), r.d(a, "loadScriptsQueue", function() {
837
- return M;
838
- }), r.d(a, "getMaxDepsChain", function() {
839
- return i;
840
- }), r.d(a, "depsParser", function() {
841
- return v;
876
+ }), r.d(s, "loadScriptsQueue", function() {
877
+ return z;
878
+ }), r.d(s, "getMaxDepsChain", function() {
879
+ return l;
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 m = function() {
884
+ return (m = Object.assign || function(p) {
885
+ for (var u, d = 1, c = arguments.length; d < c; d++) for (var i in u = arguments[d]) Object.prototype.hasOwnProperty.call(u, i) && (p[i] = u[i]);
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(i, h) {
890
+ function v(g) {
851
891
  try {
852
- x(l.next(b));
853
- } catch (c) {
854
- g(c);
892
+ w(c.next(g));
893
+ } catch (o) {
894
+ h(o);
855
895
  }
856
896
  }
857
- function S(b) {
897
+ function S(g) {
858
898
  try {
859
- x(l.throw(b));
860
- } catch (c) {
861
- g(c);
899
+ w(c.throw(g));
900
+ } catch (o) {
901
+ h(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 ? i(g.value) : (o = g.value, o instanceof d ? o : new d(function(y) {
907
+ y(o);
908
+ })).then(v, S);
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, i, h, v = { label: 0, sent: function() {
914
+ if (1 & i[0]) throw i[1];
915
+ return i[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 h = { next: S(0), throw: S(1), return: S(2) }, typeof Symbol == "function" && (h[Symbol.iterator] = function() {
878
918
  return this;
879
- }), g;
880
- function S(x) {
881
- return function(b) {
882
- return function(c) {
919
+ }), h;
920
+ function S(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 (; v; ) try {
925
+ if (d = 1, c && (i = 2 & o[0] ? c.return : o[0] ? c.throw || ((i = c.return) && i.call(c), 0) : c.next) && !(i = i.call(c, o[1])).done) return i;
926
+ switch (c = 0, i && (o = [2 & o[0], i.value]), o[0]) {
887
927
  case 0:
888
928
  case 1:
889
- s = c;
929
+ i = o;
890
930
  break;
891
931
  case 4:
892
- return p.label++, { value: c[1], done: !1 };
932
+ return v.label++, { value: o[1], done: !1 };
893
933
  case 5:
894
- p.label++, l = c[1], c = [0];
934
+ v.label++, c = o[1], o = [0];
895
935
  continue;
896
936
  case 7:
897
- c = p.ops.pop(), p.trys.pop();
937
+ o = v.ops.pop(), v.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 (i = v.trys, !((i = i.length > 0 && i[i.length - 1]) || o[0] !== 6 && o[0] !== 2)) {
941
+ v = 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 && (!i || o[1] > i[0] && o[1] < i[3])) {
945
+ v.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 && v.label < i[1]) {
949
+ v.label = i[1], i = o;
910
950
  break;
911
951
  }
912
- if (s && p.label < s[2]) {
913
- p.label = s[2], p.ops.push(c);
952
+ if (i && v.label < i[2]) {
953
+ v.label = i[2], v.ops.push(o);
914
954
  break;
915
955
  }
916
- s[2] && p.ops.pop(), p.trys.pop();
956
+ i[2] && v.ops.pop(), v.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, v);
960
+ } catch (y) {
961
+ o = [6, y], c = 0;
922
962
  } finally {
923
- d = s = 0;
963
+ d = i = 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
+ }, I = 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(i) {
977
+ u[i] = p[i] && function(h) {
978
+ return new Promise(function(v, S) {
979
+ (function(w, g, o, y) {
980
+ Promise.resolve(y).then(function(k) {
981
+ w({ value: k, done: o });
982
+ }, g);
983
+ })(v, S, (h = p[i](h)).done, h.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 i = u ? document.head : document.body, h = document.createElement("script");
991
+ h.type = "text/javascript", h.src = p, h.crossOrigin = "anonymous", h.onreadystatechange = d, h.onload = d, h.onerror = c, i.appendChild(h);
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) {
994
+ var R = function(p, u) {
995
+ return u === void 0 && (u = {}), b(void 0, void 0, void 0, function() {
996
+ var d, c, i, h, v;
997
+ return _(this, function(S) {
958
998
  switch (S.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, i = u.lastLoadResult, h = u.inHead, v = h !== void 0 && h, [4, Promise.all(p.map(function(w) {
1001
+ return b(void 0, void 0, void 0, function() {
1002
+ var g, o, y, k, O, T, $, 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, ($ = {})[g] = !0, k = $, (j = {})[g] = !1, O = j, window[g] ? [2, k] : [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 T = !0, y && i && [].concat(y).forEach(function(ce) {
1009
+ i[ce] !== !1 && (T = !0);
1010
+ }), T ? [4, N(o.indexOf("http") === 0 || o.indexOf("//:") === 0 ? o : c + o, v).then(function() {
1011
+ return k;
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
  });
@@ -985,50 +1025,50 @@ var se = { exports: {} };
985
1025
  }
986
1026
  });
987
1027
  });
988
- }, E = 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 R(c, u).then(function(i) {
1035
+ return { value: i, done: !1 };
996
1036
  });
997
1037
  }
998
1038
  return Promise.resolve({ done: !0 });
999
1039
  } };
1000
1040
  };
1001
- }, j = function(f, u) {
1041
+ }, E = function(p, u) {
1002
1042
  var d;
1003
- return u === void 0 && (u = {}), (d = {})[Symbol.asyncIterator] = E(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, i, h, v, S;
1047
+ return _(this, function(w) {
1048
+ switch (w.label) {
1009
1049
  case 0:
1010
- x.trys.push([0, 5, 6, 11]), d = N(j(f, u)), x.label = 1;
1050
+ w.trys.push([0, 5, 6, 11]), d = I(E(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
+ i = c.value, u.lastLoadResult = u.lastLoadResult || {}, console.log("current load: ", i), i.forEach(function(g) {
1056
+ u.lastLoadResult = m(m({}, 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 h = w.sent(), v = { error: h }, [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 && (S = d.return) ? [4, S.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 (v) throw v.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,13 +1128,13 @@ 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);
1088
- }, i = [
1134
+ a.value = !0, n.value = !1;
1135
+ }, e = (m) => {
1136
+ console.log("用户输入:", m);
1137
+ }, l = [
1089
1138
  {
1090
1139
  name: "markdownit",
1091
1140
  path: "markdown-it.min.js"
@@ -1095,67 +1144,77 @@ const Ze = {
1095
1144
  path: "highlight.11.11.1.min.js"
1096
1145
  }
1097
1146
  ];
1098
- let v = {};
1099
- return Ye.loadScriptsQueue(i, {
1147
+ let f = {};
1148
+ return Ye.loadScriptsQueue(l, {
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((m) => {
1153
+ if (console.log("load ai deps: ", m), 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
+ }), (m, b) => a.value ? B("", !0) : (P(), L("div", Ze, [
1158
+ A(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
  }
1207
+ }, nt = (t, n) => {
1208
+ const a = n ? `?${new URLSearchParams(n).toString()}` : "";
1209
+ console.log(`点击了路由链接: ${t}${a}`);
1157
1210
  }, rt = (t) => {
1158
- console.log(`点击了路由链接: ${t}`);
1211
+ const n = t.indexOf("?");
1212
+ if (n === -1)
1213
+ return { routeName: t };
1214
+ const a = t.substring(0, n), s = t.substring(n + 1), r = {};
1215
+ return new URLSearchParams(s).forEach((l, f) => {
1216
+ r[f] = l;
1217
+ }), { routeName: a, queryParams: Object.keys(r).length > 0 ? r : void 0 };
1159
1218
  }, ot = {
1160
1219
  color: "#536fec",
1161
1220
  fontWeight: "bold",
@@ -1163,71 +1222,71 @@ const Ze = {
1163
1222
  cursor: "pointer",
1164
1223
  padding: "0 3px"
1165
1224
  }, at = (t) => {
1166
- const n = /#router:([^#]+)#/g, o = [];
1167
- let a = 0, r;
1225
+ const n = /#router:([^#]+)#/g, a = [];
1226
+ let s = 0, r;
1168
1227
  for (; (r = n.exec(t)) !== null; ) {
1169
- r.index > a && o.push({ text: t.substring(a, r.index) });
1170
- const e = r[1];
1171
- o.push({ text: e, routeName: e }), a = n.lastIndex;
1228
+ r.index > s && a.push({ text: t.substring(s, r.index) });
1229
+ const e = r[1], { routeName: l, queryParams: f } = rt(e);
1230
+ a.push({ text: l, routeName: l, queryParams: f }), s = n.lastIndex;
1172
1231
  }
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");
1176
- 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);
1180
- }), e;
1232
+ return s < t.length && a.push({ text: t.substring(s) }), a;
1233
+ }, st = (t, n, a = {}, s) => {
1234
+ const { onRouteClick: r = nt, linkStyle: e = {} } = a, l = document.createElement("a");
1235
+ l.href = "#", l.textContent = t;
1236
+ const f = { ...ot, ...e };
1237
+ return Object.assign(l.style, f), l.addEventListener("click", (m) => {
1238
+ m.preventDefault(), r(n, s);
1239
+ }), l;
1181
1240
  }, lt = (t) => {
1182
- const n = /#router:([^#]+)#/g, o = [], a = document.createTreeWalker(
1241
+ const n = /#router:([^#]+)#/g, a = [], s = document.createTreeWalker(
1183
1242
  t,
1184
1243
  NodeFilter.SHOW_TEXT,
1185
1244
  null
1186
1245
  );
1187
- let r = a.nextNode();
1246
+ let r = s.nextNode();
1188
1247
  for (; r; ) {
1189
- const e = r, i = e.textContent || "";
1190
- if (n.test(i)) {
1248
+ const e = r, l = e.textContent || "";
1249
+ if (n.test(l)) {
1191
1250
  n.lastIndex = 0;
1192
- const v = at(i);
1193
- v.length > 0 && o.push({ node: e, replacements: v });
1251
+ const f = at(l);
1252
+ f.length > 0 && a.push({ node: e, replacements: f });
1194
1253
  }
1195
- r = a.nextNode();
1254
+ r = s.nextNode();
1196
1255
  }
1197
- return o;
1198
- }, dt = (t, n, o = {}) => {
1199
- const a = lt(t);
1200
- a.forEach(({ node: r, replacements: e }) => {
1201
- var v;
1202
- const i = document.createDocumentFragment();
1203
- e.forEach(({ text: h, routeName: y }) => {
1204
- if (y) {
1205
- const L = st(h, y, o);
1206
- i.appendChild(L);
1256
+ return a;
1257
+ }, dt = (t, n, a = {}) => {
1258
+ const s = lt(t);
1259
+ s.forEach(({ node: r, replacements: e }) => {
1260
+ var f;
1261
+ const l = document.createDocumentFragment();
1262
+ e.forEach(({ text: m, routeName: b, queryParams: _ }) => {
1263
+ if (b) {
1264
+ const I = st(m, b, a, _);
1265
+ l.appendChild(I);
1207
1266
  } else
1208
- i.appendChild(document.createTextNode(h));
1209
- }), (v = r.parentNode) == null || v.replaceChild(i, r);
1210
- }), o != null && o.nodeCallback && a.forEach(({ node: r, replacements: e }) => {
1211
- var i;
1212
- (i = o.nodeCallback) == null || i.call(o, r, e);
1267
+ l.appendChild(document.createTextNode(m));
1268
+ }), (f = r.parentNode) == null || f.replaceChild(l, r);
1269
+ }), a != null && a.nodeCallback && s.forEach(({ node: r, replacements: e }) => {
1270
+ var l;
1271
+ (l = a.nodeCallback) == null || l.call(a, r, e);
1213
1272
  });
1214
- }, it = "0.1.4", ct = "Sz";
1273
+ }, it = "0.1.6", ct = "Sz";
1215
1274
  function ft({
1216
1275
  componentPrefix: t = ct,
1217
1276
  components: n = []
1218
1277
  } = {}) {
1219
- const o = [];
1220
- function a(e, i, v) {
1221
- e.component(t + i) || e.component(
1222
- t + i,
1223
- v
1278
+ const a = [];
1279
+ function s(e, l, f) {
1280
+ e.component(t + l) || e.component(
1281
+ t + l,
1282
+ f
1224
1283
  );
1225
1284
  }
1226
1285
  function r(e) {
1227
- o.includes(e) || (o.push(e), n.forEach((i) => {
1228
- const { name: v, alias: h } = i;
1229
- a(e, v, i), h && h.forEach((y) => {
1230
- a(e, y, i);
1286
+ a.includes(e) || (a.push(e), n.forEach((l) => {
1287
+ const { name: f, alias: m } = l;
1288
+ s(e, f, l), m && m.forEach((b) => {
1289
+ s(e, b, l);
1231
1290
  });
1232
1291
  }));
1233
1292
  }
@@ -1239,15 +1298,16 @@ function ft({
1239
1298
  }
1240
1299
  const pt = {
1241
1300
  install(t) {
1242
- Q(t);
1301
+ H(t);
1243
1302
  }
1244
1303
  };
1245
1304
  export {
1246
- nt as SzAiChat,
1305
+ tt as SzAiChat,
1247
1306
  ft as create,
1248
1307
  st as createRouteLink,
1249
1308
  pt as default,
1250
1309
  lt as findRouteTextNodes,
1310
+ rt as parseRouteMarkerContent,
1251
1311
  at as parseRouteMarkers,
1252
1312
  dt as routeLinkRender
1253
1313
  };