st-comp 0.0.254 → 0.0.256

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.
@@ -1,15 +1,15 @@
1
- import { b as Z, p as q, e as ee, u as te, c as se, n as ae, _ as oe, w as ne } from "./base-29f73b05.js";
2
- import { E as ie } from "./el-dialog-eedcfd3e.js";
1
+ import { b as se, p as q, e as ae, u as ne, c as oe, n as re, _ as ie, w as le } from "./base-29f73b05.js";
2
+ import { E as ce } from "./el-dialog-eedcfd3e.js";
3
3
  import "./el-overlay-1ee0338d.js";
4
- import { E as re } from "./el-button-e2c63c08.js";
5
- import { E as le } from "./el-input-d47281da.js";
6
- import { defineComponent as J, ref as b, computed as $, watch as W, openBlock as v, createElementBlock as k, normalizeClass as X, unref as D, normalizeStyle as O, createBlock as R, withCtx as V, resolveDynamicComponent as ce, renderSlot as ue, inject as de, reactive as me, nextTick as I, Fragment as Y, createVNode as S, createElementVNode as t, renderList as pe, toDisplayString as K, createCommentVNode as x, createTextVNode as L, pushScopeId as fe, popScopeId as ve } from "vue";
7
- import { d as z } from "./dayjs.min-8313b006.js";
8
- import { V as _e } from "./index-7ed0999e.js";
9
- import { E as ge, u as he, s as U, p as be } from "./index-c2b9bbfd.js";
10
- import { _ as ke } from "./_plugin-vue_export-helper-dad06003.js";
11
- import { E as B } from "./index-f30561d3.js";
12
- import { k as ye, i as Te } from "./use-form-common-props-cb0ca65c.js";
4
+ import { E as ue } from "./el-button-e2c63c08.js";
5
+ import { E as de } from "./el-input-d47281da.js";
6
+ import { defineComponent as X, ref as T, computed as L, watch as G, openBlock as f, createElementBlock as _, normalizeClass as Q, unref as V, normalizeStyle as R, createBlock as K, withCtx as P, resolveDynamicComponent as me, renderSlot as pe, inject as fe, reactive as ve, nextTick as I, Fragment as A, createVNode as E, createElementVNode as n, renderList as ge, toDisplayString as U, createCommentVNode as x, createTextVNode as J, pushScopeId as _e, popScopeId as he } from "vue";
7
+ import { d as $ } from "./dayjs.min-8313b006.js";
8
+ import { V as be } from "./index-7ed0999e.js";
9
+ import { E as ye, u as ke, s as W, p as Te } from "./index-c2b9bbfd.js";
10
+ import { _ as Se } from "./_plugin-vue_export-helper-dad06003.js";
11
+ import { E as O } from "./index-f30561d3.js";
12
+ import { k as we, i as Ce } from "./use-form-common-props-cb0ca65c.js";
13
13
  import "./index-0f79095c.js";
14
14
  import "./index-8391a3df.js";
15
15
  import "./index-de24705f.js";
@@ -22,12 +22,12 @@ import "./index-657047bb.js";
22
22
  import "./typescript-7ae59c4c.js";
23
23
  import "./index-c71e37dc.js";
24
24
  import "./config-provider-7860903c.js";
