@ibiz-template-plugin/ai-chat 0.0.41 → 0.0.42

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.es.js CHANGED
@@ -2970,6 +2970,9 @@ class ft {
2970
2970
  get type() {
2971
2971
  return this.msg.type;
2972
2972
  }
2973
+ get status() {
2974
+ return this.msg.status;
2975
+ }
2973
2976
  get realcontent() {
2974
2977
  let e = this.msg.content;
2975
2978
  if (e.indexOf("<think>") !== -1 && e.indexOf("</think>") === -1 || (e = e.replace(new RegExp("\\<think\\>[^]*?\\<\\/think\\>", "gs"), "").trim(), e.indexOf("<tool_call>") !== -1 && e.indexOf("</tool_call>") === -1) || (e = e.replace(new RegExp("\\<tool_call\\>[^]*?\\<\\/tool_call\\>", "gs"), "").trim(), e.indexOf("<resources>") !== -1 && e.indexOf("</resources>") === -1))
@@ -3673,7 +3676,7 @@ function Pu(n) {
3673
3676
  return 30;
3674
3677
  case "failed":
3675
3678
  return 40;
3676
- case "cancelled":
3679
+ case "canceled":
3677
3680
  return 30;
3678
3681
  default:
3679
3682
  return 30;
@@ -3683,7 +3686,7 @@ function zu(n) {
3683
3686
  switch (n) {
3684
3687
  case "pending":
3685
3688
  case "sent":
3686
- case "cancelled":
3689
+ case "canceled":
3687
3690
  return "DEFAULT";
3688
3691
  case "failed":
3689
3692
  return "ERROR";
@@ -3702,7 +3705,8 @@ function $u(n) {
3702
3705
  islike: n.is_like,
3703
3706
  isdislike: n.is_dislike,
3704
3707
  feedbackcontent: n.feedback_content,
3705
- realmessageid: n.id
3708
+ realmessageid: n.id,
3709
+ status: n.status
3706
3710
  };
3707
3711
  }
3708
3712
  class Ws {
@@ -3907,7 +3911,8 @@ class Ws {
3907
3911
  suggestions: i.suggestions,
3908
3912
  completed: !0,
3909
3913
  toolcalls: i.toolcalls,
3910
- realmessageid: i.realmessageid
3914
+ realmessageid: i.realmessageid,
3915
+ status: i.status
3911
3916
  };
3912
3917
  this.addMessage(r);
3913
3918
  }), await this.afterFecthHistory(), !0;
@@ -3930,7 +3935,8 @@ class Ws {
3930
3935
  role: "USER",
3931
3936
  type: "DEFAULT",
3932
3937
  content: this.opts.appendCurContent,
3933
- completed: !0
3938
+ completed: !0,
3939
+ status: "sent"
3934
3940
  }), this.opts.appendCurResource) {
3935
3941
  const { hasResources: e, resources: t } = dr.parseMixedContent(this.opts.appendCurResource);
3936
3942
  e && t && t.length > 0 && t.forEach((i) => {
@@ -4063,12 +4069,7 @@ class Ws {
4063
4069
  const t = this.messages.value.findIndex(
4064
4070
  (i) => i.messageid === e.messageid
4065
4071
  );
4066
- if (t !== -1) {
4067
- const i = this.messages.value[t];
4068
- e.content = i.content, this.messages.value[t].replace(e), this.messages.value = [...this.messages.value];
4069
- } else
4070
- this.messages.value = [...this.messages.value, new ft(e)];
4071
- await this.asyncToIndexDB();
4072
+ e.content = e.content || "用户中断", t !== -1 ? (this.messages.value[t].replace(e), this.messages.value = [...this.messages.value]) : this.messages.value = [...this.messages.value, new ft(e)], await this.asyncToIndexDB();
4072
4073
  }
4073
4074
  /**
4074
4075
  * 数据对象转 XML 字符串
@@ -4095,7 +4096,7 @@ class Ws {
4095
4096
  * @memberof AiChatController
4096
4097
  */
4097
4098
  getMessages() {
4098
- const e = this.messages.value.filter((t) => t.type !== "ERROR").map((t) => t._origin);
4099
+ const e = this.messages.value.filter((t) => t.type !== "ERROR" && t.status !== "canceled").map((t) => t._origin);
4099
4100
  return e.forEach((t) => {
4100
4101
  t.content = t.content.replace(new RegExp("\\<tool_call\\>[^]*?\\<\\/tool_call\\>", "gs"), "").trim();
4101
4102
  }), e;
@@ -4126,7 +4127,8 @@ class Ws {
4126
4127
  messageid: He(),
4127
4128
  role: "USER",
4128
4129
  type: "DEFAULT",
4129
- content: t
4130
+ content: t,
4131
+ status: "sent"
4130
4132
  }), await this.opts.question(
4131
4133
  this,
4132
4134
  this.context,
@@ -4346,7 +4348,7 @@ class Ws {
4346
4348
  switch (s) {
4347
4349
  case "action":
4348
4350
  if (this.opts.extendToolbarClick) {
4349
- const a = t.data.actionid;
4351
+ const a = t.data.actionid, c = t.data.appid;
4350
4352
  if (!a)
4351
4353
  throw new Error("actionid不能为空");
4352
4354
  this.addMessage({
@@ -4354,23 +4356,30 @@ class Ws {
4354
4356
  state: 30,
4355
4357
  type: "DEFAULT",
4356
4358
  role: "USER",
4357
- content: o.content_name
4359
+ content: o.content_name,
4360
+ status: "sent"
4358
4361
  });
4359
- const c = { ...e };
4360
- Object.assign(c, { topic: this.topic }), c.msg.realcontent = e.realcontent;
4361
- const d = await this.opts.extendToolbarClick(
4362
+ const d = { ...e };
4363
+ Object.assign(d, { topic: this.topic }), d.msg.realcontent = e.realcontent;
4364
+ const u = await this.opts.extendToolbarClick(
4362
4365
  i,
4363
- { id: a, appId: this.context.srfappid },
4366
+ {
4367
+ id: a,
4368
+ // 是否是插件应用(建议里面定义appid认为是插件应用的界面行为)
4369
+ isPluginApp: !!c,
4370
+ appId: c || this.context.srfappid
4371
+ },
4364
4372
  this.context,
4365
4373
  this.params,
4366
- c
4367
- ), u = (l = d == null ? void 0 : d.data) == null ? void 0 : l[0];
4368
- u.content && this.addMessage({
4374
+ d
4375
+ ), h = (l = u == null ? void 0 : u.data) == null ? void 0 : l[0];
4376
+ h.content && this.addMessage({
4369
4377
  messageid: He(),
4370
4378
  state: 30,
4371
- type: u.type || "DEFAULT",
4372
- role: u.role || "ASSISTANT",
4373
- content: u.content
4379
+ type: h.type || "DEFAULT",
4380
+ role: h.role || "ASSISTANT",
4381
+ content: h.content,
4382
+ status: "sent"
4374
4383
  });
4375
4384
  }
4376
4385
  break;