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