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