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