25
- const we = Z({
25
+ const Ee = se({
26
26
  size: {
27
27
  type: [Number, String],
28
- values: ye,
28
+ values: we,
29
29
  default: "",
30
- validator: (r) => q(r)
30
+ validator: (u) => q(u)
31
31
  },
32
32
  shape: {
33
33
  type: String,
@@ -35,7 +35,7 @@ const we = Z({
35
35
  default: "circle"
36
36
  },
37
37
  icon: {
38
- type: Te
38
+ type: Ce
39
39
  },
40
40
  src: {
41
41
  type: String,
@@ -44,138 +44,166 @@ const we = Z({
44
44
  alt: String,
45
45
  srcSet: String,
46
46
  fit: {
47
- type: ee(String),
47
+ type: ae(String),
48
48
  default: "cover"
49
49
  }
50
- }), Se = {
51
- error: (r) => r instanceof Event
52
- }, Ce = J({
50
+ }), De = {
51
+ error: (u) => u instanceof Event
52
+ }, Ve = X({
53
53
  name: "ElAvatar"
54
- }), Ee = /* @__PURE__ */ J({
55
- ...Ce,
56
- props: we,
57
- emits: Se,
58
- setup(r, { emit: E }) {
59
- const _ = r, i = te("avatar"), m = b(!1), l = $(() => {
60
- const { size: o, icon: y, shape: a } = _, u = [i.b()];
61
- return se(o) && u.push(i.m(o)), y && u.push(i.m("icon")), a && u.push(i.m(a)), u;
62
- }), g = $(() => {
63
- const { size: o } = _;
64
- return q(o) ? i.cssVarBlock({
65
- size: ae(o) || ""
54
+ }), Me = /* @__PURE__ */ X({
55
+ ...Ve,
56
+ props: Ee,
57
+ emits: De,
58
+ setup(u, { emit: S }) {
59
+ const b = u, i = ne("avatar"), v = T(!1), c = L(() => {
60
+ const { size: s, icon: w, shape: a } = b, m = [i.b()];
61
+ return oe(s) && m.push(i.m(s)), w && m.push(i.m("icon")), a && m.push(i.m(a)), m;
62
+ }), y = L(() => {
63
+ const { size: s } = b;
64
+ return q(s) ? i.cssVarBlock({
65
+ size: re(s) || ""
66
66
  }) : void 0;
67
- }), h = $(() => ({
68
- objectFit: _.fit
67
+ }), p = L(() => ({
68
+ objectFit: b.fit
69
69
  }));
70
- W(() => _.src, () => m.value = !1);
71
- function c(o) {
72
- m.value = !0, E("error", o);
70
+ G(() => b.src, () => v.value = !1);
71
+ function l(s) {
72
+ v.value = !0, S("error", s);
73
73
  }
74
- return (o, y) => (v(), k("span", {
75
- class: X(D(l)),
76
- style: O(D(g))
74
+ return (s, w) => (f(), _("span", {
75
+ class: Q(V(c)),
76
+ style: R(V(y))
77
77
  }, [
78
- (o.src || o.srcSet) && !m.value ? (v(), k("img", {
78
+ (s.src || s.srcSet) && !v.value ? (f(), _("img", {
79
79
  key: 0,
80
- src: o.src,
81
- alt: o.alt,
82
- srcset: o.srcSet,
83
- style: O(D(h)),
84
- onError: c
85
- }, null, 44, ["src", "alt", "srcset"])) : o.icon ? (v(), R(D(ge), { key: 1 }, {
86
- default: V(() => [
87
- (v(), R(ce(o.icon)))
80
+ src: s.src,
81
+ alt: s.alt,
82
+ srcset: s.srcSet,
83
+ style: R(V(p)),
84
+ onError: l
85
+ }, null, 44, ["src", "alt", "srcset"])) : s.icon ? (f(), K(V(ye), { key: 1 }, {
86
+ default: P(() => [
87
+ (f(), K(me(s.icon)))
88
88
  ]),
89
89
  _: 1
90
- })) : ue(o.$slots, "default", { key: 2 })
90
+ })) : pe(s.$slots, "default", { key: 2 })
91
91
  ], 6));
92
92
  }
93
93
  });
94
- var De = /* @__PURE__ */ oe(Ee, [["__file", "avatar.vue"]]);
95
- const Ve = ne(De);
96
- const Pe = async ({ appId: r, apiKey: E, value: _, callback: i }) => {
97
- var m;
94
+ var Ne = /* @__PURE__ */ ie(Me, [["__file", "avatar.vue"]]);
95
+ const Pe = le(Ne);
96
+ const Ye = async ({ appId: u, apiKey: S, value: b, callback: i }) => {
97
+ var v;
98
98
  try {
99
- const l = await fetch(`https://dashscope.aliyuncs.com/api/v1/apps/${r}/completion`, {
99
+ const c = await fetch(`https://dashscope.aliyuncs.com/api/v1/apps/${u}/completion`, {
100
100
  method: "POST",
101
101
  body: JSON.stringify({
102
- input: { prompt: _ },
102
+ input: { prompt: b },
103
103
  parameters: { incremental_output: "true" },
104
104
  debug: {}
105
105
  }),
106
106
  headers: {
107
- Authorization: `Bearer ${E}`,
107
+ Authorization: `Bearer ${S}`,
108
108
  "Content-Type": "application/json",
109
109
  "X-DashScope-SSE": "enable"
110
110
  }
111
111
  });
112
- if (!l.ok)
113
- throw new Error(`HTTP ${l.status}`);
114
- const g = l.body.getReader(), h = new TextDecoder();
115
- let c = "";
112
+ if (!c.ok) {
113
+ i("error", `HTTP ${c.status}: ${c.statusText}`);
114
+ return;
115
+ }
116
+ const y = c.body.getReader(), p = new TextDecoder();
117
+ let l = "", s = null;
116
118
  for (; ; ) {
117
- const { done: o, value: y } = await g.read();
118
- if (o) {
119
- c.trim() && Ae(c, i), i("finish", "");
119
+ const { done: w, value: a } = await y.read();
120
+ if (w) {
121
+ l.trim() && He(l, i), i("finish", "");
120
122
  break;
121
123
  }
122
- c += h.decode(y, { stream: !0 });
123
- let a;
124
- for (; (a = c.indexOf(`
124
+ l += p.decode(a, { stream: !0 });
125
+ let m;
126
+ for (; (m = l.indexOf(`
125
127
  `)) !== -1; ) {
126
- const u = c.substring(0, a).trim();
127
- if (c = c.substring(a + 1), u.startsWith("data:")) {
128
- const T = u.substring(5).trim();
129
- if (T && T !== "[DONE]")
128
+ const k = l.substring(0, m).trim();
129
+ if (l = l.substring(m + 1), k.startsWith("event:")) {
130
+ s = k.substring(6).trim();
131
+ continue;
132
+ }
133
+ if (k.startsWith("data:")) {
134
+ const C = k.substring(5).trim();
135
+ if (s === "error" || C && C.startsWith("{"))
130
136
  try {
131
- const w = JSON.parse(T), F = (m = w == null ? void 0 : w.output) == null ? void 0 : m.text;
137
+ const h = JSON.parse(C);
138
+ if (h.code || h.message || s === "error") {
139
+ const B = h.message || h.code || "未知错误";
140
+ i("error", `百炼服务端错误: ${B}`);
141
+ return;
142
+ }
143
+ const F = (v = h == null ? void 0 : h.output) == null ? void 0 : v.text;
132
144
  F && i && i("message", F);
133
145
  } catch {
134
- console.debug("等待完整数据...");
146
+ console.debug("JSON 解析失败:", C);
135
147
  }
148
+ s = null;
136
149
  }
137
150
  }
138
151
  }
139
- } catch (l) {
140
- console.error("流式请求失败:", l), i("error", l.message);
152
+ } catch (c) {
153
+ console.error("流式请求失败:", c), i("error", c.message);
141
154
  }
142
- };
143
- function Ae(r, E) {
144
- var i;
145
- const _ = r.split(`
155
+ }, He = (u, S) => {
156
+ var v;
157
+ const b = u.split(`
146
158
  `);
147
- for (const m of _)
148
- if (m.startsWith("data:")) {
149
- const l = m.substring(5).trim();
150
- if (l && l !== "[DONE]")
159
+ let i = null;
160
+ for (const c of b) {
161
+ if (c.startsWith("event:")) {
162
+ i = c.substring(6).trim();
163
+ continue;
164
+ }
165
+ if (c.startsWith("data:")) {
166
+ const y = c.substring(5).trim();
167
+ if (y && y !== "[DONE]")
151
168
  try {
152
- const g = JSON.parse(l), h = (i = g == null ? void 0 : g.output) == null ? void 0 : i.text;
153
- h && E && E("message", h);
169
+ const p = JSON.parse(y);
170
+ if (i === "error" || p.code || p.message) {
171
+ const s = p.message || p.code || "未知错误";
172
+ S("error", `百炼服务端错误: ${s}`);
173
+ return;
174
+ }
175
+ const l = (v = p == null ? void 0 : p.output) == null ? void 0 : v.text;
176
+ l && S && S("message", l);
154
177
  } catch {
155
178
  }
179
+ i = null;
156
180
  }
157
- }
158
- const C = (r) => (fe("data-v-24220a5f"), r = r(), ve(), r), Fe = { class: "chat-container" }, Me = { class: "avatar" }, Ne = { class: "message-content" }, Ye = { class: "message-text" }, xe = { class: "message-createTime" }, He = /* @__PURE__ */ C(() => /* @__PURE__ */ t("div", { class: "message-createTime" }, "请问对本轮查询结果是否满意?", -1)), ze = { class: "feedback-buttons" }, Be = ["onClick"], $e = /* @__PURE__ */ C(() => /* @__PURE__ */ t("span", { class: "btn-emoji" }, "👍", -1)), Ie = /* @__PURE__ */ C(() => /* @__PURE__ */ t("span", { class: "btn-text" }, "满意", -1)), Le = [
159
- $e,
160
- Ie
161
- ], je = ["onClick"], Oe = /* @__PURE__ */ C(() => /* @__PURE__ */ t("span", { class: "btn-emoji" }, "👎", -1)), Re = /* @__PURE__ */ C(() => /* @__PURE__ */ t("span", { class: "btn-text" }, "不满意", -1)), Ke = [
162
- Oe,
163
- Re
164
- ], Ue = {
181
+ }
182
+ };
183
+ const D = (u) => (_e("data-v-50a97ff3"), u = u(), he(), u), Fe = { class: "ai-dialog-body" }, Ae = { class: "avatar" }, xe = { class: "message-content" }, $e = ["innerHTML"], ze = {
184
+ key: 1,
185
+ class: "message-text"
186
+ }, Oe = { class: "message-createTime" }, Be = /* @__PURE__ */ D(() => /* @__PURE__ */ n("div", { class: "message-createTime" }, "请问对本轮查询结果是否满意?", -1)), Le = { class: "feedback-buttons" }, Ie = ["onClick"], Je = /* @__PURE__ */ D(() => /* @__PURE__ */ n("span", { class: "btn-emoji" }, "👍", -1)), je = /* @__PURE__ */ D(() => /* @__PURE__ */ n("span", { class: "btn-text" }, "满意", -1)), Re = [
187
+ Je,
188
+ je
189
+ ], Ke = ["onClick"], Ue = /* @__PURE__ */ D(() => /* @__PURE__ */ n("span", { class: "btn-emoji" }, "👎", -1)), We = /* @__PURE__ */ D(() => /* @__PURE__ */ n("span", { class: "btn-text" }, "不满意", -1)), qe = [
190
+ Ue,
191
+ We
192
+ ], Xe = {
165
193
  key: 1,
166
194
  class: "message-createTime"
167
- }, qe = {
195
+ }, Ge = {
168
196
  key: 0,
169
197
  class: "message-item assistant"
170
- }, Je = { class: "avatar" }, We = /* @__PURE__ */ C(() => /* @__PURE__ */ t("div", { class: "message-content" }, [
171
- /* @__PURE__ */ t("div", { class: "typing-indicator" }, [
172
- /* @__PURE__ */ t("span"),
173
- /* @__PURE__ */ t("span"),
174
- /* @__PURE__ */ t("span")
198
+ }, Qe = { class: "avatar" }, Ze = /* @__PURE__ */ D(() => /* @__PURE__ */ n("div", { class: "message-content" }, [
199
+ /* @__PURE__ */ n("div", { class: "typing-indicator" }, [
200
+ /* @__PURE__ */ n("span"),
201
+ /* @__PURE__ */ n("span"),
202
+ /* @__PURE__ */ n("span")
175
203
  ])
176
- ], -1)), Xe = { class: "input-area" }, Ge = { class: "input-actions" }, Qe = /* @__PURE__ */ C(() => /* @__PURE__ */ t("div", { class: "input-hint" }, [
177
- /* @__PURE__ */ t("span", null, "Enter 发送 | Ctrl + Enter 换行")
178
- ], -1)), Ze = { class: "feedback-dialog-content" }, et = /* @__PURE__ */ C(() => /* @__PURE__ */ t("div", { class: "feedback-emoji" }, "😟", -1)), tt = /* @__PURE__ */ C(() => /* @__PURE__ */ t("p", { class: "feedback-tip" }, "很抱歉没能帮到您,请告诉我们哪里需要改进:", -1)), st = { class: "dialog-footer" }, at = {
204
+ ], -1)), et = { class: "input-area" }, tt = { class: "input-actions" }, st = /* @__PURE__ */ D(() => /* @__PURE__ */ n("div", { class: "input-hint" }, [
205
+ /* @__PURE__ */ n("span", null, "Enter 发送 | Ctrl + Enter 换行")
206
+ ], -1)), at = { class: "feedback-dialog-content" }, nt = /* @__PURE__ */ D(() => /* @__PURE__ */ n("div", { class: "feedback-emoji" }, "😟", -1)), ot = /* @__PURE__ */ D(() => /* @__PURE__ */ n("p", { class: "feedback-tip" }, "很抱歉没能帮到您,请告诉我们哪里需要改进:", -1)), rt = { class: "dialog-footer" }, it = {
179
207
  __name: "index",
180
208
  props: {
181
209
  defaultMessage: {
@@ -187,160 +215,201 @@ const C = (r) => (fe("data-v-24220a5f"), r = r(), ve(), r), Fe = { class: "chat-
187
215
  }
188
216
  },
189
217
  emits: ["callBack"],
190
- setup(r, { expose: E, emit: _ }) {
191
- const i = de("stConfig"), m = me(_e()), l = _, g = r, h = b(!1), c = b(!1), o = b(!1), y = b(null), a = b([
218
+ setup(u, { expose: S, emit: b }) {
219
+ const i = fe("stConfig"), v = ve(be()), c = T(!1), y = b, p = u, l = T(!1), s = T(!1), w = T(null), a = T([
192
220
  {
193
221
  role: "assistant",
194
222
  // AI-assistant, 用户-user
195
- content: g.defaultMessage,
223
+ content: p.defaultMessage,
196
224
  userContent: null,
197
225
  showFeedback: !1,
198
226
  // 是否展示反馈按钮(默认信息不用展示)
199
227
  hasFeedback: !1,
200
228
  // 是否已进行过反馈
201
- createTime: z().format("YYYY-MM-DD HH:mm:ss"),
229
+ createTime: $().format("YYYY-MM-DD HH:mm:ss"),
202
230
  // 消息发起时间
203
231
  resTime: 0,
204
232
  // 响应总耗时
205
233
  firstPackageTime: 0
206
234
  // 首包响应耗时
207
235
  }
208
- ]), u = b(""), T = b(!1), w = b(""), F = b({}), M = async (d, e) => {
209
- switch (d) {
236
+ ]), m = T(""), k = T(!1), C = T(""), h = T({}), F = (o) => {
237
+ if (typeof o != "string")
238
+ return !1;
239
+ try {
240
+ const e = JSON.parse(o);
241
+ return e !== null && typeof e == "object";
242
+ } catch {
243
+ return !1;
244
+ }
245
+ }, B = (o) => {
246
+ if (!F(o))
247
+ return null;
248
+ try {
249
+ const e = JSON.parse(o), { parsedConditions: t, ...d } = e;
250
+ return {
251
+ parsedConditions: t,
252
+ webParams: d
253
+ };
254
+ } catch {
255
+ return null;
256
+ }
257
+ }, Z = (o) => {
258
+ var t;
259
+ if (!o)
260
+ return "";
261
+ let e = "";
262
+ return (t = o.parsedConditions) != null && t.length && (e += '<div class="parsed-conditions">', o.parsedConditions.forEach((d) => {
263
+ e += `<div class="parsed-conditions-item">${d}</div>`;
264
+ }), e += "</div>"), e;
265
+ }, Y = async (o, e) => {
266
+ switch (o) {
210
267
  case "satisfied": {
211
- const s = a.value[e], p = {
212
- userName: m.username,
213
- userContent: s.userContent,
214
- aiContent: s.content,
268
+ const t = a.value[e], d = {
269
+ userName: v.username,
270
+ userContent: t.userContent,
271
+ aiContent: t.content,
215
272
  type: 1,
216
- createTime: s.createTime,
217
- resTime: s.resTime,
218
- firstPackageTime: s.firstPackageTime
273
+ createTime: t.createTime,
274
+ resTime: t.resTime,
275
+ firstPackageTime: t.firstPackageTime
219
276
  };
220
- await i.request.post("/alarm/deliversign/addVarietyAiHelperLog", p), B.success("感谢您的评价!"), a.value[e].hasFeedback = !0;
277
+ await i.request.post("/alarm/deliversign/addVarietyAiHelperLog", d), O.success("感谢您的评价!"), a.value[e].hasFeedback = !0;
221
278
  break;
222
279
  }
223
280
  case "open": {
224
- F.value = e, T.value = !0;
281
+ h.value = e, k.value = !0;
225
282
  break;
226
283
  }
227
284
  case "unsatisfied": {
228
- const s = a.value[e], p = {
229
- userName: m.username,
230
- userContent: s.userContent,
231
- userSuggestion: w.value,
232
- aiContent: s.content,
285
+ const t = a.value[e], d = {
286
+ userName: v.username,
287
+ userContent: t.userContent,
288
+ userSuggestion: C.value,
289
+ aiContent: t.content,
233
290
  type: 2,
234
- resTime: s.resTime,
235
- createTime: s.createTime,
236
- firstPackageTime: s.firstPackageTime
291
+ resTime: t.resTime,
292
+ createTime: t.createTime,
293
+ firstPackageTime: t.firstPackageTime
237
294
  };
238
- await i.request.post("/alarm/deliversign/addVarietyAiHelperLog", p), B.success("感谢您的反馈!我们将持续跟踪并进行优化"), T.value = !1, a.value[e].hasFeedback = !0;
295
+ await i.request.post("/alarm/deliversign/addVarietyAiHelperLog", d), O.success("感谢您的反馈!我们将持续跟踪并进行优化"), k.value = !1, a.value[e].hasFeedback = !0;
239
296
  break;
240
297
  }
241
298
  case "default": {
242
- const s = a.value[e], p = {
243
- userName: m.username,
244
- userContent: s.userContent,
245
- userSuggestion: w.value,
246
- aiContent: s.content,
299
+ const t = a.value[e], d = {
300
+ userName: v.username,
301
+ userContent: t.userContent,
302
+ userSuggestion: C.value,
303
+ aiContent: t.content,
247
304
  type: null,
248
- resTime: s.resTime,
249
- createTime: s.createTime,
250
- firstPackageTime: s.firstPackageTime
305
+ resTime: t.resTime,
306
+ createTime: t.createTime,
307
+ firstPackageTime: t.firstPackageTime
251
308
  };
252
- await i.request.post("/alarm/deliversign/addVarietyAiHelperLog", p);
309
+ await i.request.post("/alarm/deliversign/addVarietyAiHelperLog", d);
253
310
  }
254
311
  }
255
312
  }, j = async () => {
256
- const d = u.value.trim();
257
- if (!d)
258
- return B.warning("请输入消息内容");
259
- if (c.value)
313
+ const o = m.value.trim();
314
+ if (!o)
315
+ return O.warning("请输入消息内容");
316
+ if (l.value)
260
317
  return;
261
318
  a.value.push({
262
319
  role: "user",
263
- content: d,
264
- createTime: z().format("YYYY-MM-DD HH:mm:ss")
265
- }), u.value = "", await P(), a.value.push({
320
+ content: o,
321
+ createTime: $().format("YYYY-MM-DD HH:mm:ss")
322
+ }), m.value = "", await M(), a.value.push({
266
323
  role: "assistant",
267
324
  content: "",
268
- userContent: d,
325
+ userContent: o,
269
326
  showFeedback: !1,
270
327
  hasFeedback: !1,
271
- createTime: z().format("YYYY-MM-DD HH:mm:ss"),
328
+ createTime: $().format("YYYY-MM-DD HH:mm:ss"),
272
329
  resTime: 0,
273
330
  firstPackageTime: 0
274
- }), await P(), c.value = !0, o.value = !0;
275
- let e = "", s = (/* @__PURE__ */ new Date()).getTime();
331
+ }), await M(), l.value = !0, s.value = !0;
332
+ let e = "", t = (/* @__PURE__ */ new Date()).getTime();
276
333
  try {
277
- await Pe({
334
+ await Ye({
278
335
  appId: "9e54d112acfe4531bd1fc4fee8827fef",
279
336
  apiKey: "sk-d995eb26a4334bdeb2ccb4cbfaf51de8",
280
- value: d,
281
- callback: (N, f) => {
282
- if (N === "message") {
283
- e += f;
284
- const n = a.value[a.value.length - 1];
285
- n && n.role === "assistant" && (n.content = e, P()), n.firstPackageTime === 0 && (n.firstPackageTime = (/* @__PURE__ */ new Date()).getTime() - s);
286
- } else if (N === "finish") {
287
- o.value = !1, c.value = !1;
288
- const n = a.value[a.value.length - 1];
289
- n && n.role === "assistant" && (n.showFeedback = !0, n.resTime = (/* @__PURE__ */ new Date()).getTime() - s, M("default", a.value.length - 1));
337
+ value: o,
338
+ callback: (H, g) => {
339
+ if (H === "error") {
340
+ s.value = !1, l.value = !1, a.value.pop(), a.value.push({
341
+ role: "assistant",
342
+ userContent: o,
343
+ content: `❌ ${g}`,
344
+ showFeedback: !1,
345
+ hasFeedback: !1,
346
+ createTime: $().format("YYYY-MM-DD HH:mm:ss"),
347
+ resTime: (/* @__PURE__ */ new Date()).getTime() - t,
348
+ firstPackageTime: 0
349
+ }), Y("default", a.value.length - 1), M();
350
+ return;
351
+ } else if (H === "message") {
352
+ e += g;
353
+ const r = a.value[a.value.length - 1];
354
+ r && r.role === "assistant" && (r.content = e, M()), r.firstPackageTime === 0 && (r.firstPackageTime = (/* @__PURE__ */ new Date()).getTime() - t);
355
+ } else if (H === "finish") {
356
+ s.value = !1, l.value = !1;
357
+ const r = a.value[a.value.length - 1];
358
+ r && r.role === "assistant" && (r.showFeedback = !0, r.resTime = (/* @__PURE__ */ new Date()).getTime() - t, Y("default", a.value.length - 1));
290
359
  try {
291
- const A = JSON.parse(e);
292
- l("callBack", A);
360
+ const N = JSON.parse(e);
361
+ delete N.parsedConditions, y("callBack", N);
293
362
  } catch {
294
- l("callBack", e);
363
+ y("callBack", e);
295
364
  }
296
365
  }
297
366
  }
298
367
  });
299
- } catch (p) {
300
- B.error(`AI响应异常: ${p}`), a.value.pop(), a.value.push({
368
+ } catch (d) {
369
+ O.error(`AI响应异常: ${d}`), a.value.pop(), a.value.push({
301
370
  role: "assistant",
302
- userContent: d,
303
- content: "抱歉,AI服务响应异常,请稍后重试。",
371
+ userContent: o,
372
+ content: "抱歉,AI服务响应异常,请稍后重试。",
304
373
  showFeedback: !0,
305
374
  hasFeedback: !1,
306
- createTime: z().format("YYYY-MM-DD HH:mm:ss"),
307
- resTime: (/* @__PURE__ */ new Date()).getTime() - s,
375
+ createTime: $().format("YYYY-MM-DD HH:mm:ss"),
376
+ resTime: (/* @__PURE__ */ new Date()).getTime() - t,
308
377
  firstPackageTime: 0
309
- }), M("default", a.value.length - 1), await P(), c.value = !1, o.value = !1;
378
+ }), Y("default", a.value.length - 1), await M(), l.value = !1, s.value = !1;
310
379
  }
311
- }, G = (d) => {
312
- if (d.key === "Enter")
313
- if (d.ctrlKey) {
314
- d.preventDefault();
315
- const e = d.target, s = e.selectionStart, p = e.selectionEnd;
316
- u.value = u.value.substring(0, s) + `
317
- ` + u.value.substring(p), I(() => {
318
- e.selectionStart = e.selectionEnd = s + 1;
380
+ }, ee = (o) => {
381
+ if (o.key === "Enter")
382
+ if (o.ctrlKey) {
383
+ o.preventDefault();
384
+ const e = o.target, t = e.selectionStart, d = e.selectionEnd;
385
+ m.value = m.value.substring(0, t) + `
386
+ ` + m.value.substring(d), I(() => {
387
+ e.selectionStart = e.selectionEnd = t + 1;
319
388
  });
320
389
  } else
321
- d.preventDefault(), j();
322
- }, P = async () => {
323
- await I(), y.value && (y.value.scrollTop = y.value.scrollHeight);
390
+ o.preventDefault(), j();
391
+ }, M = async () => {
392
+ await I(), w.value && (w.value.scrollTop = w.value.scrollHeight);
324
393
  };
325
- return W(
394
+ return G(
326
395
  () => a.value,
327
396
  () => {
328
- P();
397
+ M();
329
398
  },
330
399
  { deep: !0 }
331
- ), E({
400
+ ), S({
332
401
  open: () => {
333
- h.value = !0, I(() => {
334
- P();
402
+ c.value = !0, I(() => {
403
+ M();
335
404
  });
336
405
  }
337
- }), (d, e) => {
338
- const s = Ve, p = le, H = re, N = ie;
339
- return v(), k(Y, null, [
340
- S(N, {
406
+ }), (o, e) => {
407
+ const t = Pe, d = de, z = ue, H = ce;
408
+ return f(), _(A, null, [
409
+ E(H, {
341
410
  class: "ai-dialog",
342
- modelValue: h.value,
343
- "onUpdate:modelValue": e[1] || (e[1] = (f) => h.value = f),
411
+ modelValue: c.value,
412
+ "onUpdate:modelValue": e[1] || (e[1] = (g) => c.value = g),
344
413
  title: "✨ 品种池参数解析AI助手",
345
414
  width: "500px",
346
415
  center: "",
@@ -349,85 +418,85 @@ const C = (r) => (fe("data-v-24220a5f"), r = r(), ve(), r), Fe = { class: "chat-
349
418
  modal: !1,
350
419
  "modal-penetrable": !0
351
420
  }, {
352
- default: V(() => {
353
- var f;
421
+ default: P(() => {
422
+ var g;
354
423
  return [
355
- t("div", Fe, [
356
- t("div", {
424
+ n("div", Fe, [
425
+ n("div", {
357
426
  ref_key: "messageListRef",
358
- ref: y,
427
+ ref: w,
359
428
  class: "message-list"
360
429
  }, [
361
- (v(!0), k(Y, null, pe(a.value, (n, A) => (v(), k("div", {
362
- key: A,
363
- class: "message-item-wrapper"
430
+ (f(!0), _(A, null, ge(a.value, (r, N) => (f(), _("div", {
431
+ key: N,
432
+ class: Q([r.role, "message-item"])
364
433
  }, [
365
- t("div", {
366
- class: X(["message-item", n.role])
367
- }, [
368
- n.content ? (v(), k(Y, { key: 0 }, [
369
- t("div", Me, [
370
- S(s, {
371
- size: 32,
372
- icon: n.role === "user" ? D(he) : D(U)
373
- }, null, 8, ["icon"])
374
- ]),
375
- t("div", Ne, [
376
- t("div", Ye, K(n.content), 1),
377
- t("div", xe, K(n.createTime), 1),
378
- n.role === "assistant" ? (v(), k(Y, { key: 0 }, [
379
- n.showFeedback && !n.hasFeedback ? (v(), k(Y, { key: 0 }, [
380
- He,
381
- t("div", ze, [
382
- t("button", {
383
- class: "feedback-btn satisfied-btn",
384
- onClick: (Q) => M("satisfied", A)
385
- }, Le, 8, Be),
386
- t("button", {
387
- class: "feedback-btn unsatisfied-btn",
388
- onClick: (Q) => M("open", A)
389
- }, Ke, 8, je)
390
- ])
391
- ], 64)) : x("", !0),
392
- n.showFeedback && n.hasFeedback ? (v(), k("div", Ue, "感谢您进行的评价反馈")) : x("", !0)
393
- ], 64)) : x("", !0)
394
- ])
395
- ], 64)) : x("", !0)
396
- ], 2)
397
- ]))), 128)),
398
- o.value && !((f = a.value[a.value.length - 1]) != null && f.content) ? (v(), k("div", qe, [
399
- t("div", Je, [
400
- S(s, {
434
+ r.content ? (f(), _(A, { key: 0 }, [
435
+ n("div", Ae, [
436
+ E(t, {
437
+ size: 32,
438
+ icon: r.role === "user" ? V(ke) : V(W)
439
+ }, null, 8, ["icon"])
440
+ ]),
441
+ n("div", xe, [
442
+ F(r.content) ? (f(), _("div", {
443
+ key: 0,
444
+ class: "message-json",
445
+ innerHTML: Z(B(r.content))
446
+ }, null, 8, $e)) : (f(), _("div", ze, U(r.content), 1)),
447
+ n("div", Oe, U(r.createTime), 1),
448
+ r.role === "assistant" ? (f(), _(A, { key: 2 }, [
449
+ r.showFeedback && !r.hasFeedback ? (f(), _(A, { key: 0 }, [
450
+ Be,
451
+ n("div", Le, [
452
+ n("button", {
453
+ class: "feedback-btn satisfied-btn",
454
+ onClick: (te) => Y("satisfied", N)
455
+ }, Re, 8, Ie),
456
+ n("button", {
457
+ class: "feedback-btn unsatisfied-btn",
458
+ onClick: (te) => Y("open", N)
459
+ }, qe, 8, Ke)
460
+ ])
461
+ ], 64)) : x("", !0),
462
+ r.showFeedback && r.hasFeedback ? (f(), _("div", Xe, "感谢您进行的评价反馈")) : x("", !0)
463
+ ], 64)) : x("", !0)
464
+ ])
465
+ ], 64)) : x("", !0)
466
+ ], 2))), 128)),
467
+ s.value && !((g = a.value[a.value.length - 1]) != null && g.content) ? (f(), _("div", Ge, [
468
+ n("div", Qe, [
469
+ E(t, {
401
470
  size: 32,
402
- icon: D(U)
471
+ icon: V(W)
403
472
  }, null, 8, ["icon"])
404
473
  ]),
405
- We
474
+ Ze
406
475
  ])) : x("", !0)
407
476
  ], 512),
408
- t("div", Xe, [
409
- S(p, {
477
+ n("div", et, [
478
+ E(d, {
410
479
  class: "message-input",
411
- modelValue: u.value,
412
- "onUpdate:modelValue": e[0] || (e[0] = (n) => u.value = n),
480
+ modelValue: m.value,
481
+ "onUpdate:modelValue": e[0] || (e[0] = (r) => m.value = r),
413
482
  type: "textarea",
414
483
  rows: 4,
415
484
  autosize: { minRows: 2, maxRows: 4 },
416
485
  placeholder: "输入您想查询的品种条件... (Ctrl+Enter换行,Enter发送)",
417
- onKeydown: G
486
+ onKeydown: ee
418
487
  }, null, 8, ["modelValue"]),
419
- t("div", Ge, [
420
- Qe,
421
- S(H, {
488
+ n("div", tt, [
489
+ st,
490
+ E(z, {
422
491
  class: "send-btn",
423
492
  type: "primary",
424
- icon: D(be),
425
- loading: c.value,
493
+ icon: V(Te),
494
+ loading: l.value,
426
495
  onClick: j,
427
496
  round: ""
428
497
  }, {
429
- default: V(() => [
430
- L(" 发送 ")
498
+ default: P(() => [
499
+ J(" 发送 ")
431
500
  ]),
432
501
  _: 1
433
502
  }, 8, ["icon", "loading"])
@@ -438,40 +507,40 @@ const C = (r) => (fe("data-v-24220a5f"), r = r(), ve(), r), Fe = { class: "chat-
438
507
  }),
439
508
  _: 1
440
509
  }, 8, ["modelValue"]),
441
- S(N, {
442
- modelValue: T.value,
443
- "onUpdate:modelValue": e[5] || (e[5] = (f) => T.value = f),
510
+ E(H, {
511
+ modelValue: k.value,
512
+ "onUpdate:modelValue": e[5] || (e[5] = (g) => k.value = g),
444
513
  title: "📝 反馈意见",
445
514
  width: "400px"
446
515
  }, {
447
- footer: V(() => [
448
- t("span", st, [
449
- S(H, {
450
- onClick: e[3] || (e[3] = (f) => T.value = !1)
516
+ footer: P(() => [
517
+ n("span", rt, [
518
+ E(z, {
519
+ onClick: e[3] || (e[3] = (g) => k.value = !1)
451
520
  }, {
452
- default: V(() => [
453
- L("取消")
521
+ default: P(() => [
522
+ J("取消")
454
523
  ]),
455
524
  _: 1
456
525
  }),
457
- S(H, {
526
+ E(z, {
458
527
  type: "primary",
459
- onClick: e[4] || (e[4] = (f) => M("unsatisfied", F.value))
528
+ onClick: e[4] || (e[4] = (g) => Y("unsatisfied", h.value))
460
529
  }, {
461
- default: V(() => [
462
- L("提交反馈")
530
+ default: P(() => [
531
+ J("提交反馈")
463
532
  ]),
464
533
  _: 1
465
534
  })
466
535
  ])
467
536
  ]),
468
- default: V(() => [
469
- t("div", Ze, [
470
- et,
471
- tt,
472
- S(p, {
473
- modelValue: w.value,
474
- "onUpdate:modelValue": e[2] || (e[2] = (f) => w.value = f),
537
+ default: P(() => [
538
+ n("div", at, [
539
+ nt,
540
+ ot,
541
+ E(d, {
542
+ modelValue: C.value,
543
+ "onUpdate:modelValue": e[2] || (e[2] = (g) => C.value = g),
475
544
  type: "textarea",
476
545
  rows: 4,
477
546
  placeholder: "[非必填]例如:回答不够准确、查询结果有误、界面体验不佳..."
@@ -483,11 +552,11 @@ const C = (r) => (fe("data-v-24220a5f"), r = r(), ve(), r), Fe = { class: "chat-
483
552
  ], 64);
484
553
  };
485
554
  }
486
- }, ot = /* @__PURE__ */ ke(at, [["__scopeId", "data-v-24220a5f"]]), Pt = {
487
- install(r) {
488
- r.component("st-varietyAiHelper", ot);
555
+ }, lt = /* @__PURE__ */ Se(it, [["__scopeId", "data-v-50a97ff3"]]), Ht = {
556
+ install(u) {
557
+ u.component("st-varietyAiHelper", lt);
489
558
  }
490
559
  };
491
560
  export {
492
- Pt as default
561
+ Ht as default
493
562
  };