sand-components-vben 2.5.7 → 2.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sand-components-vben",
3
- "version": "2.5.7",
3
+ "version": "2.5.8",
4
4
  "description": "",
5
5
  "main": "sand-components-vben.js",
6
6
  "scripts": {
@@ -39147,59 +39147,77 @@ function ioe() {
39147
39147
  // 思考内容
39148
39148
  thinkIng: !1
39149
39149
  // 是否正在思考
39150
- }), { isStreaming: t, streamContent: n, currentRequestId: r, conversationId: a, thinkContent: i, thinkIng: o } = Wn(e), s = (d, f, p) => {
39150
+ }), { isStreaming: t, streamContent: n, currentRequestId: r, conversationId: a, thinkContent: i, thinkIng: o } = Wn(e), s = (f, p, m, g) => {
39151
39151
  try {
39152
- if (typeof d == "object" && d !== null && d.conversationId !== a.value && (a.value = d.conversationId), typeof d == "object" && d !== null && d.event === "message") {
39153
- const m = d.answer;
39154
- m && (n.value += m, p && p(n.value));
39152
+ if (typeof f == "object" && f !== null && f.conversationId !== a.value && (a.value = f.conversationId), typeof f == "object" && f !== null) {
39153
+ if (f.event === "message") {
39154
+ const v = f.answer;
39155
+ v && (n.value += v, m && m(n.value));
39156
+ } else if (f.event === "message_end") {
39157
+ console.log("流式消息接收完成"), t.value = !1, r.value = null, g && g(n.value);
39158
+ return;
39159
+ } else if (f.event === "error")
39160
+ throw console.error("流式请求出现错误:", f.message || "未知错误"), t.value = !1, r.value = null, new Error(f.message || "流式请求出现错误");
39155
39161
  }
39156
- } catch (m) {
39157
- console.error("处理流式消息失败:", m), typeof f == "string" && (n.value += f, p && p(n.value));
39162
+ } catch (v) {
39163
+ console.error("处理流式消息失败:", v), typeof p == "string" && (n.value += p, m && m(n.value));
39158
39164
  }
39159
- }, u = async (d = {}) => {
39165
+ }, u = async (f = {}) => {
39160
39166
  const {
39161
- sceneId: f,
39162
- extra: p = {},
39163
- conversationId: m,
39164
- describe: g,
39165
- onContentUpdate: v,
39166
- onError: h,
39167
- onComplete: b,
39168
- onOpen: y
39169
- } = d;
39167
+ sceneId: p,
39168
+ extra: m = {},
39169
+ conversationId: g,
39170
+ describe: v,
39171
+ onContentUpdate: h,
39172
+ onError: b,
39173
+ onComplete: y,
39174
+ onOpen: A
39175
+ } = f;
39170
39176
  n.value = "", t.value = !0;
39171
- const A = Date.now().toString();
39172
- r.value = A;
39173
- const O = {
39174
- id: f,
39175
- dict: p
39177
+ const O = Date.now().toString();
39178
+ r.value = O;
39179
+ const T = {
39180
+ id: p,
39181
+ dict: m
39176
39182
  };
39177
- m && (O.conversationId = m), g && (O.describe = g);
39183
+ g && (T.conversationId = g), v && (T.describe = v);
39178
39184
  try {
39179
- const T = Gke();
39180
- return await Im.createSseRequest(T, {
39181
- data: O,
39182
- requestId: A,
39183
- onMessage: (x, E) => {
39184
- x.event === "message" && (x.answer.includes("<think>") ? x.answer = x.answer.replace("<think>", "") : x.answer.includes("</think>") && (x.answer = x.answer.replace("</think>", ""))), s(x, E, v);
39185
- },
39186
- onError: (x) => {
39187
- console.error("流式请求失败:", x), t.value = !1, r.value = null, h && h(x);
39185
+ const x = Gke();
39186
+ return await Im.createSseRequest(x, {
39187
+ data: T,
39188
+ requestId: O,
39189
+ onMessage: (E, N) => {
39190
+ if (E.event === "message")
39191
+ if (E.answer.includes("<think>")) {
39192
+ o.value = !0;
39193
+ const D = E.answer.indexOf("<think>"), w = E.answer.substring(0, D), C = E.answer.substring(D + 7);
39194
+ w ? E.answer = w : E.answer = "", C && (i.value += C);
39195
+ } else if (E.answer.includes("</think>")) {
39196
+ o.value = !1;
39197
+ const D = E.answer.indexOf("</think>"), w = E.answer.substring(0, D), C = E.answer.substring(D + 8);
39198
+ w && (i.value += w), E.answer = C || "";
39199
+ } else o.value && (i.value += E.answer, E.answer = "");
39200
+ s(E, N, h, y);
39201
+ },
39202
+ onError: (E) => {
39203
+ console.error("流式请求失败:", E), t.value = !1, r.value = null, b && b(E);
39188
39204
  },
39189
39205
  onComplete: () => {
39190
- console.log("流式请求完成"), t.value = !1, r.value = null, b && b(n.value);
39206
+ console.log("流式请求完成"), t.value = !1, r.value = null, y && y(n.value);
39191
39207
  },
39192
39208
  onOpen: () => {
39193
- console.log("流式连接已建立"), y && y();
39209
+ console.log("流式连接已建立"), A && A();
39194
39210
  }
39195
- }), A;
39196
- } catch (T) {
39197
- throw console.error("创建流式请求失败:", T), t.value = !1, r.value = null, T;
39211
+ }), O;
39212
+ } catch (x) {
39213
+ throw console.error("创建流式请求失败:", x), t.value = !1, r.value = null, x;
39198
39214
  }
39199
39215
  }, c = () => {
39200
39216
  r.value && (Im.cancelRequest(r.value), t.value = !1, r.value = null);
39201
39217
  }, l = () => {
39202
- n.value = "", t.value = !1, r.value = null;
39218
+ n.value = "", t.value = !1, r.value = null, i.value = "", o.value = !1;
39219
+ }, d = () => {
39220
+ i.value = "", o.value = !1;
39203
39221
  };
39204
39222
  return Uv(() => {
39205
39223
  c();
@@ -39209,10 +39227,13 @@ function ioe() {
39209
39227
  streamContent: n,
39210
39228
  currentRequestId: r,
39211
39229
  conversationId: a,
39230
+ thinkContent: i,
39231
+ thinkIng: o,
39212
39232
  // 方法
39213
39233
  createStreamRequest: u,
39214
39234
  cancelCurrentRequest: c,
39215
39235
  resetStreamState: l,
39236
+ resetThinkContent: d,
39216
39237
  handleStreamMessage: s
39217
39238
  };
39218
39239
  }