@opentiny/tiny-robot 0.4.0-beta.0 → 0.4.0
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.d.ts +20 -21
- package/dist/index6.js +448 -455
- package/dist/style.css +1 -1
- package/package.json +3 -3
package/dist/index6.js
CHANGED
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
import { defineComponent as k, openBlock as _, createElementBlock as B, renderSlot as C, ref as
|
|
1
|
+
import { defineComponent as k, openBlock as _, createElementBlock as B, renderSlot as C, ref as L, computed as y, watch as H, unref as E, normalizeClass as K, createVNode as j, watchEffect as q, nextTick as ee, Fragment as w, createElementVNode as R, toDisplayString as z, withDirectives as Z, vShow as Q, createBlock as I, resolveDynamicComponent as Y, normalizeProps as D, guardReactiveProps as P, createCommentVNode as se, useCssModule as Ye, renderList as W, mergeProps as F, markRaw as O, inject as T, provide as $, toValue as S, reactive as Je, readonly as We, withCtx as M, onMounted as ve, onUnmounted as je } from "vue";
|
|
2
2
|
import { _ as N } from "./_plugin-vue_export-helper.js";
|
|
3
|
-
import { IconLoading as
|
|
4
|
-
import { i as
|
|
5
|
-
const
|
|
3
|
+
import { IconLoading as he, IconAtom as ze, IconArrowDown as ye, IconPlugin as fe, IconError as Ve, IconCancelled as Xe } from "@opentiny/tiny-robot-svgs";
|
|
4
|
+
import { i as qe, w as Ze, g as Qe, a as et } from "./index4.js";
|
|
5
|
+
const xe = Symbol("bubble-message-group"), Re = Symbol("bubble-box-renderer-matches"), Be = Symbol("bubble-box-fallback-renderer"), Ce = Symbol(
|
|
6
6
|
"bubble-box-prop-fallback-renderer"
|
|
7
|
-
),
|
|
7
|
+
), Ee = Symbol("bubble-content-renderer-matches"), ke = Symbol(
|
|
8
8
|
"bubble-content-fallback-renderer"
|
|
9
|
-
),
|
|
9
|
+
), Se = Symbol(
|
|
10
10
|
"bubble-content-prop-fallback-renderer"
|
|
11
|
-
),
|
|
11
|
+
), oe = Symbol("bubble-store"), Ie = Symbol("bubble-state-change-fn"), Te = Symbol("bubble-list-context"), G = {
|
|
12
12
|
LOADING: -1,
|
|
13
13
|
NORMAL: 0,
|
|
14
14
|
CONTENT: 10,
|
|
15
15
|
ROLE: 20
|
|
16
|
-
},
|
|
16
|
+
}, tt = {
|
|
17
17
|
class: "tr-bubble__box",
|
|
18
18
|
"data-box-type": "box"
|
|
19
|
-
},
|
|
19
|
+
}, nt = /* @__PURE__ */ k({
|
|
20
20
|
__name: "Box",
|
|
21
21
|
props: {
|
|
22
22
|
placement: {},
|
|
23
23
|
shape: {}
|
|
24
24
|
},
|
|
25
25
|
setup(t) {
|
|
26
|
-
return (e, n) => (_(), B("div",
|
|
26
|
+
return (e, n) => (_(), B("div", tt, [
|
|
27
27
|
C(e.$slots, "default", {}, void 0, !0)
|
|
28
28
|
]));
|
|
29
29
|
}
|
|
30
|
-
}),
|
|
30
|
+
}), re = /* @__PURE__ */ N(nt, [["__scopeId", "data-v-98101726"]]), ot = ["src", "alt"], st = /* @__PURE__ */ k({
|
|
31
31
|
__name: "Image",
|
|
32
32
|
props: {
|
|
33
33
|
message: {},
|
|
34
34
|
contentIndex: {}
|
|
35
35
|
},
|
|
36
36
|
setup(t) {
|
|
37
|
-
const e = t, n =
|
|
37
|
+
const e = t, n = L(!1), s = L(!1), { content: a } = ie(e), i = y(() => a.value ? typeof a.value.image_url == "string" ? a.value.image_url : a.value.image_url.url : null);
|
|
38
38
|
H(i, () => {
|
|
39
|
-
n.value = !1,
|
|
39
|
+
n.value = !1, s.value = !1;
|
|
40
40
|
});
|
|
41
|
-
const
|
|
42
|
-
n.value = !0,
|
|
41
|
+
const o = () => {
|
|
42
|
+
n.value = !0, s.value = !1;
|
|
43
43
|
}, r = () => {
|
|
44
|
-
|
|
44
|
+
s.value = !0, n.value = !0;
|
|
45
45
|
};
|
|
46
|
-
return (u,
|
|
46
|
+
return (u, b) => {
|
|
47
47
|
var v;
|
|
48
48
|
return _(), B("img", {
|
|
49
|
-
class:
|
|
49
|
+
class: K(["tr-bubble__image", { loading: !n.value }]),
|
|
50
50
|
src: i.value,
|
|
51
51
|
alt: (v = E(a)) == null ? void 0 : v.text,
|
|
52
52
|
loading: "lazy",
|
|
53
|
-
onLoad:
|
|
53
|
+
onLoad: o,
|
|
54
54
|
onError: r,
|
|
55
55
|
"data-type": "image"
|
|
56
56
|
}, null, 42, ot);
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
}),
|
|
59
|
+
}), Le = /* @__PURE__ */ N(st, [["__scopeId", "data-v-e59794cb"]]), rt = {
|
|
60
60
|
class: "tr-bubble__loading",
|
|
61
61
|
"data-type": "loading"
|
|
62
|
-
},
|
|
62
|
+
}, at = /* @__PURE__ */ k({
|
|
63
63
|
__name: "Loading",
|
|
64
64
|
props: {
|
|
65
65
|
message: {},
|
|
66
66
|
contentIndex: {}
|
|
67
67
|
},
|
|
68
68
|
setup(t) {
|
|
69
|
-
return (e, n) => (_(), B("div",
|
|
70
|
-
|
|
69
|
+
return (e, n) => (_(), B("div", rt, [
|
|
70
|
+
j(E(he))
|
|
71
71
|
]));
|
|
72
72
|
}
|
|
73
|
-
}),
|
|
73
|
+
}), Me = /* @__PURE__ */ N(at, [["__scopeId", "data-v-bc1b5ff4"]]), lt = {
|
|
74
74
|
class: "tr-bubble__reasoning",
|
|
75
75
|
"data-type": "reasoning"
|
|
76
|
-
},
|
|
76
|
+
}, ct = { class: "title" }, ut = { class: "detail" }, it = /* @__PURE__ */ k({
|
|
77
77
|
__name: "Reasoning",
|
|
78
78
|
props: {
|
|
79
79
|
message: {},
|
|
80
80
|
contentIndex: {}
|
|
81
81
|
},
|
|
82
82
|
setup(t) {
|
|
83
|
-
const e = t, { restMessage: n, restProps:
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
i.value = ((
|
|
83
|
+
const e = t, { restMessage: n, restProps: s } = Ke(e, ["reasoning_content"]), a = le(n, e.contentIndex), i = L(!1);
|
|
84
|
+
q(() => {
|
|
85
|
+
var b;
|
|
86
|
+
i.value = ((b = e.message.state) == null ? void 0 : b.open) ?? !1;
|
|
87
87
|
});
|
|
88
|
-
const
|
|
89
|
-
i.value = !i.value,
|
|
90
|
-
}, u =
|
|
88
|
+
const o = He(), r = () => {
|
|
89
|
+
i.value = !i.value, o("open", i.value);
|
|
90
|
+
}, u = L(null);
|
|
91
91
|
return H(
|
|
92
92
|
() => e.message.reasoning_content,
|
|
93
93
|
() => {
|
|
94
|
-
|
|
94
|
+
ee(() => {
|
|
95
95
|
u.value && u.value.scrollTo({
|
|
96
96
|
top: u.value.scrollHeight,
|
|
97
97
|
behavior: "smooth"
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
), (
|
|
102
|
-
var
|
|
101
|
+
), (b, v) => {
|
|
102
|
+
var p, m;
|
|
103
103
|
return _(), B(w, null, [
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
R("div", lt, [
|
|
105
|
+
R("div", {
|
|
106
106
|
class: "header",
|
|
107
107
|
onClick: r
|
|
108
108
|
}, [
|
|
109
|
-
|
|
110
|
-
class:
|
|
109
|
+
R("div", {
|
|
110
|
+
class: K(["icon-and-text", { thinking: (p = e.message.state) == null ? void 0 : p.thinking }])
|
|
111
111
|
}, [
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
j(E(ze)),
|
|
113
|
+
R("span", ct, z((m = e.message.state) != null && m.thinking ? "正在思考" : "已思考"), 1)
|
|
114
114
|
], 2),
|
|
115
|
-
|
|
116
|
-
class:
|
|
115
|
+
j(E(ye), {
|
|
116
|
+
class: K(["expand-icon", { "-rotate-90": !i.value }])
|
|
117
117
|
}, null, 8, ["class"])
|
|
118
118
|
]),
|
|
119
|
-
|
|
120
|
-
v[0] || (v[0] =
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
Z(R("div", ut, [
|
|
120
|
+
v[0] || (v[0] = R("div", { class: "side-border" }, [
|
|
121
|
+
R("div", { class: "dot-wrapper" }, [
|
|
122
|
+
R("div", { class: "dot" })
|
|
123
123
|
]),
|
|
124
|
-
|
|
124
|
+
R("div", { class: "border-line" })
|
|
125
125
|
], -1)),
|
|
126
|
-
|
|
126
|
+
R("p", {
|
|
127
127
|
class: "detail-content",
|
|
128
128
|
ref_key: "detailRef",
|
|
129
129
|
ref: u
|
|
130
|
-
},
|
|
130
|
+
}, z(e.message.reasoning_content), 513)
|
|
131
131
|
], 512), [
|
|
132
|
-
[
|
|
132
|
+
[Q, i.value]
|
|
133
133
|
])
|
|
134
134
|
]),
|
|
135
|
-
(_(),
|
|
135
|
+
(_(), I(Y(E(a)), D(P(E(s))), null, 16))
|
|
136
136
|
], 64);
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
}),
|
|
139
|
+
}), $e = /* @__PURE__ */ N(it, [["__scopeId", "data-v-a8e2bce1"]]), dt = {
|
|
140
140
|
key: 0,
|
|
141
141
|
class: "tr-bubble__text",
|
|
142
142
|
"data-type": "text"
|
|
143
|
-
},
|
|
143
|
+
}, ft = /* @__PURE__ */ k({
|
|
144
144
|
__name: "Text",
|
|
145
145
|
props: {
|
|
146
146
|
message: {},
|
|
147
147
|
contentIndex: {}
|
|
148
148
|
},
|
|
149
149
|
setup(t) {
|
|
150
|
-
const e = t, { contentText: n } =
|
|
151
|
-
return (
|
|
150
|
+
const e = t, { contentText: n } = ie(e);
|
|
151
|
+
return (s, a) => E(n) ? (_(), B("p", dt, z(E(n)), 1)) : se("", !0);
|
|
152
152
|
}
|
|
153
|
-
}),
|
|
153
|
+
}), ae = /* @__PURE__ */ N(ft, [["__scopeId", "data-v-93592ecb"]]), Ae = /* @__PURE__ */ k({
|
|
154
154
|
__name: "ToolRole",
|
|
155
155
|
props: {
|
|
156
156
|
message: {},
|
|
157
157
|
contentIndex: {}
|
|
158
158
|
},
|
|
159
159
|
setup(t) {
|
|
160
|
-
const e = t, n =
|
|
161
|
-
return
|
|
160
|
+
const e = t, n = ue();
|
|
161
|
+
return q(() => {
|
|
162
162
|
e.message.tool_call_id && (n.toolCallResults || (n.toolCallResults = {}), n.toolCallResults[e.message.tool_call_id] = e.message.content ?? "");
|
|
163
|
-
}), (
|
|
163
|
+
}), (s, a) => se("", !0);
|
|
164
164
|
}
|
|
165
|
-
}),
|
|
165
|
+
}), pt = {
|
|
166
166
|
class: "tr-bubble__tool-call",
|
|
167
167
|
"data-type": "tool-call"
|
|
168
|
-
},
|
|
168
|
+
}, bt = { class: "header" }, _t = { class: "header-left" }, mt = { class: "title" }, gt = { class: "header-right" }, vt = { class: "divider" }, ht = ["innerHTML"], yt = /* @__PURE__ */ k({
|
|
169
169
|
__name: "Tool",
|
|
170
170
|
props: {
|
|
171
171
|
message: {},
|
|
@@ -173,164 +173,164 @@ const Be = Symbol("bubble-message-group"), Ce = Symbol("bubble-box-renderer-matc
|
|
|
173
173
|
toolCallIndex: {}
|
|
174
174
|
},
|
|
175
175
|
setup(t) {
|
|
176
|
-
const e = t, { toolCall: n, toolCallWithResult:
|
|
177
|
-
["running", { text: "正在调用", icon:
|
|
178
|
-
["success", { text: "已调用", icon:
|
|
179
|
-
["failed", { text: "调用失败", icon:
|
|
180
|
-
["cancelled", { text: "已取消", icon:
|
|
181
|
-
]),
|
|
182
|
-
var
|
|
183
|
-
return i.get(((
|
|
184
|
-
}), r = (
|
|
185
|
-
let
|
|
176
|
+
const e = t, { toolCall: n, toolCallWithResult: s, state: a } = Dt(e), i = /* @__PURE__ */ new Map([
|
|
177
|
+
["running", { text: "正在调用", icon: he }],
|
|
178
|
+
["success", { text: "已调用", icon: fe }],
|
|
179
|
+
["failed", { text: "调用失败", icon: Ve }],
|
|
180
|
+
["cancelled", { text: "已取消", icon: Xe }]
|
|
181
|
+
]), o = y(() => {
|
|
182
|
+
var d;
|
|
183
|
+
return i.get(((d = a.value) == null ? void 0 : d.status) || "") || { text: "", icon: fe };
|
|
184
|
+
}), r = (d, g = 2) => {
|
|
185
|
+
let x = "";
|
|
186
186
|
try {
|
|
187
|
-
typeof
|
|
187
|
+
typeof d == "string" ? x = JSON.stringify(JSON.parse(d), null, g) : x = JSON.stringify(d, null, g);
|
|
188
188
|
} catch {
|
|
189
189
|
}
|
|
190
|
-
return
|
|
191
|
-
}, u =
|
|
192
|
-
if (!
|
|
190
|
+
return x;
|
|
191
|
+
}, u = Ye(), b = (d) => d.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), v = (d) => {
|
|
192
|
+
if (!d)
|
|
193
193
|
return "";
|
|
194
|
-
let
|
|
195
|
-
return
|
|
194
|
+
let g = b(d);
|
|
195
|
+
return g = g.replace(
|
|
196
196
|
/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,
|
|
197
|
-
(
|
|
198
|
-
let
|
|
199
|
-
return /^"/.test(
|
|
197
|
+
(x) => {
|
|
198
|
+
let A = "number";
|
|
199
|
+
return /^"/.test(x) ? A = /:$/.test(x) ? "key" : "string" : /true|false/.test(x) ? A = "boolean" : /null/.test(x) && (A = "null"), `<span class="${u[A]}">${x}</span>`;
|
|
200
200
|
}
|
|
201
|
-
),
|
|
202
|
-
},
|
|
203
|
-
H(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
top:
|
|
201
|
+
), g;
|
|
202
|
+
}, p = y(() => r(s.value, 2)), m = y(() => v(p.value)), l = L(null);
|
|
203
|
+
H(p, (d, g) => {
|
|
204
|
+
g === "" || g === "{}" || ee(() => {
|
|
205
|
+
l.value && l.value.scrollTo({
|
|
206
|
+
top: l.value.scrollHeight,
|
|
207
207
|
behavior: "smooth"
|
|
208
208
|
});
|
|
209
209
|
});
|
|
210
210
|
});
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
const f = L(!1);
|
|
212
|
+
q(() => {
|
|
213
|
+
f.value = a.value.open ?? !1;
|
|
214
214
|
});
|
|
215
|
-
const h =
|
|
216
|
-
var
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
...(
|
|
221
|
-
[
|
|
215
|
+
const h = He(), c = () => {
|
|
216
|
+
var g, x;
|
|
217
|
+
f.value = !f.value;
|
|
218
|
+
const d = (g = n.value) == null ? void 0 : g.id;
|
|
219
|
+
d && h("toolCall", {
|
|
220
|
+
...(x = e.message.state) == null ? void 0 : x.toolCall,
|
|
221
|
+
[d]: { ...a.value, open: f.value }
|
|
222
222
|
});
|
|
223
223
|
};
|
|
224
|
-
return (
|
|
225
|
-
var
|
|
226
|
-
return _(), B("div",
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
(_(),
|
|
230
|
-
class:
|
|
224
|
+
return (d, g) => {
|
|
225
|
+
var x;
|
|
226
|
+
return _(), B("div", pt, [
|
|
227
|
+
R("div", bt, [
|
|
228
|
+
R("div", _t, [
|
|
229
|
+
(_(), I(Y(o.value.icon), {
|
|
230
|
+
class: K(["header-icon", `icon-${E(a).status}`])
|
|
231
231
|
}, null, 8, ["class"])),
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
R("span", null, [
|
|
233
|
+
R("span", null, z(o.value.text) + " ", 1),
|
|
234
|
+
R("span", mt, z(((x = E(n)) == null ? void 0 : x.function.name) || "Untitled"), 1)
|
|
235
235
|
])
|
|
236
236
|
]),
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
class:
|
|
240
|
-
onClick:
|
|
237
|
+
R("div", gt, [
|
|
238
|
+
j(E(ye), {
|
|
239
|
+
class: K(["expand-icon", { "-rotate-90": !f.value }]),
|
|
240
|
+
onClick: c
|
|
241
241
|
}, null, 8, ["class"])
|
|
242
242
|
])
|
|
243
243
|
]),
|
|
244
|
-
|
|
245
|
-
[
|
|
244
|
+
Z(R("div", vt, null, 512), [
|
|
245
|
+
[Q, f.value]
|
|
246
246
|
]),
|
|
247
|
-
|
|
247
|
+
Z(R("div", {
|
|
248
248
|
class: "detail",
|
|
249
|
-
innerHTML:
|
|
249
|
+
innerHTML: m.value,
|
|
250
250
|
ref_key: "detailRef",
|
|
251
|
-
ref:
|
|
252
|
-
}, null, 8,
|
|
253
|
-
[
|
|
251
|
+
ref: l
|
|
252
|
+
}, null, 8, ht), [
|
|
253
|
+
[Q, f.value]
|
|
254
254
|
])
|
|
255
255
|
]);
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
|
-
}),
|
|
259
|
-
key:
|
|
260
|
-
number:
|
|
261
|
-
string:
|
|
262
|
-
boolean:
|
|
258
|
+
}), xt = "_key_1b448_2", Rt = "_number_1b448_6", Bt = "_string_1b448_10", Ct = "_boolean_1b448_14", Et = {
|
|
259
|
+
key: xt,
|
|
260
|
+
number: Rt,
|
|
261
|
+
string: Bt,
|
|
262
|
+
boolean: Ct,
|
|
263
263
|
null: "_null_1b448_18"
|
|
264
|
-
},
|
|
265
|
-
$style:
|
|
266
|
-
},
|
|
264
|
+
}, kt = {
|
|
265
|
+
$style: Et
|
|
266
|
+
}, Ne = /* @__PURE__ */ N(yt, [["__cssModules", kt], ["__scopeId", "data-v-d5b7675f"]]), Oe = /* @__PURE__ */ k({
|
|
267
267
|
__name: "Tools",
|
|
268
268
|
props: {
|
|
269
269
|
message: {},
|
|
270
270
|
contentIndex: {}
|
|
271
271
|
},
|
|
272
272
|
setup(t) {
|
|
273
|
-
const e = t, { restMessage: n, restProps:
|
|
274
|
-
return (i,
|
|
275
|
-
(_(),
|
|
276
|
-
(_(!0), B(w, null,
|
|
273
|
+
const e = t, { restMessage: n, restProps: s } = Ke(e, ["tool_calls"]), a = le(n, e.contentIndex);
|
|
274
|
+
return (i, o) => (_(), B(w, null, [
|
|
275
|
+
(_(), I(Y(E(a)), D(P(E(s))), null, 16)),
|
|
276
|
+
(_(!0), B(w, null, W(e.message.tool_calls, (r, u) => (_(), I(Ne, F({
|
|
277
277
|
key: r.id
|
|
278
278
|
}, { ref_for: !0 }, e, { "tool-call-index": u }), null, 16, ["tool-call-index"]))), 128))
|
|
279
279
|
], 64));
|
|
280
280
|
}
|
|
281
|
-
}),
|
|
281
|
+
}), we = [
|
|
282
282
|
{
|
|
283
283
|
find: (t, e) => (e == null ? void 0 : e.type) === "image_url",
|
|
284
|
-
renderer: O(
|
|
285
|
-
priority:
|
|
284
|
+
renderer: O(re),
|
|
285
|
+
priority: G.NORMAL,
|
|
286
286
|
attributes: { "data-box-type": "image" }
|
|
287
287
|
}
|
|
288
|
-
],
|
|
288
|
+
], De = [
|
|
289
289
|
{
|
|
290
290
|
find: (t) => !!t.loading,
|
|
291
|
-
renderer: O(
|
|
292
|
-
priority:
|
|
291
|
+
renderer: O(Me),
|
|
292
|
+
priority: G.LOADING
|
|
293
293
|
},
|
|
294
294
|
{
|
|
295
295
|
find: (t) => typeof t.reasoning_content == "string",
|
|
296
|
-
renderer: O(
|
|
297
|
-
priority:
|
|
296
|
+
renderer: O($e),
|
|
297
|
+
priority: G.NORMAL
|
|
298
298
|
},
|
|
299
299
|
{
|
|
300
300
|
find: (t) => Array.isArray(t.tool_calls) && t.tool_calls.length > 0,
|
|
301
|
-
renderer: O(
|
|
302
|
-
priority:
|
|
301
|
+
renderer: O(Oe),
|
|
302
|
+
priority: G.NORMAL
|
|
303
303
|
},
|
|
304
304
|
{
|
|
305
305
|
find: (t, e) => e.type === "image_url",
|
|
306
|
-
renderer: O(
|
|
307
|
-
priority:
|
|
306
|
+
renderer: O(Le),
|
|
307
|
+
priority: G.CONTENT
|
|
308
308
|
},
|
|
309
309
|
{
|
|
310
310
|
find: (t) => t.role === "tool",
|
|
311
|
-
renderer: O(
|
|
312
|
-
priority:
|
|
311
|
+
renderer: O(Ae),
|
|
312
|
+
priority: G.ROLE
|
|
313
313
|
}
|
|
314
|
-
],
|
|
315
|
-
const e = T(
|
|
316
|
-
return !e && t &&
|
|
314
|
+
], Fe = O(re), Pe = O(ae), pe = Symbol("BUBBLE_CONTENT_RESOLVER_KEY"), te = (t) => {
|
|
315
|
+
const e = T(pe, void 0), n = e ?? t;
|
|
316
|
+
return !e && t && $(pe, t), n ? (a) => {
|
|
317
317
|
const i = S(n);
|
|
318
318
|
return i == null ? void 0 : i(a);
|
|
319
319
|
} : (a) => a.content;
|
|
320
320
|
};
|
|
321
321
|
function St(t) {
|
|
322
322
|
const { boxRendererMatches: e, fallbackBoxRenderer: n } = t;
|
|
323
|
-
e &&
|
|
323
|
+
e && $(Re, e), n && $(Be, n);
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function It(t) {
|
|
326
326
|
const { fallbackBoxRenderer: e } = t;
|
|
327
|
-
e &&
|
|
327
|
+
e && $(Ce, e);
|
|
328
328
|
}
|
|
329
329
|
function Tt(t, e) {
|
|
330
|
-
const n = T(
|
|
330
|
+
const n = T(Re, we), s = T(Be, void 0), a = T(Ce, void 0), i = te();
|
|
331
331
|
if (typeof e == "number" && S(t).length !== 1)
|
|
332
332
|
throw new Error("[BubbleBoxRenderer] When contentIndex is a number, messages array length must be 1");
|
|
333
|
-
const
|
|
333
|
+
const o = (r) => {
|
|
334
334
|
if (r.length !== 1)
|
|
335
335
|
return { content: void 0, index: void 0 };
|
|
336
336
|
const u = i(r.at(0));
|
|
@@ -340,154 +340,154 @@ function Tt(t, e) {
|
|
|
340
340
|
};
|
|
341
341
|
};
|
|
342
342
|
return y(() => {
|
|
343
|
-
const r = S(t), { content: u, index:
|
|
343
|
+
const r = S(t), { content: u, index: b } = o(r), v = S(n).find((p) => p.find(r, u, b));
|
|
344
344
|
return v ? {
|
|
345
345
|
renderer: v.renderer,
|
|
346
346
|
attributes: v.attributes
|
|
347
347
|
} : {
|
|
348
|
-
renderer: S(a) || S(
|
|
348
|
+
renderer: S(a) || S(s) || Fe
|
|
349
349
|
};
|
|
350
350
|
});
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function Lt(t) {
|
|
353
353
|
const { contentRendererMatches: e, fallbackContentRenderer: n } = t;
|
|
354
|
-
e &&
|
|
354
|
+
e && $(Ee, e), n && $(ke, n);
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function Mt(t) {
|
|
357
357
|
const { fallbackContentRenderer: e } = t;
|
|
358
|
-
e &&
|
|
358
|
+
e && $(Se, e);
|
|
359
359
|
}
|
|
360
|
-
function
|
|
361
|
-
const n = T(
|
|
360
|
+
function le(t, e) {
|
|
361
|
+
const n = T(Ee, De), s = T(ke, void 0), a = T(Se, void 0), i = te();
|
|
362
362
|
return y(() => {
|
|
363
|
-
const
|
|
364
|
-
return
|
|
363
|
+
const o = S(t), r = i(o), u = Array.isArray(r) ? r.at(e ?? 0) : { type: "text", text: r || "" }, b = S(n).find((v) => v.find(o, u, e));
|
|
364
|
+
return b ? b.renderer : S(a) || S(s) || Pe;
|
|
365
365
|
});
|
|
366
366
|
}
|
|
367
|
-
function
|
|
368
|
-
|
|
367
|
+
function $t(t) {
|
|
368
|
+
$(Ie, t);
|
|
369
369
|
}
|
|
370
|
-
function
|
|
371
|
-
return T(
|
|
370
|
+
function He() {
|
|
371
|
+
return T(Ie, (t, e) => {
|
|
372
372
|
console.warn(`[Bubble] State change function not found for key: ${t}`);
|
|
373
373
|
});
|
|
374
374
|
}
|
|
375
|
-
function
|
|
376
|
-
const e = T(
|
|
375
|
+
function ce(t) {
|
|
376
|
+
const e = T(oe, void 0);
|
|
377
377
|
if (e)
|
|
378
378
|
return e;
|
|
379
|
-
const n =
|
|
380
|
-
return
|
|
379
|
+
const n = Je(t || {});
|
|
380
|
+
return $(oe, n), n;
|
|
381
381
|
}
|
|
382
|
-
function
|
|
383
|
-
return T(
|
|
382
|
+
function ue() {
|
|
383
|
+
return T(oe, {});
|
|
384
384
|
}
|
|
385
|
-
function
|
|
385
|
+
function Ge(t) {
|
|
386
386
|
H(
|
|
387
387
|
t,
|
|
388
|
-
(e, n,
|
|
388
|
+
(e, n, s) => {
|
|
389
389
|
if (!e) return;
|
|
390
390
|
const a = (i) => {
|
|
391
391
|
var u;
|
|
392
|
-
const
|
|
393
|
-
if (!e.contains((
|
|
392
|
+
const o = window.getSelection();
|
|
393
|
+
if (!e.contains((o == null ? void 0 : o.anchorNode) || null)) return;
|
|
394
394
|
i.preventDefault();
|
|
395
|
-
const r = (
|
|
395
|
+
const r = (o == null ? void 0 : o.toString().replace(/\n{2,}/g, `
|
|
396
396
|
`)) || "";
|
|
397
397
|
(u = i.clipboardData) == null || u.setData("text/plain", r);
|
|
398
398
|
};
|
|
399
|
-
e.addEventListener("copy", a),
|
|
399
|
+
e.addEventListener("copy", a), s(() => e.removeEventListener("copy", a));
|
|
400
400
|
},
|
|
401
401
|
{ immediate: !0, flush: "post" }
|
|
402
402
|
);
|
|
403
403
|
}
|
|
404
|
-
const
|
|
405
|
-
const e =
|
|
404
|
+
const ie = (t) => {
|
|
405
|
+
const e = te(), n = y(() => {
|
|
406
406
|
const a = e(t.message);
|
|
407
407
|
return Array.isArray(a) ? a.at(t.contentIndex) : { type: "text", text: a || "" };
|
|
408
|
-
}),
|
|
408
|
+
}), s = y(() => n.value.type === "text" ? String(n.value.text) : "");
|
|
409
409
|
return {
|
|
410
410
|
content: n,
|
|
411
|
-
contentText:
|
|
411
|
+
contentText: s
|
|
412
412
|
};
|
|
413
413
|
};
|
|
414
|
-
function
|
|
415
|
-
|
|
414
|
+
function At(t) {
|
|
415
|
+
$(xe, t);
|
|
416
416
|
}
|
|
417
|
-
function
|
|
418
|
-
return T(
|
|
417
|
+
function Nt() {
|
|
418
|
+
return T(xe, void 0);
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function Ke(t, e) {
|
|
421
421
|
const n = y(() => {
|
|
422
422
|
const a = Object.entries(t.message).filter(([i]) => !e.includes(i));
|
|
423
423
|
return Object.fromEntries(a);
|
|
424
|
-
}),
|
|
424
|
+
}), s = y(() => ({
|
|
425
425
|
...t,
|
|
426
426
|
message: n.value
|
|
427
427
|
}));
|
|
428
428
|
return {
|
|
429
429
|
restMessage: n,
|
|
430
|
-
restProps:
|
|
430
|
+
restProps: s
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
|
-
let
|
|
434
|
-
const
|
|
435
|
-
let
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
438
|
-
return
|
|
433
|
+
let ne = null;
|
|
434
|
+
const Ot = () => (ne || (ne = import("./index5.js")), ne);
|
|
435
|
+
let J = null;
|
|
436
|
+
const wt = async () => {
|
|
437
|
+
if (J)
|
|
438
|
+
return J;
|
|
439
439
|
try {
|
|
440
440
|
const [t, e] = await Promise.all([import("markdown-it"), import("dompurify")]);
|
|
441
|
-
return
|
|
441
|
+
return J = { markdown: t.default, dompurify: e.default }, J;
|
|
442
442
|
} catch {
|
|
443
|
-
return console.warn("[BubbleMarkdownRenderer] install markdown-it and dompurify to use markdown renderer"),
|
|
443
|
+
return console.warn("[BubbleMarkdownRenderer] install markdown-it and dompurify to use markdown renderer"), J = null, null;
|
|
444
444
|
}
|
|
445
|
-
}, be = ["running", "success", "failed", "cancelled"],
|
|
445
|
+
}, be = ["running", "success", "failed", "cancelled"], Dt = (t) => {
|
|
446
446
|
const e = y(() => {
|
|
447
|
-
var
|
|
448
|
-
return (r = (
|
|
449
|
-
}), n =
|
|
450
|
-
var v,
|
|
451
|
-
let
|
|
452
|
-
|
|
447
|
+
var o, r;
|
|
448
|
+
return (r = (o = t.message) == null ? void 0 : o.tool_calls) == null ? void 0 : r[t.toolCallIndex];
|
|
449
|
+
}), n = ue(), s = y(() => {
|
|
450
|
+
var v, p, m;
|
|
451
|
+
let o = n.toolCallDefaultStatus;
|
|
452
|
+
o && !be.includes(o) && (o = void 0);
|
|
453
453
|
const r = n.toolCallDefaultOpen;
|
|
454
454
|
let u = {
|
|
455
|
-
status:
|
|
455
|
+
status: o,
|
|
456
456
|
open: r
|
|
457
457
|
};
|
|
458
|
-
const
|
|
459
|
-
if (
|
|
460
|
-
const
|
|
461
|
-
if (
|
|
462
|
-
const { status:
|
|
463
|
-
|
|
458
|
+
const b = (v = e.value) == null ? void 0 : v.id;
|
|
459
|
+
if (b) {
|
|
460
|
+
const l = (m = (p = t.message.state) == null ? void 0 : p.toolCall) == null ? void 0 : m[b];
|
|
461
|
+
if (l) {
|
|
462
|
+
const { status: f, open: h, ...c } = l;
|
|
463
|
+
f && be.includes(f) && (u.status = f), h !== void 0 && (u.open = h), u = { ...u, ...c };
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
return u;
|
|
467
467
|
}), a = y(() => {
|
|
468
468
|
var r, u;
|
|
469
|
-
const
|
|
470
|
-
if (
|
|
471
|
-
return (u = n.toolCallResults) == null ? void 0 : u[
|
|
472
|
-
}), i =
|
|
473
|
-
return
|
|
469
|
+
const o = (r = e.value) == null ? void 0 : r.id;
|
|
470
|
+
if (o)
|
|
471
|
+
return (u = n.toolCallResults) == null ? void 0 : u[o];
|
|
472
|
+
}), i = L({});
|
|
473
|
+
return q(() => {
|
|
474
474
|
var u;
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
const v =
|
|
475
|
+
const o = (u = e.value) == null ? void 0 : u.function.arguments, r = a.value;
|
|
476
|
+
Ot().then(({ jsonrepair: b }) => {
|
|
477
|
+
const v = b(typeof o == "string" ? o || "{}" : JSON.stringify(o));
|
|
478
478
|
i.value = {
|
|
479
479
|
arguments: JSON.parse(v),
|
|
480
|
-
result: r ? JSON.parse(
|
|
480
|
+
result: r ? JSON.parse(b(r || "{}")) : void 0
|
|
481
481
|
};
|
|
482
|
-
}).catch((
|
|
483
|
-
console.warn(
|
|
482
|
+
}).catch((b) => {
|
|
483
|
+
console.warn(b);
|
|
484
484
|
});
|
|
485
485
|
}), {
|
|
486
486
|
toolCall: e,
|
|
487
|
-
toolCallWithResult:
|
|
488
|
-
state:
|
|
487
|
+
toolCallWithResult: We(i),
|
|
488
|
+
state: s
|
|
489
489
|
};
|
|
490
|
-
},
|
|
490
|
+
}, _e = /* @__PURE__ */ k({
|
|
491
491
|
__name: "BubbleBoxWrapper",
|
|
492
492
|
props: {
|
|
493
493
|
role: {},
|
|
@@ -498,18 +498,18 @@ const Dt = async () => {
|
|
|
498
498
|
},
|
|
499
499
|
setup(t) {
|
|
500
500
|
const e = t, n = Tt(() => e.messages, e.contentIndex);
|
|
501
|
-
return (
|
|
501
|
+
return (s, a) => (_(), I(Y(E(n).renderer), F({
|
|
502
502
|
"data-role": e.role,
|
|
503
503
|
"data-placement": e.placement,
|
|
504
504
|
"data-shape": e.shape
|
|
505
505
|
}, E(n).attributes), {
|
|
506
|
-
default:
|
|
507
|
-
C(
|
|
506
|
+
default: M(() => [
|
|
507
|
+
C(s.$slots, "default")
|
|
508
508
|
]),
|
|
509
509
|
_: 3
|
|
510
510
|
}, 16, ["data-role", "data-placement", "data-shape"]));
|
|
511
511
|
}
|
|
512
|
-
}),
|
|
512
|
+
}), me = /* @__PURE__ */ k({
|
|
513
513
|
__name: "BubbleContentWrapper",
|
|
514
514
|
props: {
|
|
515
515
|
message: {},
|
|
@@ -517,16 +517,16 @@ const Dt = async () => {
|
|
|
517
517
|
},
|
|
518
518
|
emits: ["state-change"],
|
|
519
519
|
setup(t, { emit: e }) {
|
|
520
|
-
const n = t,
|
|
521
|
-
return
|
|
520
|
+
const n = t, s = le(() => n.message, n.contentIndex), a = e;
|
|
521
|
+
return $t((o, r) => {
|
|
522
522
|
a("state-change", {
|
|
523
|
-
key:
|
|
523
|
+
key: o,
|
|
524
524
|
value: r,
|
|
525
525
|
contentIndex: n.contentIndex
|
|
526
526
|
});
|
|
527
|
-
}), (
|
|
527
|
+
}), (o, r) => (_(), I(Y(E(s)), D(P(n)), null, 16));
|
|
528
528
|
}
|
|
529
|
-
}),
|
|
529
|
+
}), Ft = ["data-role", "data-placement"], Pt = { class: "tr-bubble__body" }, Ht = { class: "tr-bubble__content" }, Gt = { class: "tr-bubble__after" }, Kt = /* @__PURE__ */ k({
|
|
530
530
|
__name: "Bubble",
|
|
531
531
|
props: {
|
|
532
532
|
content: {},
|
|
@@ -549,85 +549,85 @@ const Dt = async () => {
|
|
|
549
549
|
},
|
|
550
550
|
emits: ["state-change"],
|
|
551
551
|
setup(t, { emit: e }) {
|
|
552
|
-
const n = t,
|
|
553
|
-
|
|
554
|
-
const i =
|
|
555
|
-
var
|
|
556
|
-
if ((
|
|
557
|
-
return
|
|
558
|
-
const { role:
|
|
559
|
-
return [{ role:
|
|
560
|
-
}), u = (
|
|
561
|
-
const
|
|
562
|
-
return Array.isArray(
|
|
552
|
+
const n = t, s = te(() => n.contentResolver), a = e;
|
|
553
|
+
ce();
|
|
554
|
+
const i = Nt(), o = y(() => S(i)), r = y(() => {
|
|
555
|
+
var de;
|
|
556
|
+
if ((de = o.value) != null && de.messages.length)
|
|
557
|
+
return o.value.messages;
|
|
558
|
+
const { role: l, content: f, reasoning_content: h, tool_calls: c, tool_call_id: d, name: g, id: x, loading: A, state: Ue } = n;
|
|
559
|
+
return [{ role: l, content: f, reasoning_content: h, tool_calls: c, tool_call_id: d, name: g, id: x, loading: A, state: Ue }];
|
|
560
|
+
}), u = (l) => {
|
|
561
|
+
const f = s(l);
|
|
562
|
+
return Array.isArray(f) ? f : [{ type: "text", text: f || "" }];
|
|
563
563
|
};
|
|
564
|
-
|
|
565
|
-
const
|
|
564
|
+
It({ fallbackBoxRenderer: () => n.fallbackBoxRenderer }), Mt({ fallbackContentRenderer: () => n.fallbackContentRenderer });
|
|
565
|
+
const b = y(() => r.value.length === 0 ? !0 : n.hidden), v = y(() => {
|
|
566
566
|
if (n.contentRenderMode === "split" && r.value.length === 1) {
|
|
567
|
-
const
|
|
568
|
-
if (Array.isArray(
|
|
569
|
-
return
|
|
567
|
+
const l = s(r.value.at(0));
|
|
568
|
+
if (Array.isArray(l))
|
|
569
|
+
return l;
|
|
570
570
|
}
|
|
571
571
|
return null;
|
|
572
|
-
}),
|
|
573
|
-
return
|
|
572
|
+
}), p = T(Te, !1), m = L(null);
|
|
573
|
+
return p || Ge(m), (l, f) => Z((_(), B("div", {
|
|
574
574
|
class: "tr-bubble",
|
|
575
575
|
ref_key: "bubbleRef",
|
|
576
|
-
ref:
|
|
576
|
+
ref: m,
|
|
577
577
|
"data-role": n.role,
|
|
578
578
|
"data-placement": n.placement
|
|
579
579
|
}, [
|
|
580
|
-
C(
|
|
580
|
+
C(l.$slots, "prefix", {
|
|
581
581
|
messages: r.value,
|
|
582
582
|
role: t.role
|
|
583
583
|
}, void 0, !0),
|
|
584
|
-
|
|
585
|
-
n.avatar ? (_(),
|
|
584
|
+
R("div", Pt, [
|
|
585
|
+
n.avatar ? (_(), I(Y(n.avatar), {
|
|
586
586
|
key: 0,
|
|
587
|
-
class:
|
|
588
|
-
}, null, 8, ["class"])) :
|
|
589
|
-
|
|
590
|
-
v.value ? (_(!0), B(w, { key: 0 },
|
|
591
|
-
key:
|
|
587
|
+
class: K(["tr-bubble__avatar", l.$style["tr-bubble__avatar"]])
|
|
588
|
+
}, null, 8, ["class"])) : se("", !0),
|
|
589
|
+
R("div", Ht, [
|
|
590
|
+
v.value ? (_(!0), B(w, { key: 0 }, W(v.value, (h, c) => (_(), I(_e, {
|
|
591
|
+
key: c,
|
|
592
592
|
class: "tr-bubble__box",
|
|
593
593
|
role: n.role,
|
|
594
594
|
placement: n.placement,
|
|
595
595
|
shape: n.shape,
|
|
596
596
|
messages: r.value,
|
|
597
|
-
"content-index":
|
|
597
|
+
"content-index": c
|
|
598
598
|
}, {
|
|
599
|
-
default:
|
|
600
|
-
|
|
599
|
+
default: M(() => [
|
|
600
|
+
j(me, {
|
|
601
601
|
message: r.value.at(0),
|
|
602
|
-
"content-index":
|
|
603
|
-
onStateChange:
|
|
602
|
+
"content-index": c,
|
|
603
|
+
onStateChange: f[0] || (f[0] = (d) => a("state-change", { ...d, messageIndex: 0 }))
|
|
604
604
|
}, null, 8, ["message", "content-index"]),
|
|
605
|
-
C(
|
|
605
|
+
C(l.$slots, "content-footer", {
|
|
606
606
|
messages: r.value,
|
|
607
607
|
role: n.role,
|
|
608
|
-
contentIndex:
|
|
608
|
+
contentIndex: c
|
|
609
609
|
}, void 0, !0)
|
|
610
610
|
]),
|
|
611
611
|
_: 2
|
|
612
|
-
}, 1032, ["role", "placement", "shape", "messages", "content-index"]))), 128)) : (_(),
|
|
612
|
+
}, 1032, ["role", "placement", "shape", "messages", "content-index"]))), 128)) : (_(), I(_e, {
|
|
613
613
|
key: 1,
|
|
614
614
|
role: n.role,
|
|
615
615
|
placement: n.placement,
|
|
616
616
|
shape: n.shape,
|
|
617
617
|
messages: r.value
|
|
618
618
|
}, {
|
|
619
|
-
default:
|
|
620
|
-
(_(!0), B(w, null,
|
|
621
|
-
key: `message-${
|
|
619
|
+
default: M(() => [
|
|
620
|
+
(_(!0), B(w, null, W(r.value, (h, c) => (_(), B(w, {
|
|
621
|
+
key: `message-${c}`
|
|
622
622
|
}, [
|
|
623
|
-
(_(!0), B(w, null,
|
|
624
|
-
key: `content-${
|
|
623
|
+
(_(!0), B(w, null, W(u(h), (d, g) => (_(), I(me, {
|
|
624
|
+
key: `content-${g}`,
|
|
625
625
|
message: h,
|
|
626
|
-
"content-index":
|
|
627
|
-
onStateChange: (
|
|
626
|
+
"content-index": g,
|
|
627
|
+
onStateChange: (x) => a("state-change", { ...x, messageIndex: c })
|
|
628
628
|
}, null, 8, ["message", "content-index", "onStateChange"]))), 128))
|
|
629
629
|
], 64))), 128)),
|
|
630
|
-
C(
|
|
630
|
+
C(l.$slots, "content-footer", {
|
|
631
631
|
messages: r.value,
|
|
632
632
|
role: n.role
|
|
633
633
|
}, void 0, !0)
|
|
@@ -635,80 +635,80 @@ const Dt = async () => {
|
|
|
635
635
|
_: 3
|
|
636
636
|
}, 8, ["role", "placement", "shape", "messages"]))
|
|
637
637
|
]),
|
|
638
|
-
|
|
639
|
-
C(
|
|
638
|
+
R("div", Gt, [
|
|
639
|
+
C(l.$slots, "after", {
|
|
640
640
|
messages: r.value,
|
|
641
641
|
role: t.role
|
|
642
642
|
}, void 0, !0)
|
|
643
643
|
])
|
|
644
644
|
]),
|
|
645
|
-
C(
|
|
645
|
+
C(l.$slots, "suffix", {
|
|
646
646
|
messages: r.value,
|
|
647
647
|
role: t.role
|
|
648
648
|
}, void 0, !0)
|
|
649
|
-
], 8,
|
|
650
|
-
[
|
|
649
|
+
], 8, Ft)), [
|
|
650
|
+
[Q, !b.value]
|
|
651
651
|
]);
|
|
652
652
|
}
|
|
653
|
-
}),
|
|
653
|
+
}), Ut = {
|
|
654
654
|
"tr-bubble__avatar": "_tr-bubble__avatar_1r87c_2"
|
|
655
|
-
},
|
|
656
|
-
$style:
|
|
657
|
-
},
|
|
658
|
-
function
|
|
659
|
-
const n = H(t, (
|
|
660
|
-
a === !0 &&
|
|
655
|
+
}, Yt = {
|
|
656
|
+
$style: Ut
|
|
657
|
+
}, U = /* @__PURE__ */ N(Kt, [["__cssModules", Yt], ["__scopeId", "data-v-2d927bba"]]);
|
|
658
|
+
function ge(t, e) {
|
|
659
|
+
const n = H(t, (s, a) => {
|
|
660
|
+
a === !0 && s === !1 && (e(), n());
|
|
661
661
|
});
|
|
662
662
|
return n;
|
|
663
663
|
}
|
|
664
|
-
function
|
|
665
|
-
const { scrollOnMount:
|
|
664
|
+
function Jt(t, e, n) {
|
|
665
|
+
const { scrollOnMount: s = !0, bottomThreshold: a = 20, scrollThrottle: i = 0 } = n ?? {}, o = L(!0);
|
|
666
666
|
let r = !1;
|
|
667
|
-
const u = /* @__PURE__ */ new Set(),
|
|
668
|
-
const
|
|
669
|
-
if (
|
|
670
|
-
const
|
|
671
|
-
|
|
667
|
+
const u = /* @__PURE__ */ new Set(), b = () => et(t), { y: v, isScrolling: p, arrivedState: m } = qe(b, { throttle: i }), l = (c) => c.scrollHeight - c.scrollTop - c.clientHeight <= a, f = async (c = "auto") => {
|
|
668
|
+
const d = S(b);
|
|
669
|
+
if (d && (await ee(), d.scrollTo({ top: d.scrollHeight, behavior: c }), c === "smooth" && !l(d))) {
|
|
670
|
+
const g = ge(p, () => {
|
|
671
|
+
d.scrollTo({ top: d.scrollHeight, behavior: "auto" }), u.delete(g);
|
|
672
672
|
});
|
|
673
|
-
u.add(
|
|
673
|
+
u.add(g);
|
|
674
674
|
}
|
|
675
675
|
}, h = () => {
|
|
676
|
-
r || !
|
|
677
|
-
r = !1, await
|
|
676
|
+
r || !o.value || (r = !0, requestAnimationFrame(async () => {
|
|
677
|
+
r = !1, await f("auto");
|
|
678
678
|
}));
|
|
679
679
|
};
|
|
680
680
|
return H(
|
|
681
681
|
v,
|
|
682
682
|
() => {
|
|
683
|
-
const
|
|
684
|
-
|
|
683
|
+
const c = S(b);
|
|
684
|
+
c && (o.value = l(c));
|
|
685
685
|
},
|
|
686
686
|
{ flush: "post" }
|
|
687
|
-
),
|
|
687
|
+
), Ze(
|
|
688
688
|
e,
|
|
689
689
|
() => {
|
|
690
690
|
h();
|
|
691
691
|
},
|
|
692
692
|
{ flush: "post", throttle: 100 }
|
|
693
|
-
),
|
|
694
|
-
|
|
695
|
-
}),
|
|
696
|
-
u.forEach((
|
|
697
|
-
|
|
693
|
+
), ve(() => {
|
|
694
|
+
s && f("smooth");
|
|
695
|
+
}), je(() => {
|
|
696
|
+
u.forEach((c) => {
|
|
697
|
+
c();
|
|
698
698
|
}), u.clear();
|
|
699
|
-
}),
|
|
700
|
-
if (
|
|
701
|
-
const
|
|
702
|
-
|
|
699
|
+
}), Qe("keydown", (c) => {
|
|
700
|
+
if (c.key === "End" && !o.value) {
|
|
701
|
+
const d = ge(p, () => {
|
|
702
|
+
f("auto"), u.delete(d);
|
|
703
703
|
});
|
|
704
|
-
u.add(
|
|
704
|
+
u.add(d);
|
|
705
705
|
}
|
|
706
706
|
}), {
|
|
707
|
-
scrollToBottom:
|
|
708
|
-
arrivedState:
|
|
707
|
+
scrollToBottom: f,
|
|
708
|
+
arrivedState: m
|
|
709
709
|
};
|
|
710
710
|
}
|
|
711
|
-
const
|
|
711
|
+
const Wt = /* @__PURE__ */ k({
|
|
712
712
|
__name: "BubbleItem",
|
|
713
713
|
props: {
|
|
714
714
|
messageGroup: {},
|
|
@@ -718,29 +718,29 @@ const jt = /* @__PURE__ */ k({
|
|
|
718
718
|
},
|
|
719
719
|
emits: ["state-change"],
|
|
720
720
|
setup(t, { emit: e }) {
|
|
721
|
-
const n = t,
|
|
722
|
-
return
|
|
721
|
+
const n = t, s = e;
|
|
722
|
+
return At(() => n.messageGroup), (a, i) => (_(), I(U, F(t.roleConfig, {
|
|
723
723
|
role: t.messageGroup.role,
|
|
724
724
|
"content-render-mode": t.contentRenderMode,
|
|
725
725
|
"content-resolver": t.contentResolver,
|
|
726
|
-
onStateChange: i[0] || (i[0] = (
|
|
726
|
+
onStateChange: i[0] || (i[0] = (o) => s("state-change", o))
|
|
727
727
|
}), {
|
|
728
|
-
prefix:
|
|
729
|
-
C(a.$slots, "prefix", D(
|
|
728
|
+
prefix: M((o) => [
|
|
729
|
+
C(a.$slots, "prefix", D(P(o)))
|
|
730
730
|
]),
|
|
731
|
-
suffix:
|
|
732
|
-
C(a.$slots, "suffix", D(
|
|
731
|
+
suffix: M((o) => [
|
|
732
|
+
C(a.$slots, "suffix", D(P(o)))
|
|
733
733
|
]),
|
|
734
|
-
"content-footer":
|
|
735
|
-
C(a.$slots, "content-footer", D(
|
|
734
|
+
"content-footer": M((o) => [
|
|
735
|
+
C(a.$slots, "content-footer", D(P(o)))
|
|
736
736
|
]),
|
|
737
|
-
after:
|
|
738
|
-
C(a.$slots, "after", D(
|
|
737
|
+
after: M((o) => [
|
|
738
|
+
C(a.$slots, "after", D(P(o)))
|
|
739
739
|
]),
|
|
740
740
|
_: 3
|
|
741
741
|
}, 16, ["role", "content-render-mode", "content-resolver"]));
|
|
742
742
|
}
|
|
743
|
-
}),
|
|
743
|
+
}), jt = /* @__PURE__ */ k({
|
|
744
744
|
__name: "BubbleList",
|
|
745
745
|
props: {
|
|
746
746
|
messages: {},
|
|
@@ -754,107 +754,100 @@ const jt = /* @__PURE__ */ k({
|
|
|
754
754
|
},
|
|
755
755
|
emits: ["state-change"],
|
|
756
756
|
setup(t, { expose: e, emit: n }) {
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
const i =
|
|
760
|
-
var
|
|
761
|
-
return
|
|
762
|
-
},
|
|
763
|
-
let
|
|
757
|
+
const s = t, a = n;
|
|
758
|
+
ce(), $(Te, !0);
|
|
759
|
+
const i = (p) => {
|
|
760
|
+
var m, l;
|
|
761
|
+
return p ? !!((l = (m = s.roleConfigs) == null ? void 0 : m[p]) != null && l.hidden) : !1;
|
|
762
|
+
}, o = L(null);
|
|
763
|
+
let r = async () => {
|
|
764
764
|
};
|
|
765
|
-
if (
|
|
766
|
-
const
|
|
767
|
-
var
|
|
765
|
+
if (s.autoScroll) {
|
|
766
|
+
const p = y(() => s.messages.at(-1)), { scrollToBottom: m } = Jt(o, () => {
|
|
767
|
+
var l, f;
|
|
768
768
|
return [
|
|
769
|
-
|
|
770
|
-
(
|
|
771
|
-
(
|
|
769
|
+
s.messages.length,
|
|
770
|
+
(l = p.value) == null ? void 0 : l.content,
|
|
771
|
+
(f = p.value) == null ? void 0 : f.reasoning_content
|
|
772
772
|
];
|
|
773
773
|
});
|
|
774
|
-
|
|
774
|
+
r = m, H(
|
|
775
775
|
() => {
|
|
776
|
-
var
|
|
777
|
-
return (
|
|
776
|
+
var l;
|
|
777
|
+
return (l = p.value) == null ? void 0 : l.role;
|
|
778
778
|
},
|
|
779
|
-
async (
|
|
780
|
-
|
|
779
|
+
async (l) => {
|
|
780
|
+
l === "user" && (await ee(), m("smooth"));
|
|
781
781
|
}
|
|
782
782
|
);
|
|
783
783
|
}
|
|
784
|
-
|
|
785
|
-
const
|
|
786
|
-
const
|
|
787
|
-
let
|
|
788
|
-
for (const [f,
|
|
789
|
-
const
|
|
790
|
-
g ? (
|
|
791
|
-
role:
|
|
792
|
-
messages: [
|
|
784
|
+
Ge(o);
|
|
785
|
+
const u = (p) => {
|
|
786
|
+
const m = [];
|
|
787
|
+
let l = !1;
|
|
788
|
+
for (const [f, h] of p.entries()) {
|
|
789
|
+
const c = m[m.length - 1], d = h.role || "", g = i(h.role);
|
|
790
|
+
c && (l && g || c.role === d && l === g) ? (c.messages.push(h), c.messageIndexes.push(f)) : m.push({
|
|
791
|
+
role: d,
|
|
792
|
+
messages: [h],
|
|
793
793
|
messageIndexes: [f],
|
|
794
794
|
startIndex: f
|
|
795
|
-
}),
|
|
796
|
-
role: I,
|
|
797
|
-
messages: [l],
|
|
798
|
-
messageIndexes: [f],
|
|
799
|
-
startIndex: f
|
|
800
|
-
}), c = !1), h = P;
|
|
795
|
+
}), l = g;
|
|
801
796
|
}
|
|
802
|
-
return
|
|
803
|
-
},
|
|
804
|
-
const
|
|
805
|
-
let
|
|
806
|
-
for (const [
|
|
807
|
-
const
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
startIndex: l
|
|
818
|
-
}), h = !1), f = oe;
|
|
797
|
+
return m;
|
|
798
|
+
}, b = (p, m) => {
|
|
799
|
+
const l = [];
|
|
800
|
+
let f = !1;
|
|
801
|
+
for (const [h, c] of p.entries()) {
|
|
802
|
+
const d = l[l.length - 1], g = c.role === m, x = c.role || "", A = i(c.role);
|
|
803
|
+
d && // divider 消息(分割角色)永远不与任何组进行合并
|
|
804
|
+
!g && // divider 组(分割角色)不允许被追加消息,确保 divider 组永远只有 1 条 message
|
|
805
|
+
d.role !== m && // hidden / 非 hidden 分组隔离
|
|
806
|
+
f === A ? (d.messages.push(c), d.messageIndexes.push(h)) : l.push({
|
|
807
|
+
role: g ? m : x,
|
|
808
|
+
messages: [c],
|
|
809
|
+
messageIndexes: [h],
|
|
810
|
+
startIndex: h
|
|
811
|
+
}), f = A;
|
|
819
812
|
}
|
|
820
|
-
return
|
|
821
|
-
},
|
|
813
|
+
return l;
|
|
814
|
+
}, v = y(() => s.messages.length === 0 ? [] : typeof s.groupStrategy == "function" ? s.groupStrategy(s.messages, s.dividerRole) : s.groupStrategy === "consecutive" ? u(s.messages) : b(s.messages, s.dividerRole));
|
|
822
815
|
return e({
|
|
823
|
-
scrollToBottom:
|
|
824
|
-
}), (
|
|
816
|
+
scrollToBottom: r
|
|
817
|
+
}), (p, m) => (_(), B("div", {
|
|
825
818
|
class: "tr-bubble-list",
|
|
826
819
|
ref_key: "listRef",
|
|
827
|
-
ref:
|
|
820
|
+
ref: o
|
|
828
821
|
}, [
|
|
829
|
-
(_(!0), B(w, null,
|
|
830
|
-
var
|
|
831
|
-
return _(),
|
|
832
|
-
key:
|
|
833
|
-
role:
|
|
834
|
-
"role-config": (
|
|
835
|
-
"message-group":
|
|
836
|
-
"content-render-mode":
|
|
837
|
-
"content-resolver":
|
|
838
|
-
onStateChange: (
|
|
822
|
+
(_(!0), B(w, null, W(v.value, (l, f) => {
|
|
823
|
+
var h;
|
|
824
|
+
return _(), I(Wt, {
|
|
825
|
+
key: f,
|
|
826
|
+
role: l.role || s.fallbackRole,
|
|
827
|
+
"role-config": (h = s.roleConfigs) == null ? void 0 : h[l.role || s.fallbackRole],
|
|
828
|
+
"message-group": l,
|
|
829
|
+
"content-render-mode": s.contentRenderMode,
|
|
830
|
+
"content-resolver": s.contentResolver,
|
|
831
|
+
onStateChange: (c) => a("state-change", { ...c, messageIndex: l.startIndex + c.messageIndex })
|
|
839
832
|
}, {
|
|
840
|
-
prefix:
|
|
841
|
-
C(
|
|
842
|
-
messageIndexes:
|
|
833
|
+
prefix: M((c) => [
|
|
834
|
+
C(p.$slots, "prefix", F({ ref_for: !0 }, c, {
|
|
835
|
+
messageIndexes: l.messageIndexes
|
|
843
836
|
}), void 0, !0)
|
|
844
837
|
]),
|
|
845
|
-
suffix:
|
|
846
|
-
C(
|
|
847
|
-
messageIndexes:
|
|
838
|
+
suffix: M((c) => [
|
|
839
|
+
C(p.$slots, "suffix", F({ ref_for: !0 }, c, {
|
|
840
|
+
messageIndexes: l.messageIndexes
|
|
848
841
|
}), void 0, !0)
|
|
849
842
|
]),
|
|
850
|
-
"content-footer":
|
|
851
|
-
C(
|
|
852
|
-
messageIndexes:
|
|
843
|
+
"content-footer": M((c) => [
|
|
844
|
+
C(p.$slots, "content-footer", F({ ref_for: !0 }, c, {
|
|
845
|
+
messageIndexes: l.messageIndexes
|
|
853
846
|
}), void 0, !0)
|
|
854
847
|
]),
|
|
855
|
-
after:
|
|
856
|
-
C(
|
|
857
|
-
messageIndexes:
|
|
848
|
+
after: M((c) => [
|
|
849
|
+
C(p.$slots, "after", F({ ref_for: !0 }, c, {
|
|
850
|
+
messageIndexes: l.messageIndexes
|
|
858
851
|
}), void 0, !0)
|
|
859
852
|
]),
|
|
860
853
|
_: 2
|
|
@@ -862,7 +855,7 @@ const jt = /* @__PURE__ */ k({
|
|
|
862
855
|
}), 128))
|
|
863
856
|
], 512));
|
|
864
857
|
}
|
|
865
|
-
}),
|
|
858
|
+
}), V = /* @__PURE__ */ N(jt, [["__scopeId", "data-v-e217fbb7"]]), X = /* @__PURE__ */ k({
|
|
866
859
|
__name: "BubbleProvider",
|
|
867
860
|
props: {
|
|
868
861
|
boxRendererMatches: {},
|
|
@@ -873,74 +866,74 @@ const jt = /* @__PURE__ */ k({
|
|
|
873
866
|
},
|
|
874
867
|
setup(t) {
|
|
875
868
|
const e = t;
|
|
876
|
-
|
|
877
|
-
const n = y(() => (e.boxRendererMatches || []).concat(
|
|
878
|
-
return St({ boxRendererMatches: n, fallbackBoxRenderer: a }),
|
|
869
|
+
ce(e.store);
|
|
870
|
+
const n = y(() => (e.boxRendererMatches || []).concat(we).sort((o, r) => (o.priority ?? 0) - (r.priority ?? 0))), s = y(() => (e.contentRendererMatches || []).concat(De).sort((o, r) => (o.priority ?? 0) - (r.priority ?? 0))), a = y(() => e.fallbackBoxRenderer || Fe), i = y(() => e.fallbackContentRenderer || Pe);
|
|
871
|
+
return St({ boxRendererMatches: n, fallbackBoxRenderer: a }), Lt({ contentRendererMatches: s, fallbackContentRenderer: i }), (o, r) => C(o.$slots, "default");
|
|
879
872
|
}
|
|
880
|
-
}),
|
|
873
|
+
}), zt = ["innerHTML"], Vt = /* @__PURE__ */ k({
|
|
881
874
|
__name: "Markdown",
|
|
882
875
|
props: {
|
|
883
876
|
message: {},
|
|
884
877
|
contentIndex: {}
|
|
885
878
|
},
|
|
886
879
|
setup(t) {
|
|
887
|
-
const e = t, { contentText: n } =
|
|
888
|
-
|
|
889
|
-
|
|
880
|
+
const e = t, { contentText: n } = ie(e), s = L(null);
|
|
881
|
+
ve(async () => {
|
|
882
|
+
s.value = await wt();
|
|
890
883
|
});
|
|
891
|
-
const { mdConfig: a, dompurifyConfig: i } =
|
|
892
|
-
return
|
|
893
|
-
if (
|
|
894
|
-
const { markdown: r, dompurify: u } =
|
|
895
|
-
|
|
884
|
+
const { mdConfig: a, dompurifyConfig: i } = ue(), o = L("");
|
|
885
|
+
return q(() => {
|
|
886
|
+
if (s.value) {
|
|
887
|
+
const { markdown: r, dompurify: u } = s.value, b = r(a || {}).render(n.value);
|
|
888
|
+
o.value = u.sanitize(b, i);
|
|
896
889
|
}
|
|
897
|
-
}), (r, u) =>
|
|
890
|
+
}), (r, u) => o.value ? (_(), B("div", {
|
|
898
891
|
key: 0,
|
|
899
892
|
class: "tr-bubble__markdown markdown-body",
|
|
900
893
|
"data-type": "markdown",
|
|
901
|
-
innerHTML:
|
|
902
|
-
}, null, 8,
|
|
894
|
+
innerHTML: o.value
|
|
895
|
+
}, null, 8, zt)) : (_(), I(ae, D(F({ key: 1 }, e)), null, 16));
|
|
903
896
|
}
|
|
904
|
-
}),
|
|
905
|
-
Box:
|
|
906
|
-
Image:
|
|
907
|
-
Loading:
|
|
908
|
-
Markdown:
|
|
909
|
-
Reasoning:
|
|
910
|
-
Text:
|
|
911
|
-
Tool:
|
|
912
|
-
ToolRole:
|
|
913
|
-
Tools:
|
|
897
|
+
}), Xt = /* @__PURE__ */ N(Vt, [["__scopeId", "data-v-eb1c196f"]]), sn = {
|
|
898
|
+
Box: re,
|
|
899
|
+
Image: Le,
|
|
900
|
+
Loading: Me,
|
|
901
|
+
Markdown: Xt,
|
|
902
|
+
Reasoning: $e,
|
|
903
|
+
Text: ae,
|
|
904
|
+
Tool: Ne,
|
|
905
|
+
ToolRole: Ae,
|
|
906
|
+
Tools: Oe
|
|
914
907
|
};
|
|
915
|
-
|
|
908
|
+
U.name = "TrBubble";
|
|
909
|
+
const qt = function(t) {
|
|
910
|
+
t.component(U.name, U);
|
|
911
|
+
};
|
|
912
|
+
U.install = qt;
|
|
913
|
+
const rn = U;
|
|
914
|
+
V.name = "TrBubbleList";
|
|
916
915
|
const Zt = function(t) {
|
|
917
|
-
t.component(
|
|
916
|
+
t.component(V.name, V);
|
|
918
917
|
};
|
|
919
|
-
|
|
920
|
-
const an =
|
|
921
|
-
|
|
918
|
+
V.install = Zt;
|
|
919
|
+
const an = V;
|
|
920
|
+
X.name = "TrBubbleProvider";
|
|
922
921
|
const Qt = function(t) {
|
|
923
|
-
t.component(
|
|
924
|
-
};
|
|
925
|
-
q.install = Qt;
|
|
926
|
-
const ln = q;
|
|
927
|
-
Z.name = "TrBubbleProvider";
|
|
928
|
-
const en = function(t) {
|
|
929
|
-
t.component(Z.name, Z);
|
|
922
|
+
t.component(X.name, X);
|
|
930
923
|
};
|
|
931
|
-
|
|
932
|
-
const
|
|
924
|
+
X.install = Qt;
|
|
925
|
+
const ln = X;
|
|
933
926
|
export {
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
927
|
+
rn as B,
|
|
928
|
+
an as a,
|
|
929
|
+
ln as b,
|
|
930
|
+
G as c,
|
|
931
|
+
sn as d,
|
|
939
932
|
Tt as e,
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
933
|
+
le as f,
|
|
934
|
+
He as g,
|
|
935
|
+
ie as h,
|
|
936
|
+
Ke as i,
|
|
937
|
+
Dt as j,
|
|
938
|
+
Jt as u
|
|
946
939
|
};
|