@ibiz-template-plugin/ai-chat 0.0.49 → 0.0.51
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 +50 -33
- package/dist/index.legacy.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/components/chat-tool-call/chat-tool-call.d.ts +4 -0
- package/dist/types/entity/chat-message/chat-message.d.ts +1 -0
- package/dist/types/interface/i-chat-message/i-chat-message.d.ts +6 -0
- package/dist/types/utils/util/chat-tool-call-parser.d.ts +7 -6
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1333,31 +1333,31 @@ function _l(n, e, t, i) {
|
|
|
1333
1333
|
}
|
|
1334
1334
|
class vd {
|
|
1335
1335
|
/**
|
|
1336
|
-
*
|
|
1337
|
-
* @
|
|
1338
|
-
* @
|
|
1339
|
-
* @returns {*} {IChatToolCall[]}
|
|
1340
|
-
* @memberof ChatToolCallParser
|
|
1336
|
+
* 解析工具调用字符串
|
|
1337
|
+
* @param toolCallString
|
|
1338
|
+
* @returns
|
|
1341
1339
|
*/
|
|
1342
1340
|
static parse(e) {
|
|
1343
|
-
|
|
1341
|
+
let t = !0;
|
|
1342
|
+
e.indexOf("<tool_call>") !== -1 && e.indexOf("</tool_call>") === -1 && (t = !1);
|
|
1343
|
+
const i = new RegExp(
|
|
1344
1344
|
"<tool_call>\\s*({[\\s\\S]*?})\\s*</tool_call>",
|
|
1345
1345
|
"g"
|
|
1346
|
-
),
|
|
1347
|
-
for (const
|
|
1346
|
+
), r = e.matchAll(i), s = [];
|
|
1347
|
+
for (const o of r)
|
|
1348
1348
|
try {
|
|
1349
|
-
const
|
|
1350
|
-
name:
|
|
1351
|
-
parameters:
|
|
1352
|
-
error:
|
|
1349
|
+
const l = JSON.parse(o[1]), a = {
|
|
1350
|
+
name: l.name,
|
|
1351
|
+
parameters: l.parameters,
|
|
1352
|
+
error: l.error || !1
|
|
1353
1353
|
};
|
|
1354
|
-
|
|
1355
|
-
result:
|
|
1356
|
-
}),
|
|
1357
|
-
} catch (
|
|
1358
|
-
console.error("解析工具调用失败:",
|
|
1354
|
+
l.result && Object.assign(a, {
|
|
1355
|
+
result: l.result
|
|
1356
|
+
}), s.push(a);
|
|
1357
|
+
} catch (l) {
|
|
1358
|
+
console.error("解析工具调用失败:", l);
|
|
1359
1359
|
}
|
|
1360
|
-
return
|
|
1360
|
+
return { completed: t, toolCalls: s };
|
|
1361
1361
|
}
|
|
1362
1362
|
}
|
|
1363
1363
|
var Kt, V, Ii, ks, gn = 0, Tl = [], q = D, xs = q.__b, Ss = q.__r, Ms = q.diffed, _s = q.__c, Ts = q.unmount, Ns = q.__;
|
|
@@ -2565,8 +2565,14 @@ const su = (n) => {
|
|
|
2565
2565
|
r.value = !r.value;
|
|
2566
2566
|
};
|
|
2567
2567
|
return /* @__PURE__ */ m("div", { className: "".concat(t.b()), children: [
|
|
2568
|
-
|
|
2569
|
-
|
|
2568
|
+
!n.toolcallCompleted && /* @__PURE__ */ m("div", { className: t.e("loading-container"), children: [
|
|
2569
|
+
/* @__PURE__ */ m("div", { className: t.e("loading-text"), children: "智能体工具调用执行中" }),
|
|
2570
|
+
/* @__PURE__ */ m("div", { className: t.e("loading-dot") }),
|
|
2571
|
+
/* @__PURE__ */ m("div", { className: t.e("loading-dot") }),
|
|
2572
|
+
/* @__PURE__ */ m("div", { className: t.e("loading-dot") })
|
|
2573
|
+
] }),
|
|
2574
|
+
n.toolcallCompleted && o.value.map((a, c) => /* @__PURE__ */ m(ru, { item: a }, c)),
|
|
2575
|
+
n.toolcallCompleted && s.value && /* @__PURE__ */ m("div", { className: t.e("toggle"), onClick: l, children: r.value ? "收起工具调用" : "展开全部 ".concat(i.value.length, " 个工具调用") })
|
|
2570
2576
|
] });
|
|
2571
2577
|
};
|
|
2572
2578
|
const be = new L("chat-select"), ou = (n) => {
|
|
@@ -2703,9 +2709,6 @@ const ht = new L("markdown-message"), au = (n) => {
|
|
|
2703
2709
|
if (e.content.indexOf("<think>") !== -1) {
|
|
2704
2710
|
const { isThoughtCompleted: h, thoughtContent: f, answerContent: p } = u(e.content);
|
|
2705
2711
|
h ? (l.value.icon = /* @__PURE__ */ m(Pi, {}), l.value.title = "思考完成") : e.completed === !0 ? (l.value.icon = /* @__PURE__ */ m(Pi, {}), l.value.title = "思考已停止") : (l.value.icon = /* @__PURE__ */ m(zi, {}), l.value.title = "思考中..."), l.value.description = f || "", r.value.setMarkdown(p || "");
|
|
2706
|
-
} else if (e.content.indexOf("<tool_call>") !== -1) {
|
|
2707
|
-
const h = e.content.replace(new RegExp("\\<tool_call\\>[^]*?\\<\\/tool_call\\>", "gs"), "").trim();
|
|
2708
|
-
r.value.setMarkdown(h || "");
|
|
2709
2712
|
} else
|
|
2710
2713
|
r.value.setMarkdown(e.content || "");
|
|
2711
2714
|
c(e.suggestions);
|
|
@@ -2720,7 +2723,7 @@ const ht = new L("markdown-message"), au = (n) => {
|
|
|
2720
2723
|
icon: f || e.completed === !0 ? /* @__PURE__ */ m(Pi, {}) : /* @__PURE__ */ m(zi, {})
|
|
2721
2724
|
}, y && (h = y);
|
|
2722
2725
|
} else
|
|
2723
|
-
|
|
2726
|
+
h = e.content;
|
|
2724
2727
|
c(e.suggestions), r.value = new dl({
|
|
2725
2728
|
// @ts-ignore
|
|
2726
2729
|
id: i,
|
|
@@ -2756,7 +2759,13 @@ const ht = new L("markdown-message"), au = (n) => {
|
|
|
2756
2759
|
] }),
|
|
2757
2760
|
/* @__PURE__ */ m("div", { className: "".concat(ht.b("content"), " pre-wrap-container"), children: [
|
|
2758
2761
|
/* @__PURE__ */ m(nu, { items: [l.value] }),
|
|
2759
|
-
|
|
2762
|
+
/* @__PURE__ */ m(
|
|
2763
|
+
su,
|
|
2764
|
+
{
|
|
2765
|
+
toolcallCompleted: !!e.toolcallcompleted,
|
|
2766
|
+
items: e.toolcalls || []
|
|
2767
|
+
}
|
|
2768
|
+
),
|
|
2760
2769
|
/* @__PURE__ */ m("div", { id: i })
|
|
2761
2770
|
] }),
|
|
2762
2771
|
/* @__PURE__ */ m("div", { className: ht.b("footer"), children: [
|
|
@@ -3060,6 +3069,7 @@ const pu = new L("chat-message-item"), mu = (n) => {
|
|
|
3060
3069
|
};
|
|
3061
3070
|
class ft {
|
|
3062
3071
|
constructor(e) {
|
|
3072
|
+
A(this, "toolcallcompleted", !0);
|
|
3063
3073
|
A(this, "toolcalls", []);
|
|
3064
3074
|
/**
|
|
3065
3075
|
* @description 消息的所有原始内容
|
|
@@ -3125,7 +3135,7 @@ class ft {
|
|
|
3125
3135
|
* @param {IChatMessage} msg
|
|
3126
3136
|
*/
|
|
3127
3137
|
update(e) {
|
|
3128
|
-
e.content || (e.content = ""), this.allcontent += e.content, e.content.indexOf("<think>") !== -1 && this.msg.content && (this.msg.content = ""), this.msg.content += e.content, this.computeToolCalls();
|
|
3138
|
+
e.content || (e.content = ""), this.allcontent += e.content, e.content.indexOf("<think>") !== -1 && this.msg.content && (this.msg.content = ""), this.msg.content += e.content, (this.msg.content.indexOf("<tool_call>") !== -1 || this.msg.content.indexOf("</tool_call>") !== -1) && (this.msg.content = ""), this.computeToolCalls();
|
|
3129
3139
|
}
|
|
3130
3140
|
/**
|
|
3131
3141
|
* @description 替换消息
|
|
@@ -3150,7 +3160,8 @@ class ft {
|
|
|
3150
3160
|
* @memberof ChatMessage
|
|
3151
3161
|
*/
|
|
3152
3162
|
computeToolCalls() {
|
|
3153
|
-
|
|
3163
|
+
const { completed: e, toolCalls: t } = vd.parse(this.allcontent);
|
|
3164
|
+
this.toolcallcompleted = e, this.toolcalls = t;
|
|
3154
3165
|
}
|
|
3155
3166
|
}
|
|
3156
3167
|
class Rt {
|
|
@@ -4150,7 +4161,13 @@ class js {
|
|
|
4150
4161
|
const t = this.messages.value.find(
|
|
4151
4162
|
(i) => i.messageid === e.messageid
|
|
4152
4163
|
);
|
|
4153
|
-
|
|
4164
|
+
if (t)
|
|
4165
|
+
t.update(e), this.messages.value = [...this.messages.value];
|
|
4166
|
+
else {
|
|
4167
|
+
const i = new ft(e);
|
|
4168
|
+
i.update({ ...e, content: "" }), this.messages.value = [...this.messages.value, i];
|
|
4169
|
+
}
|
|
4170
|
+
this.asyncToIndexDB();
|
|
4154
4171
|
}
|
|
4155
4172
|
/**
|
|
4156
4173
|
* 更新消息完成状态
|
|
@@ -4179,18 +4196,18 @@ class js {
|
|
|
4179
4196
|
* @param {IChatMessage} data
|
|
4180
4197
|
*/
|
|
4181
4198
|
replaceMessage(e, t = !0) {
|
|
4182
|
-
const i = this.messages.value.findIndex(
|
|
4183
|
-
(
|
|
4199
|
+
const i = { ...e }, r = this.messages.value.findIndex(
|
|
4200
|
+
(s) => s.messageid === e.messageid
|
|
4184
4201
|
);
|
|
4185
|
-
|
|
4202
|
+
r !== -1 ? (i.toolcalls = this.messages.value[r].toolcalls, this.messages.value[r].replace(e), this.messages.value = [...this.messages.value]) : this.messages.value = [...this.messages.value, new ft(e)], this.asyncToIndexDB(), e.type === "DEFAULT" && this.opts.recommendPrompt && t && this.opts.recommendPrompt(this.context, this.params, {
|
|
4186
4203
|
appDataEntityId: this.appDataEntityId,
|
|
4187
4204
|
message: {
|
|
4188
4205
|
messages: [e],
|
|
4189
4206
|
sessionid: this.chatSessionid,
|
|
4190
4207
|
srfaiagent: this.activeAIAgentID
|
|
4191
4208
|
}
|
|
4192
|
-
}).then((
|
|
4193
|
-
|
|
4209
|
+
}).then((s) => {
|
|
4210
|
+
s && s.content && this.updateRecommendPrompt(i, s.content);
|
|
4194
4211
|
});
|
|
4195
4212
|
}
|
|
4196
4213
|
/**
|