@szjy/ai-coms 0.1.6 → 0.1.8

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