@fv-ui/ai-chat 0.4.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -3
- package/dist/index.d.ts +181 -28
- package/dist/style.css +1 -1
- package/es/index.mjs +272 -72
- package/lib/index.js +271 -71
- package/package.json +1 -1
package/es/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import DOMPurify from 'dompurify';
|
|
|
5
5
|
import Prism$1 from 'prismjs';
|
|
6
6
|
import { ElAvatar, ElButton, ElIcon, ElPopover, ElMessage, ElDialog, ElDropdown, ElDropdownMenu, ElDropdownItem, ElMessageBox, ElTooltip, ElSelect, ElOption } from 'element-plus';
|
|
7
7
|
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
|
|
8
|
-
import { ArrowDown, Close, Check, Delete, Microphone, Promotion, VideoPause, Loading, SuccessFilled, CircleCloseFilled, ChatDotRound, Cpu, Cellphone, Link, Folder, Headset, Film, Monitor, DataAnalysis, Document, Notebook, Picture, Paperclip, RefreshRight, MoreFilled, User, DocumentCopy, ArrowUp, CopyDocument, Download, FullScreen } from '@element-plus/icons-vue';
|
|
8
|
+
import { ArrowDown, Close, Check, Delete, Microphone, Promotion, VideoPause, Loading, SuccessFilled, CircleCloseFilled, ChatDotRound, Cpu, Cellphone, Link, Folder, Headset, Film, Monitor, DataAnalysis, Document, Notebook, Picture, Paperclip, RefreshRight, MoreFilled, User, DocumentCopy, ArrowUp, Bottom, CopyDocument, Download, FullScreen } from '@element-plus/icons-vue';
|
|
9
9
|
|
|
10
10
|
function unwrapPlugin(plugin) {
|
|
11
11
|
const candidate = plugin && typeof plugin === "object" && "default" in plugin ? plugin.default : plugin;
|
|
@@ -3343,7 +3343,7 @@ const _hoisted_16$1 = {
|
|
|
3343
3343
|
key: 1,
|
|
3344
3344
|
class: "fv-editor-footer"
|
|
3345
3345
|
};
|
|
3346
|
-
const _hoisted_17 = { class: "fv-editor-select-dialog" };
|
|
3346
|
+
const _hoisted_17$1 = { class: "fv-editor-select-dialog" };
|
|
3347
3347
|
const _hoisted_18 = { class: "fv-editor-select-title" };
|
|
3348
3348
|
const _hoisted_19 = { class: "fv-editor-select-grid" };
|
|
3349
3349
|
const _hoisted_20 = ["onClick"];
|
|
@@ -4306,7 +4306,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
4306
4306
|
onClose: closeSelectDialog
|
|
4307
4307
|
}, {
|
|
4308
4308
|
default: withCtx(() => [
|
|
4309
|
-
createElementVNode("div", _hoisted_17, [
|
|
4309
|
+
createElementVNode("div", _hoisted_17$1, [
|
|
4310
4310
|
(openBlock(true), createElementBlock(
|
|
4311
4311
|
Fragment,
|
|
4312
4312
|
null,
|
|
@@ -5615,6 +5615,7 @@ function createMessageTree(initial) {
|
|
|
5615
5615
|
role: node.role,
|
|
5616
5616
|
content: node.content,
|
|
5617
5617
|
reasoning: node.reasoning,
|
|
5618
|
+
toolSteps: node.toolSteps ? node.toolSteps.map((s) => ({ ...s })) : void 0,
|
|
5618
5619
|
files: node.files ? [...node.files] : void 0,
|
|
5619
5620
|
modelIdx: node.modelIdx,
|
|
5620
5621
|
model: node.model,
|
|
@@ -5895,6 +5896,17 @@ ${fileParts.join("\n")}` });
|
|
|
5895
5896
|
msgs.edit(assistantId, { backendId: id });
|
|
5896
5897
|
},
|
|
5897
5898
|
onTool: (ev) => {
|
|
5899
|
+
const steps = [...msgs.messages.value[assistantId]?.toolSteps ?? []];
|
|
5900
|
+
if (ev.status === "start") {
|
|
5901
|
+
steps.push({
|
|
5902
|
+
key: `${ev.toolName}-${steps.length}`,
|
|
5903
|
+
title: options.toolStepLabel ? options.toolStepLabel(ev.toolName) : ev.toolName,
|
|
5904
|
+
status: "loading"
|
|
5905
|
+
});
|
|
5906
|
+
} else if (steps.length) {
|
|
5907
|
+
steps[steps.length - 1] = { ...steps[steps.length - 1], status: "success" };
|
|
5908
|
+
}
|
|
5909
|
+
msgs.edit(assistantId, { toolSteps: steps });
|
|
5898
5910
|
options.onToolEvent?.(ev);
|
|
5899
5911
|
},
|
|
5900
5912
|
onDone: () => {
|
|
@@ -6008,50 +6020,51 @@ const _hoisted_2$3 = {
|
|
|
6008
6020
|
key: 0,
|
|
6009
6021
|
class: "fv-msg-avatar"
|
|
6010
6022
|
};
|
|
6011
|
-
const _hoisted_3$3 =
|
|
6012
|
-
const _hoisted_4$2 =
|
|
6023
|
+
const _hoisted_3$3 = ["src"];
|
|
6024
|
+
const _hoisted_4$2 = ["src"];
|
|
6025
|
+
const _hoisted_5 = { class: "fv-msg-main" };
|
|
6026
|
+
const _hoisted_6 = {
|
|
6013
6027
|
key: 0,
|
|
6014
6028
|
class: "fv-msg-header"
|
|
6015
6029
|
};
|
|
6016
|
-
const
|
|
6017
|
-
|
|
6018
|
-
key: 0,
|
|
6030
|
+
const _hoisted_7 = {
|
|
6031
|
+
key: 2,
|
|
6019
6032
|
class: "fv-msg-model"
|
|
6020
6033
|
};
|
|
6021
|
-
const
|
|
6034
|
+
const _hoisted_8 = {
|
|
6022
6035
|
key: 1,
|
|
6023
6036
|
class: "fv-msg-files"
|
|
6024
6037
|
};
|
|
6025
|
-
const
|
|
6026
|
-
const
|
|
6038
|
+
const _hoisted_9 = ["src", "alt"];
|
|
6039
|
+
const _hoisted_10 = {
|
|
6027
6040
|
key: 1,
|
|
6028
6041
|
class: "fv-msg-file-name"
|
|
6029
6042
|
};
|
|
6030
|
-
const
|
|
6031
|
-
key:
|
|
6043
|
+
const _hoisted_11 = {
|
|
6044
|
+
key: 4,
|
|
6032
6045
|
class: "fv-msg-content"
|
|
6033
6046
|
};
|
|
6034
|
-
const
|
|
6047
|
+
const _hoisted_12 = {
|
|
6035
6048
|
key: 0,
|
|
6036
6049
|
class: "fv-msg-error"
|
|
6037
6050
|
};
|
|
6038
|
-
const
|
|
6051
|
+
const _hoisted_13 = {
|
|
6039
6052
|
key: 2,
|
|
6040
6053
|
class: "fv-msg-pending"
|
|
6041
6054
|
};
|
|
6042
|
-
const _hoisted_13 = {
|
|
6043
|
-
key: 4,
|
|
6044
|
-
class: "fv-msg-content fv-msg-content-user"
|
|
6045
|
-
};
|
|
6046
6055
|
const _hoisted_14 = {
|
|
6047
6056
|
key: 5,
|
|
6048
|
-
class: "fv-msg-
|
|
6057
|
+
class: "fv-msg-content fv-msg-content-user"
|
|
6049
6058
|
};
|
|
6050
6059
|
const _hoisted_15 = {
|
|
6060
|
+
key: 6,
|
|
6061
|
+
class: "fv-msg-actions"
|
|
6062
|
+
};
|
|
6063
|
+
const _hoisted_16 = {
|
|
6051
6064
|
key: 0,
|
|
6052
6065
|
class: "fv-msg-branch"
|
|
6053
6066
|
};
|
|
6054
|
-
const
|
|
6067
|
+
const _hoisted_17 = { class: "fv-msg-branch-label" };
|
|
6055
6068
|
var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
6056
6069
|
...{ name: "FvAiMessage" },
|
|
6057
6070
|
__name: "index",
|
|
@@ -6062,6 +6075,12 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
6062
6075
|
showBranchSwitch: { type: Boolean, required: false, default: true },
|
|
6063
6076
|
showUserAvatar: { type: Boolean, required: false, default: true },
|
|
6064
6077
|
showUserName: { type: Boolean, required: false, default: true },
|
|
6078
|
+
showAssistantAvatar: { type: Boolean, required: false, default: true },
|
|
6079
|
+
showAssistantName: { type: Boolean, required: false, default: true },
|
|
6080
|
+
userAvatar: { type: String, required: false, default: "" },
|
|
6081
|
+
assistantAvatar: { type: String, required: false, default: "" },
|
|
6082
|
+
userName: { type: String, required: false, default: "" },
|
|
6083
|
+
assistantName: { type: String, required: false, default: "" },
|
|
6065
6084
|
autoCollapse: { type: Boolean, required: false, default: true }
|
|
6066
6085
|
},
|
|
6067
6086
|
emits: ["copy", "regenerate", "branch-change"],
|
|
@@ -6076,6 +6095,19 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
6076
6095
|
return "end";
|
|
6077
6096
|
});
|
|
6078
6097
|
const hasReasoning = computed(() => !!props.message.reasoning);
|
|
6098
|
+
const hasToolSteps = computed(() => (props.message.toolSteps?.length ?? 0) > 0);
|
|
6099
|
+
const toolChainItems = computed(() => {
|
|
6100
|
+
const steps = props.message.toolSteps ?? [];
|
|
6101
|
+
const running = props.message.status === "pending" || props.message.status === "streaming";
|
|
6102
|
+
return steps.map((s) => {
|
|
6103
|
+
const loading = running && s.status !== "error" && s.status !== "success";
|
|
6104
|
+
return {
|
|
6105
|
+
...s,
|
|
6106
|
+
status: loading ? "loading" : s.status ?? "success",
|
|
6107
|
+
title: `${loading ? "\u6B63\u5728\u67E5\u8BE2" : "\u5DF2\u67E5\u8BE2"}${s.title ?? ""}`
|
|
6108
|
+
};
|
|
6109
|
+
});
|
|
6110
|
+
});
|
|
6079
6111
|
const modelLabel = computed(() => props.message.model ?? "");
|
|
6080
6112
|
function onCopy() {
|
|
6081
6113
|
emit("copy", props.message);
|
|
@@ -6092,50 +6124,70 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
6092
6124
|
class: normalizeClass(["fv-msg", [`is-${__props.message.role}`, { "is-error": __props.message.status === "error", "is-user": isUser.value }]]),
|
|
6093
6125
|
"data-message-id": __props.message.id
|
|
6094
6126
|
}, [
|
|
6095
|
-
createCommentVNode(" \u5934\u50CF:user \u53F3\u4FA7(\u81EA\u8EAB),assistant \u5DE6\u4FA7
|
|
6096
|
-
|
|
6127
|
+
createCommentVNode(" \u5934\u50CF:user \u53F3\u4FA7(\u81EA\u8EAB),assistant \u5DE6\u4FA7;\u663E\u9690\u5F00\u5173\u5173\u95ED\u65F6\u4E0D\u6E32\u67D3;\r\n \u4F18\u5148\u7EA7:message-avatar \u6574\u4F53\u63D2\u69FD > user-avatar/assistant-avatar \u7EC6\u5206\u63D2\u69FD > props \u56FE\u7247 > \u5185\u7F6E\u56FE\u6807 "),
|
|
6128
|
+
(isUser.value ? __props.showUserAvatar : __props.showAssistantAvatar) ? (openBlock(), createElementBlock("div", _hoisted_2$3, [
|
|
6097
6129
|
renderSlot(_ctx.$slots, "message-avatar", { message: __props.message }, () => [
|
|
6098
|
-
isUser.value ? (
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6130
|
+
isUser.value ? renderSlot(_ctx.$slots, "user-avatar", {}, () => [
|
|
6131
|
+
__props.userAvatar ? (openBlock(), createElementBlock("img", {
|
|
6132
|
+
key: 0,
|
|
6133
|
+
class: "fv-msg-avatar-img",
|
|
6134
|
+
src: __props.userAvatar,
|
|
6135
|
+
alt: ""
|
|
6136
|
+
}, null, 8, _hoisted_3$3)) : (openBlock(), createBlock(unref(ElIcon), {
|
|
6137
|
+
key: 1,
|
|
6138
|
+
class: "fv-msg-avatar-user"
|
|
6139
|
+
}, {
|
|
6140
|
+
default: withCtx(() => [
|
|
6141
|
+
createVNode(unref(User))
|
|
6142
|
+
]),
|
|
6143
|
+
_: 1
|
|
6144
|
+
/* STABLE */
|
|
6145
|
+
}))
|
|
6146
|
+
], void 0, 0) : renderSlot(_ctx.$slots, "assistant-avatar", {}, () => [
|
|
6147
|
+
__props.assistantAvatar ? (openBlock(), createElementBlock("img", {
|
|
6148
|
+
key: 0,
|
|
6149
|
+
class: "fv-msg-avatar-img",
|
|
6150
|
+
src: __props.assistantAvatar,
|
|
6151
|
+
alt: ""
|
|
6152
|
+
}, null, 8, _hoisted_4$2)) : (openBlock(), createBlock(unref(ElIcon), {
|
|
6153
|
+
key: 1,
|
|
6154
|
+
class: "fv-msg-avatar-bot"
|
|
6155
|
+
}, {
|
|
6156
|
+
default: withCtx(() => [
|
|
6157
|
+
createVNode(unref(ChatDotRound))
|
|
6158
|
+
]),
|
|
6159
|
+
_: 1
|
|
6160
|
+
/* STABLE */
|
|
6161
|
+
}))
|
|
6162
|
+
], void 0, 1)
|
|
6117
6163
|
])
|
|
6118
6164
|
])) : createCommentVNode("v-if", true),
|
|
6119
|
-
createElementVNode("div",
|
|
6120
|
-
createCommentVNode(" \u5934\u90E8:\u89D2\u8272\u540D + \u6A21\u578B\u6807\u8BB0
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
),
|
|
6165
|
+
createElementVNode("div", _hoisted_5, [
|
|
6166
|
+
createCommentVNode(" \u5934\u90E8:\u89D2\u8272\u540D + \u6A21\u578B\u6807\u8BB0;\u663E\u9690\u5F00\u5173\u5173\u95ED\u65F6\u4E0D\u6E32\u67D3;\u7EC6\u5206\u63D2\u69FD > props > \u9ED8\u8BA4\u6587\u6848 "),
|
|
6167
|
+
(isUser.value ? __props.showUserName : __props.showAssistantName) ? (openBlock(), createElementBlock("div", _hoisted_6, [
|
|
6168
|
+
isUser.value ? renderSlot(_ctx.$slots, "user-name", { message: __props.message }, () => [
|
|
6169
|
+
createTextVNode(
|
|
6170
|
+
toDisplayString(__props.userName || "\u4F60"),
|
|
6171
|
+
1
|
|
6172
|
+
/* TEXT */
|
|
6173
|
+
)
|
|
6174
|
+
], void 0, 0) : renderSlot(_ctx.$slots, "assistant-name", { message: __props.message }, () => [
|
|
6175
|
+
createTextVNode(
|
|
6176
|
+
toDisplayString(__props.assistantName || "\u52A9\u624B"),
|
|
6177
|
+
1
|
|
6178
|
+
/* TEXT */
|
|
6179
|
+
)
|
|
6180
|
+
], void 0, 1),
|
|
6129
6181
|
!isUser.value && modelLabel.value ? (openBlock(), createElementBlock(
|
|
6130
6182
|
"span",
|
|
6131
|
-
|
|
6183
|
+
_hoisted_7,
|
|
6132
6184
|
toDisplayString(modelLabel.value),
|
|
6133
6185
|
1
|
|
6134
6186
|
/* TEXT */
|
|
6135
6187
|
)) : createCommentVNode("v-if", true)
|
|
6136
6188
|
])) : createCommentVNode("v-if", true),
|
|
6137
6189
|
createCommentVNode(" \u9644\u4EF6:user \u6D88\u606F files \u4EE5 FilesCard \u5E73\u94FA "),
|
|
6138
|
-
__props.message.files?.length ? (openBlock(), createElementBlock("div",
|
|
6190
|
+
__props.message.files?.length ? (openBlock(), createElementBlock("div", _hoisted_8, [
|
|
6139
6191
|
renderSlot(_ctx.$slots, "message-files", {
|
|
6140
6192
|
message: __props.message,
|
|
6141
6193
|
files: __props.message.files
|
|
@@ -6156,9 +6208,9 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
6156
6208
|
class: "fv-msg-file-img",
|
|
6157
6209
|
src: f.url,
|
|
6158
6210
|
alt: f.name
|
|
6159
|
-
}, null, 8,
|
|
6211
|
+
}, null, 8, _hoisted_9)) : (openBlock(), createElementBlock(
|
|
6160
6212
|
"span",
|
|
6161
|
-
|
|
6213
|
+
_hoisted_10,
|
|
6162
6214
|
toDisplayString(f.name),
|
|
6163
6215
|
1
|
|
6164
6216
|
/* TEXT */
|
|
@@ -6173,9 +6225,15 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
6173
6225
|
))
|
|
6174
6226
|
])
|
|
6175
6227
|
])) : createCommentVNode("v-if", true),
|
|
6228
|
+
createCommentVNode(" \u5DE5\u5177\u8C03\u7528\u8F68\u8FF9(assistant \u542B toolSteps \u65F6):\u7EB5\u5411\u6B65\u9AA4\u94FE,Thinking \u4E4B\u4E0B\u6B63\u6587\u4E4B\u4E0A "),
|
|
6229
|
+
!isUser.value && hasToolSteps.value ? (openBlock(), createBlock(_sfc_main$9, {
|
|
6230
|
+
key: 2,
|
|
6231
|
+
class: "fv-msg-tools",
|
|
6232
|
+
items: toolChainItems.value
|
|
6233
|
+
}, null, 8, ["items"])) : createCommentVNode("v-if", true),
|
|
6176
6234
|
createCommentVNode(" \u601D\u8003\u94FE\u6298\u53E0(assistant \u542B reasoning \u65F6) "),
|
|
6177
6235
|
!isUser.value && hasReasoning.value ? (openBlock(), createBlock(_sfc_main$a, {
|
|
6178
|
-
key:
|
|
6236
|
+
key: 3,
|
|
6179
6237
|
content: __props.message.reasoning,
|
|
6180
6238
|
status: thinkingStatus.value,
|
|
6181
6239
|
"auto-collapse": __props.autoCollapse
|
|
@@ -6189,17 +6247,17 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
6189
6247
|
/* STABLE */
|
|
6190
6248
|
}, 8, ["content", "status", "auto-collapse"])) : createCommentVNode("v-if", true),
|
|
6191
6249
|
createCommentVNode(" \u6B63\u6587:user \u7EAF\u6587\u672C\u6C14\u6CE1;assistant Markdown;pending \u7A7A\u5185\u5BB9\u7ED9\u52A0\u8F7D\u5360\u4F4D "),
|
|
6192
|
-
!isUser.value ? (openBlock(), createElementBlock("div",
|
|
6250
|
+
!isUser.value ? (openBlock(), createElementBlock("div", _hoisted_11, [
|
|
6193
6251
|
__props.message.status === "error" ? (openBlock(), createElementBlock(
|
|
6194
6252
|
"span",
|
|
6195
|
-
|
|
6253
|
+
_hoisted_12,
|
|
6196
6254
|
toDisplayString(__props.message.error || "\u751F\u6210\u5931\u8D25"),
|
|
6197
6255
|
1
|
|
6198
6256
|
/* TEXT */
|
|
6199
6257
|
)) : __props.message.content ? (openBlock(), createBlock(_sfc_main$i, {
|
|
6200
6258
|
key: 1,
|
|
6201
6259
|
content: __props.message.content
|
|
6202
|
-
}, null, 8, ["content"])) : __props.message.status === "pending" || __props.message.status === "streaming" ? (openBlock(), createElementBlock("span",
|
|
6260
|
+
}, null, 8, ["content"])) : __props.message.status === "pending" || __props.message.status === "streaming" ? (openBlock(), createElementBlock("span", _hoisted_13, [
|
|
6203
6261
|
(openBlock(), createElementBlock(
|
|
6204
6262
|
Fragment,
|
|
6205
6263
|
null,
|
|
@@ -6222,13 +6280,13 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
6222
6280
|
])) : createCommentVNode("v-if", true)
|
|
6223
6281
|
])) : (openBlock(), createElementBlock(
|
|
6224
6282
|
"div",
|
|
6225
|
-
|
|
6283
|
+
_hoisted_14,
|
|
6226
6284
|
toDisplayString(__props.message.content),
|
|
6227
6285
|
1
|
|
6228
6286
|
/* TEXT */
|
|
6229
6287
|
)),
|
|
6230
6288
|
createCommentVNode(" \u64CD\u4F5C\u533A:assistant \u590D\u5236/\u91CD\u751F\u6210 + \u5206\u652F\u5207\u6362;user \u4EC5\u590D\u5236(hover \u6D88\u606F\u65F6\u6D6E\u73B0,\u89C1 scss) "),
|
|
6231
|
-
__props.showActions || __props.showBranchSwitch && __props.branch && __props.branch.count > 1 ? (openBlock(), createElementBlock("div",
|
|
6289
|
+
__props.showActions || __props.showBranchSwitch && __props.branch && __props.branch.count > 1 ? (openBlock(), createElementBlock("div", _hoisted_15, [
|
|
6232
6290
|
renderSlot(_ctx.$slots, "message-actions", { message: __props.message }, () => [
|
|
6233
6291
|
__props.showActions && isUser.value ? (openBlock(), createBlock(unref(ElTooltip), {
|
|
6234
6292
|
key: 0,
|
|
@@ -6319,7 +6377,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
6319
6377
|
})) : createCommentVNode("v-if", true)
|
|
6320
6378
|
]),
|
|
6321
6379
|
createCommentVNode(" \u5206\u652F\u5207\u6362:\u5144\u5F1F\u5206\u652F > 1 \u65F6 "),
|
|
6322
|
-
__props.showBranchSwitch && __props.branch && __props.branch.count > 1 ? (openBlock(), createElementBlock("span",
|
|
6380
|
+
__props.showBranchSwitch && __props.branch && __props.branch.count > 1 ? (openBlock(), createElementBlock("span", _hoisted_16, [
|
|
6323
6381
|
createVNode(unref(ElButton), {
|
|
6324
6382
|
text: "",
|
|
6325
6383
|
size: "small",
|
|
@@ -6342,7 +6400,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
6342
6400
|
}, 8, ["disabled"]),
|
|
6343
6401
|
createElementVNode(
|
|
6344
6402
|
"span",
|
|
6345
|
-
|
|
6403
|
+
_hoisted_17,
|
|
6346
6404
|
toDisplayString(__props.branch.index) + " / " + toDisplayString(__props.branch.count),
|
|
6347
6405
|
1
|
|
6348
6406
|
/* TEXT */
|
|
@@ -6393,10 +6451,18 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
6393
6451
|
suggestions: { type: Array, required: false, default: () => [] },
|
|
6394
6452
|
suggestionsTitle: { type: String, required: false, default: "" },
|
|
6395
6453
|
scrollThreshold: { type: Number, required: false, default: 40 },
|
|
6454
|
+
showScrollButton: { type: Boolean, required: false, default: true },
|
|
6455
|
+
scrollButtonThreshold: { type: Number, required: false, default: 100 },
|
|
6396
6456
|
showActions: { type: Boolean, required: false, default: true },
|
|
6397
6457
|
showBranchSwitch: { type: Boolean, required: false, default: true },
|
|
6398
6458
|
showUserAvatar: { type: Boolean, required: false, default: true },
|
|
6399
|
-
showUserName: { type: Boolean, required: false, default: true }
|
|
6459
|
+
showUserName: { type: Boolean, required: false, default: true },
|
|
6460
|
+
showAssistantAvatar: { type: Boolean, required: false, default: true },
|
|
6461
|
+
showAssistantName: { type: Boolean, required: false, default: true },
|
|
6462
|
+
userAvatar: { type: String, required: false, default: "" },
|
|
6463
|
+
assistantAvatar: { type: String, required: false, default: "" },
|
|
6464
|
+
userName: { type: String, required: false, default: "" },
|
|
6465
|
+
assistantName: { type: String, required: false, default: "" }
|
|
6400
6466
|
},
|
|
6401
6467
|
emits: ["select", "copy", "regenerate", "branch-change"],
|
|
6402
6468
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -6421,8 +6487,14 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
6421
6487
|
function scrollToBottomIfNear() {
|
|
6422
6488
|
if (distanceFromBottom() <= props.scrollThreshold) nextTick(() => scrollToBottom());
|
|
6423
6489
|
}
|
|
6490
|
+
const isAwayFromBottom = ref(false);
|
|
6491
|
+
function onScroll() {
|
|
6492
|
+
isAwayFromBottom.value = distanceFromBottom() > props.scrollButtonThreshold;
|
|
6493
|
+
}
|
|
6494
|
+
watch(() => props.scrollButtonThreshold, onScroll);
|
|
6424
6495
|
onMounted(() => {
|
|
6425
6496
|
if (!isEmpty.value) nextTick(() => scrollToBottom(false));
|
|
6497
|
+
onScroll();
|
|
6426
6498
|
});
|
|
6427
6499
|
watch(() => props.messages.length, (nv, ov) => {
|
|
6428
6500
|
if (nv > (ov ?? 0)) scrollToBottomIfNear();
|
|
@@ -6499,7 +6571,8 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
6499
6571
|
{
|
|
6500
6572
|
ref_key: "scrollRef",
|
|
6501
6573
|
ref: scrollRef,
|
|
6502
|
-
class: "fv-messages-scroll"
|
|
6574
|
+
class: "fv-messages-scroll",
|
|
6575
|
+
onScrollPassive: onScroll
|
|
6503
6576
|
},
|
|
6504
6577
|
[
|
|
6505
6578
|
createElementVNode("div", _hoisted_3$2, [
|
|
@@ -6515,6 +6588,12 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
6515
6588
|
"show-branch-switch": __props.showBranchSwitch,
|
|
6516
6589
|
"show-user-avatar": __props.showUserAvatar,
|
|
6517
6590
|
"show-user-name": __props.showUserName,
|
|
6591
|
+
"show-assistant-avatar": __props.showAssistantAvatar,
|
|
6592
|
+
"show-assistant-name": __props.showAssistantName,
|
|
6593
|
+
"user-avatar": __props.userAvatar,
|
|
6594
|
+
"assistant-avatar": __props.assistantAvatar,
|
|
6595
|
+
"user-name": __props.userName,
|
|
6596
|
+
"assistant-name": __props.assistantName,
|
|
6518
6597
|
onCopy,
|
|
6519
6598
|
onRegenerate,
|
|
6520
6599
|
onBranchChange: onBranch
|
|
@@ -6535,16 +6614,77 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
6535
6614
|
renderSlot(_ctx.$slots, "message-actions", mergeProps({ ref_for: true }, scope))
|
|
6536
6615
|
]),
|
|
6537
6616
|
key: "1"
|
|
6617
|
+
} : void 0,
|
|
6618
|
+
_ctx.$slots["user-avatar"] ? {
|
|
6619
|
+
name: "user-avatar",
|
|
6620
|
+
fn: withCtx(() => [
|
|
6621
|
+
renderSlot(_ctx.$slots, "user-avatar")
|
|
6622
|
+
]),
|
|
6623
|
+
key: "2"
|
|
6624
|
+
} : void 0,
|
|
6625
|
+
_ctx.$slots["assistant-avatar"] ? {
|
|
6626
|
+
name: "assistant-avatar",
|
|
6627
|
+
fn: withCtx(() => [
|
|
6628
|
+
renderSlot(_ctx.$slots, "assistant-avatar")
|
|
6629
|
+
]),
|
|
6630
|
+
key: "3"
|
|
6631
|
+
} : void 0,
|
|
6632
|
+
_ctx.$slots["user-name"] ? {
|
|
6633
|
+
name: "user-name",
|
|
6634
|
+
fn: withCtx((scope) => [
|
|
6635
|
+
renderSlot(_ctx.$slots, "user-name", mergeProps({ ref_for: true }, scope))
|
|
6636
|
+
]),
|
|
6637
|
+
key: "4"
|
|
6638
|
+
} : void 0,
|
|
6639
|
+
_ctx.$slots["assistant-name"] ? {
|
|
6640
|
+
name: "assistant-name",
|
|
6641
|
+
fn: withCtx((scope) => [
|
|
6642
|
+
renderSlot(_ctx.$slots, "assistant-name", mergeProps({ ref_for: true }, scope))
|
|
6643
|
+
]),
|
|
6644
|
+
key: "5"
|
|
6538
6645
|
} : void 0
|
|
6539
|
-
]), 1032, ["message", "branch", "show-actions", "show-branch-switch", "show-user-avatar", "show-user-name"]);
|
|
6646
|
+
]), 1032, ["message", "branch", "show-actions", "show-branch-switch", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "user-name", "assistant-name"]);
|
|
6540
6647
|
}),
|
|
6541
6648
|
128
|
|
6542
6649
|
/* KEYED_FRAGMENT */
|
|
6543
|
-
))
|
|
6650
|
+
)),
|
|
6651
|
+
createCommentVNode(" \u6EDA\u5230\u5E95\u90E8\u60AC\u6D6E\u6309\u94AE:\u5728 fv-messages-inner \u5185,\u968F\u5185\u5BB9\u5BBD\u5EA6\u7EA6\u675F\u5C42\u5B9A\u4F4D(\u5BBD\u5C4F\u65F6\u4E0D\u8D34\u89C6\u53E3\u53F3\u7F18);\r\n \u8DDD\u5E95\u8D85\u8FC7 scrollButtonThreshold \u663E\u793A(\u7A7A\u6001\u4E0D\u6E32\u67D3);\r\n scroll-button \u63D2\u69FD\u6574\u4F53\u8986\u76D6\u6309\u94AE,scroll-button-icon \u63D2\u69FD\u4EC5\u8986\u76D6\u56FE\u6807\u5185\u5BB9 "),
|
|
6652
|
+
createVNode(Transition, { name: "fv-messages-back-fade" }, {
|
|
6653
|
+
default: withCtx(() => [
|
|
6654
|
+
renderSlot(_ctx.$slots, "scroll-button", {
|
|
6655
|
+
scrollToBottom,
|
|
6656
|
+
awayFromBottom: isAwayFromBottom.value
|
|
6657
|
+
}, () => [
|
|
6658
|
+
__props.showScrollButton && !isEmpty.value && isAwayFromBottom.value ? (openBlock(), createBlock(unref(ElButton), {
|
|
6659
|
+
key: 0,
|
|
6660
|
+
class: "fv-messages-back",
|
|
6661
|
+
circle: "",
|
|
6662
|
+
"aria-label": "\u6EDA\u52A8\u5230\u5E95\u90E8",
|
|
6663
|
+
onClick: _cache[0] || (_cache[0] = ($event) => scrollToBottom())
|
|
6664
|
+
}, {
|
|
6665
|
+
default: withCtx(() => [
|
|
6666
|
+
createVNode(unref(ElIcon), { class: "fv-messages-back-icon" }, {
|
|
6667
|
+
default: withCtx(() => [
|
|
6668
|
+
renderSlot(_ctx.$slots, "scroll-button-icon", {}, () => [
|
|
6669
|
+
createVNode(unref(Bottom))
|
|
6670
|
+
])
|
|
6671
|
+
]),
|
|
6672
|
+
_: 3
|
|
6673
|
+
/* FORWARDED */
|
|
6674
|
+
})
|
|
6675
|
+
]),
|
|
6676
|
+
_: 3
|
|
6677
|
+
/* FORWARDED */
|
|
6678
|
+
})) : createCommentVNode("v-if", true)
|
|
6679
|
+
])
|
|
6680
|
+
]),
|
|
6681
|
+
_: 3
|
|
6682
|
+
/* FORWARDED */
|
|
6683
|
+
})
|
|
6544
6684
|
])
|
|
6545
6685
|
],
|
|
6546
|
-
|
|
6547
|
-
/* NEED_PATCH */
|
|
6686
|
+
544
|
|
6687
|
+
/* NEED_HYDRATION, NEED_PATCH */
|
|
6548
6688
|
)
|
|
6549
6689
|
],
|
|
6550
6690
|
2112
|
|
@@ -6829,9 +6969,18 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
6829
6969
|
title: { type: String, required: false, default: "" },
|
|
6830
6970
|
showHeader: { type: Boolean, required: false, default: false },
|
|
6831
6971
|
centerWelcome: { type: Boolean, required: false, default: true },
|
|
6972
|
+
showScrollButton: { type: Boolean, required: false, default: true },
|
|
6973
|
+
scrollButtonThreshold: { type: Number, required: false, default: 100 },
|
|
6832
6974
|
showUserAvatar: { type: Boolean, required: false, default: true },
|
|
6833
6975
|
showUserName: { type: Boolean, required: false, default: true },
|
|
6976
|
+
showAssistantAvatar: { type: Boolean, required: false, default: true },
|
|
6977
|
+
showAssistantName: { type: Boolean, required: false, default: true },
|
|
6978
|
+
userAvatar: { type: String, required: false, default: "" },
|
|
6979
|
+
assistantAvatar: { type: String, required: false, default: "" },
|
|
6980
|
+
userName: { type: String, required: false, default: "" },
|
|
6981
|
+
assistantName: { type: String, required: false, default: "" },
|
|
6834
6982
|
placeholder: { type: String, required: false, default: "" },
|
|
6983
|
+
toolStepLabel: { type: Function, required: false, default: void 0 },
|
|
6835
6984
|
senderShadow: { type: Boolean, required: false, default: true },
|
|
6836
6985
|
suggestions: { type: Array, required: false, default: () => [] },
|
|
6837
6986
|
features: { type: Object, required: false, default: () => ({}) },
|
|
@@ -6875,6 +7024,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
6875
7024
|
adapter: resolveAdapter,
|
|
6876
7025
|
models: () => isMultiple.value && selectedModels.value.length ? selectedModels.value : [""],
|
|
6877
7026
|
initial: { messages: initialTable, currentId: initialId },
|
|
7027
|
+
toolStepLabel: props.toolStepLabel,
|
|
6878
7028
|
onToolEvent: (ev) => emit("tool-event", ev)
|
|
6879
7029
|
});
|
|
6880
7030
|
const { send, stop: stopChat, regenerate: regenerateChat, msgs, isLoading } = chat;
|
|
@@ -7094,8 +7244,16 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7094
7244
|
nodes: unref(nodeTable),
|
|
7095
7245
|
name: __props.title,
|
|
7096
7246
|
suggestions: __props.suggestions,
|
|
7247
|
+
"show-scroll-button": __props.showScrollButton,
|
|
7248
|
+
"scroll-button-threshold": __props.scrollButtonThreshold,
|
|
7097
7249
|
"show-user-avatar": __props.showUserAvatar,
|
|
7098
7250
|
"show-user-name": __props.showUserName,
|
|
7251
|
+
"show-assistant-avatar": __props.showAssistantAvatar,
|
|
7252
|
+
"show-assistant-name": __props.showAssistantName,
|
|
7253
|
+
"user-avatar": __props.userAvatar,
|
|
7254
|
+
"assistant-avatar": __props.assistantAvatar,
|
|
7255
|
+
"user-name": __props.userName,
|
|
7256
|
+
"assistant-name": __props.assistantName,
|
|
7099
7257
|
onSelect: onSelectSuggestion,
|
|
7100
7258
|
onCopy,
|
|
7101
7259
|
onRegenerate,
|
|
@@ -7118,14 +7276,56 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7118
7276
|
]),
|
|
7119
7277
|
key: "1"
|
|
7120
7278
|
} : void 0,
|
|
7279
|
+
_ctx.$slots["user-avatar"] ? {
|
|
7280
|
+
name: "user-avatar",
|
|
7281
|
+
fn: withCtx(() => [
|
|
7282
|
+
renderSlot(_ctx.$slots, "user-avatar")
|
|
7283
|
+
]),
|
|
7284
|
+
key: "2"
|
|
7285
|
+
} : void 0,
|
|
7286
|
+
_ctx.$slots["assistant-avatar"] ? {
|
|
7287
|
+
name: "assistant-avatar",
|
|
7288
|
+
fn: withCtx(() => [
|
|
7289
|
+
renderSlot(_ctx.$slots, "assistant-avatar")
|
|
7290
|
+
]),
|
|
7291
|
+
key: "3"
|
|
7292
|
+
} : void 0,
|
|
7293
|
+
_ctx.$slots["user-name"] ? {
|
|
7294
|
+
name: "user-name",
|
|
7295
|
+
fn: withCtx((scope) => [
|
|
7296
|
+
renderSlot(_ctx.$slots, "user-name", normalizeProps(guardReactiveProps(scope)))
|
|
7297
|
+
]),
|
|
7298
|
+
key: "4"
|
|
7299
|
+
} : void 0,
|
|
7300
|
+
_ctx.$slots["assistant-name"] ? {
|
|
7301
|
+
name: "assistant-name",
|
|
7302
|
+
fn: withCtx((scope) => [
|
|
7303
|
+
renderSlot(_ctx.$slots, "assistant-name", normalizeProps(guardReactiveProps(scope)))
|
|
7304
|
+
]),
|
|
7305
|
+
key: "5"
|
|
7306
|
+
} : void 0,
|
|
7121
7307
|
_ctx.$slots.empty ? {
|
|
7122
7308
|
name: "empty",
|
|
7123
7309
|
fn: withCtx(() => [
|
|
7124
7310
|
renderSlot(_ctx.$slots, "empty")
|
|
7125
7311
|
]),
|
|
7126
|
-
key: "
|
|
7312
|
+
key: "6"
|
|
7313
|
+
} : void 0,
|
|
7314
|
+
_ctx.$slots["scroll-button"] ? {
|
|
7315
|
+
name: "scroll-button",
|
|
7316
|
+
fn: withCtx((scope) => [
|
|
7317
|
+
renderSlot(_ctx.$slots, "scroll-button", normalizeProps(guardReactiveProps(scope)))
|
|
7318
|
+
]),
|
|
7319
|
+
key: "7"
|
|
7320
|
+
} : void 0,
|
|
7321
|
+
_ctx.$slots["scroll-button-icon"] ? {
|
|
7322
|
+
name: "scroll-button-icon",
|
|
7323
|
+
fn: withCtx(() => [
|
|
7324
|
+
renderSlot(_ctx.$slots, "scroll-button-icon")
|
|
7325
|
+
]),
|
|
7326
|
+
key: "8"
|
|
7127
7327
|
} : void 0
|
|
7128
|
-
]), 1032, ["messages", "nodes", "name", "suggestions", "show-user-avatar", "show-user-name"]),
|
|
7328
|
+
]), 1032, ["messages", "nodes", "name", "suggestions", "show-scroll-button", "scroll-button-threshold", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "user-name", "assistant-name"]),
|
|
7129
7329
|
__props.features?.artifacts && artifacts.value.length ? (openBlock(), createBlock(_sfc_main$1, {
|
|
7130
7330
|
key: 0,
|
|
7131
7331
|
artifacts: artifacts.value,
|