@zero-library/chat-agent 2.1.19 → 2.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +115 -81
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +295 -197
- package/dist/index.d.ts +295 -197
- package/dist/index.esm.js +115 -81
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { useRefState, useDebounce, useSyncInput, RenderWrapper, shouldRender, isFunction, useDeepEffect, useWebSocket, getWebSocketUrl, getToken, isLocalhost, downloadFile, FilePreview, MarkdownEditor,
|
|
1
|
+
import { useRefState, useDebounce, useSyncInput, RenderWrapper, shouldRender, isFunction, useDeepEffect, useWebSocket, getWebSocketUrl, getToken, isLocalhost, downloadFile, FilePreview, MarkdownEditor, isNumber, getFileSuffixName, isObject, isNullOrUnDef, isBoolean, UserAvatar, copyText, deepCopy, transforms, transform, getCurrentUser, deepMerge, createRequest, RenderMarkdown, useCreateValtioContext, FileIcon, isExternal } from '@zero-library/common';
|
|
2
2
|
import { App, Badge, Button, Flex, Typography, Spin, Splitter, Tag, Popover, List, Avatar, Space, message, Empty, Modal, Row, Col, Collapse, Drawer } from 'antd';
|
|
3
|
-
import dayjs from 'dayjs';
|
|
4
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
4
|
import { forwardRef, useRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
|
6
5
|
import { useSnapshot, proxy } from 'valtio';
|
|
@@ -8,6 +7,7 @@ import { CloudUploadOutlined, PaperClipOutlined, EnterOutlined, UserSwitchOutlin
|
|
|
8
7
|
import { Attachments, Sender, Suggestion, XProvider, Welcome, Prompts, Bubble, Conversations } from '@ant-design/x';
|
|
9
8
|
export * from '@ant-design/x';
|
|
10
9
|
import classNames8 from 'classnames';
|
|
10
|
+
import dayjs from 'dayjs';
|
|
11
11
|
import InfiniteScroll from 'react-infinite-scroll-component';
|
|
12
12
|
|
|
13
13
|
var __defProp = Object.defineProperty;
|
|
@@ -19,36 +19,6 @@ var __export = (target, all) => {
|
|
|
19
19
|
for (var name in all)
|
|
20
20
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
21
|
};
|
|
22
|
-
var classifyTime, replaceThinkTags, copy;
|
|
23
|
-
var init_utils = __esm({
|
|
24
|
-
"src/core/utils.ts"() {
|
|
25
|
-
classifyTime = (timestamp) => {
|
|
26
|
-
const now = dayjs();
|
|
27
|
-
const target = dayjs(timestamp);
|
|
28
|
-
if (target.isSame(now, "day")) {
|
|
29
|
-
return "\u4ECA\u5929";
|
|
30
|
-
}
|
|
31
|
-
const diffInDays = now.diff(target, "day");
|
|
32
|
-
if (diffInDays < 7) {
|
|
33
|
-
return "\u6700\u8FD1 7 \u5929";
|
|
34
|
-
} else if (diffInDays < 30) {
|
|
35
|
-
return "\u6700\u8FD1 30 \u5929";
|
|
36
|
-
} else if (diffInDays < 180) {
|
|
37
|
-
return "\u6700\u8FD1\u534A\u5E74";
|
|
38
|
-
} else {
|
|
39
|
-
return "\u66F4\u65E9";
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
replaceThinkTags = (str) => {
|
|
43
|
-
return str.replace(/<think>/g, ":::alert type=think data={content:'").replace(/<\/think>/g, "'} ::: ");
|
|
44
|
-
};
|
|
45
|
-
copy = (value) => {
|
|
46
|
-
copyText(value).then(() => {
|
|
47
|
-
message.success("\u590D\u5236\u6210\u529F");
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
22
|
var ChatProvider, useChatStore;
|
|
53
23
|
var init_Context = __esm({
|
|
54
24
|
"src/stores/Context.ts"() {
|
|
@@ -207,7 +177,6 @@ __export(FileEdit_exports, {
|
|
|
207
177
|
var FileEdit_default;
|
|
208
178
|
var init_FileEdit = __esm({
|
|
209
179
|
"src/ui/common/markdownAlert/FileEdit.tsx"() {
|
|
210
|
-
init_utils();
|
|
211
180
|
init_Context();
|
|
212
181
|
init_styles_module();
|
|
213
182
|
FileEdit_default = ({ data, loading }) => {
|
|
@@ -223,7 +192,7 @@ var init_FileEdit = __esm({
|
|
|
223
192
|
] }),
|
|
224
193
|
/* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxs(Flex, { children: [
|
|
225
194
|
/* @__PURE__ */ jsx(Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsx(PlayCircleOutlined, {}), onClick: onPreview, children: "\u9884\u89C8\u7F16\u8F91" }),
|
|
226
|
-
/* @__PURE__ */ jsx(Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsx(CopyOutlined, {}), onClick: () =>
|
|
195
|
+
/* @__PURE__ */ jsx(Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsx(CopyOutlined, {}), onClick: () => copyText(data.content), children: "\u590D\u5236" })
|
|
227
196
|
] }) })
|
|
228
197
|
] }),
|
|
229
198
|
/* @__PURE__ */ jsx(Flex, { gap: 8, align: "center", className: styles_module_default.fileEditContent, children: /* @__PURE__ */ jsx(RenderMarkdown, { content: data.content }) })
|
|
@@ -306,9 +275,26 @@ var init_Think = __esm({
|
|
|
306
275
|
};
|
|
307
276
|
}
|
|
308
277
|
});
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
278
|
+
var classifyTime = (timestamp) => {
|
|
279
|
+
const now = dayjs();
|
|
280
|
+
const target = dayjs(timestamp);
|
|
281
|
+
if (target.isSame(now, "day")) {
|
|
282
|
+
return "\u4ECA\u5929";
|
|
283
|
+
}
|
|
284
|
+
const diffInDays = now.diff(target, "day");
|
|
285
|
+
if (diffInDays < 7) {
|
|
286
|
+
return "\u6700\u8FD1 7 \u5929";
|
|
287
|
+
} else if (diffInDays < 30) {
|
|
288
|
+
return "\u6700\u8FD1 30 \u5929";
|
|
289
|
+
} else if (diffInDays < 180) {
|
|
290
|
+
return "\u6700\u8FD1\u534A\u5E74";
|
|
291
|
+
} else {
|
|
292
|
+
return "\u66F4\u65E9";
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
var replaceThinkTags = (str) => {
|
|
296
|
+
return str.replace(/<think>/g, ":::alert type=think data={content:'").replace(/<\/think>/g, "'} :::");
|
|
297
|
+
};
|
|
312
298
|
|
|
313
299
|
// src/services/index.ts
|
|
314
300
|
var createChatService = (request) => {
|
|
@@ -444,6 +430,7 @@ function createChatStore() {
|
|
|
444
430
|
},
|
|
445
431
|
hooks: {},
|
|
446
432
|
layout: {},
|
|
433
|
+
/** 文件预览状态 */
|
|
447
434
|
preview: {
|
|
448
435
|
file: {},
|
|
449
436
|
isEdit: false
|
|
@@ -451,7 +438,9 @@ function createChatStore() {
|
|
|
451
438
|
// isShow: 0, // 0 不显示 1 显示 2 用户关闭
|
|
452
439
|
// isIntact: false // true 完整 false 不完整
|
|
453
440
|
},
|
|
441
|
+
/** 当前用户信息 */
|
|
454
442
|
userInfo: {},
|
|
443
|
+
/** 聊天参数配置 */
|
|
455
444
|
params: {}
|
|
456
445
|
});
|
|
457
446
|
const setServices = ({ baseUrl = "/api" } = {}) => {
|
|
@@ -493,14 +482,16 @@ function createChatStore() {
|
|
|
493
482
|
},
|
|
494
483
|
name: "name",
|
|
495
484
|
iconUrl: "avatar",
|
|
496
|
-
description: "
|
|
485
|
+
description: "remark"
|
|
497
486
|
});
|
|
498
487
|
};
|
|
499
488
|
const receiver = proxy({
|
|
489
|
+
/** 当前激活的接收者信息(智能体或专家) */
|
|
500
490
|
active: {},
|
|
491
|
+
/** 接收者加载状态 */
|
|
501
492
|
loading: false,
|
|
493
|
+
/** 接收者透传参数,后期可能扩展不透传参数 */
|
|
502
494
|
params: {}
|
|
503
|
-
// 透传参数,后期可能扩展不透传参数
|
|
504
495
|
});
|
|
505
496
|
const setReceiverParams = (params) => {
|
|
506
497
|
if (isObject(params)) {
|
|
@@ -559,10 +550,15 @@ function createChatStore() {
|
|
|
559
550
|
setReceiverParams();
|
|
560
551
|
};
|
|
561
552
|
const character = proxy({
|
|
553
|
+
/** 性格列表 */
|
|
562
554
|
list: [],
|
|
555
|
+
/** 当前激活的性格 */
|
|
563
556
|
active: {},
|
|
557
|
+
/** 性格选择面板是否打开 */
|
|
564
558
|
open: false,
|
|
559
|
+
/** 加载性格列表的状态 */
|
|
565
560
|
loading: false,
|
|
561
|
+
/** 切换性格时的加载状态 */
|
|
566
562
|
switchLoading: false
|
|
567
563
|
});
|
|
568
564
|
const getCharacters = async (agentId) => {
|
|
@@ -597,16 +593,20 @@ function createChatStore() {
|
|
|
597
593
|
}
|
|
598
594
|
};
|
|
599
595
|
const conversations = proxy({
|
|
596
|
+
/** 会话列表数据 */
|
|
600
597
|
list: {
|
|
601
598
|
items: [],
|
|
599
|
+
/** 分页查询参数 */
|
|
602
600
|
params: {
|
|
603
601
|
pageNum: 1,
|
|
604
602
|
pageSize: 1e3
|
|
605
603
|
}
|
|
606
604
|
},
|
|
605
|
+
/** 当前会话索引,创建会话时更新,促使页面更新会话列表 */
|
|
607
606
|
updateIndex: 0,
|
|
608
|
-
|
|
607
|
+
/** 获取会话列表的加载状态 */
|
|
609
608
|
loading: false,
|
|
609
|
+
/** 删除会话的加载状态 */
|
|
610
610
|
delLoading: false
|
|
611
611
|
});
|
|
612
612
|
const getConversations = async (targetId, targetType) => {
|
|
@@ -652,14 +652,18 @@ function createChatStore() {
|
|
|
652
652
|
}
|
|
653
653
|
};
|
|
654
654
|
const conversation = proxy({
|
|
655
|
-
|
|
655
|
+
/** 当前激活的会话信息 */
|
|
656
656
|
active: {
|
|
657
657
|
id: "",
|
|
658
|
+
/** 会话成员对象,包含用户、智能体、专家等 */
|
|
658
659
|
member: {}
|
|
659
660
|
},
|
|
661
|
+
/** 每个会话的消息存储,以会话ID为键 */
|
|
660
662
|
messages: {},
|
|
663
|
+
/** 消息反馈状态 */
|
|
661
664
|
feedback: {
|
|
662
665
|
// open: false,
|
|
666
|
+
/** 反馈操作加载状态 */
|
|
663
667
|
loading: false
|
|
664
668
|
// recordId: '',
|
|
665
669
|
// target: undefined as number | undefined
|
|
@@ -707,14 +711,18 @@ function createChatStore() {
|
|
|
707
711
|
};
|
|
708
712
|
const setInitMessage = async (conversationId) => {
|
|
709
713
|
conversation.messages[conversationId] = {
|
|
714
|
+
/** 输入框内容 */
|
|
710
715
|
content: "",
|
|
716
|
+
/** 上传文件列表 */
|
|
711
717
|
files: [],
|
|
712
|
-
|
|
718
|
+
/** 头部展开状态 */
|
|
713
719
|
headerOpen: false,
|
|
720
|
+
/** 消息发送/接收加载状态 */
|
|
714
721
|
loading: false,
|
|
722
|
+
/** 消息列表 */
|
|
715
723
|
message: [],
|
|
724
|
+
/** 推荐问题列表 */
|
|
716
725
|
questionList: []
|
|
717
|
-
// 推荐问题
|
|
718
726
|
};
|
|
719
727
|
};
|
|
720
728
|
const resolveConversationId = async (receiverId, strategy = 2) => {
|
|
@@ -819,13 +827,13 @@ function createChatStore() {
|
|
|
819
827
|
if (other) return other;
|
|
820
828
|
return void 0;
|
|
821
829
|
};
|
|
822
|
-
const sendMessage = async (
|
|
830
|
+
const sendMessage = async (message2, files = [], params) => {
|
|
823
831
|
const conversationId = conversation.active.id;
|
|
824
832
|
if (conversation.messages[conversationId].loading) return;
|
|
825
833
|
let msgContent = "", msgFiles;
|
|
826
834
|
const references = conversation.messages[conversationId].references;
|
|
827
|
-
if (
|
|
828
|
-
msgContent =
|
|
835
|
+
if (message2) {
|
|
836
|
+
msgContent = message2;
|
|
829
837
|
msgFiles = files;
|
|
830
838
|
} else {
|
|
831
839
|
if (references?.type === 1 && references?.content?.markdown) {
|
|
@@ -853,9 +861,9 @@ function createChatStore() {
|
|
|
853
861
|
stream: true
|
|
854
862
|
};
|
|
855
863
|
const extraParams = deepCopy(config.params.params || {});
|
|
856
|
-
Object.assign(extraParams, receiver.params,
|
|
864
|
+
Object.assign(extraParams, receiver.params, message2 ? {} : references?.params, params);
|
|
857
865
|
sendParams.params = JSON.stringify(extraParams);
|
|
858
|
-
if (!
|
|
866
|
+
if (!message2) {
|
|
859
867
|
setContent("");
|
|
860
868
|
setFileList([]);
|
|
861
869
|
setReferences();
|
|
@@ -901,15 +909,15 @@ function createChatStore() {
|
|
|
901
909
|
const messages = conversation.messages[msg.conversationId].message;
|
|
902
910
|
const idx = findMsgIndex(msg.conversationId, msg.id);
|
|
903
911
|
if (idx === -1) return;
|
|
904
|
-
const
|
|
912
|
+
const message2 = messages[idx];
|
|
905
913
|
conversation.messages[msg.conversationId].loading = true;
|
|
906
|
-
if (
|
|
914
|
+
if (message2?.type === "STEP_STARTED" || message2?.type === "TEXT_MESSAGE_START") {
|
|
907
915
|
messages[idx] = msg;
|
|
908
916
|
return;
|
|
909
917
|
}
|
|
910
918
|
messages[idx] = {
|
|
911
|
-
...
|
|
912
|
-
msgContent:
|
|
919
|
+
...message2,
|
|
920
|
+
msgContent: message2.msgContent + (msg.msgContent || "")
|
|
913
921
|
};
|
|
914
922
|
};
|
|
915
923
|
const endCallback = (msg) => {
|
|
@@ -949,35 +957,65 @@ function createChatStore() {
|
|
|
949
957
|
}
|
|
950
958
|
};
|
|
951
959
|
return {
|
|
960
|
+
/** 全局配置对象 */
|
|
952
961
|
config,
|
|
962
|
+
/** 设置服务配置 */
|
|
953
963
|
setServices,
|
|
964
|
+
/** 设置文件预览 */
|
|
954
965
|
setPreview,
|
|
966
|
+
/** 设置布局配置 */
|
|
955
967
|
setLayout,
|
|
968
|
+
/** 设置生命周期钩子 */
|
|
956
969
|
setHooks,
|
|
970
|
+
/** 设置聊天参数 */
|
|
957
971
|
setParams,
|
|
972
|
+
/** 设置用户信息 */
|
|
958
973
|
setUserInfo,
|
|
974
|
+
/** 智能体性格状态 */
|
|
959
975
|
character,
|
|
976
|
+
/** 获取性格列表 */
|
|
960
977
|
getCharacters,
|
|
978
|
+
/** 打开性格选择面板 */
|
|
961
979
|
openCharacterList,
|
|
980
|
+
/** 关闭性格选择面板 */
|
|
962
981
|
closeCharacterList,
|
|
982
|
+
/** 切换性格 */
|
|
963
983
|
switchCharacter,
|
|
984
|
+
/** 接收者状态 */
|
|
964
985
|
receiver,
|
|
986
|
+
/** 设置接收者参数 */
|
|
965
987
|
setReceiverParams,
|
|
988
|
+
/** 历史会话状态 */
|
|
966
989
|
conversations,
|
|
990
|
+
/** 获取会话列表 */
|
|
967
991
|
getConversations,
|
|
992
|
+
/** 删除会话 */
|
|
968
993
|
delConversation,
|
|
994
|
+
/** 当前会话状态 */
|
|
969
995
|
conversation,
|
|
996
|
+
/** 设置说话人类型 */
|
|
970
997
|
setSpeakHuman,
|
|
998
|
+
/** 设置引用消息 */
|
|
971
999
|
setReferences,
|
|
1000
|
+
/** 设置消息内容 */
|
|
972
1001
|
setContent,
|
|
1002
|
+
/** 设置文件列表 */
|
|
973
1003
|
setFileList,
|
|
1004
|
+
/** 设置头部展开状态 */
|
|
974
1005
|
setHeaderOpen,
|
|
1006
|
+
/** 消息反馈操作 */
|
|
975
1007
|
feedback,
|
|
1008
|
+
/** 切换智能体会话 */
|
|
976
1009
|
switchAgentConversation,
|
|
1010
|
+
/** 创建新会话 */
|
|
977
1011
|
createConversation,
|
|
1012
|
+
/** 切换会话 */
|
|
978
1013
|
switchConversation,
|
|
1014
|
+
/** 发送消息 */
|
|
979
1015
|
sendMessage,
|
|
1016
|
+
/** 取消接收 */
|
|
980
1017
|
cancelReceive,
|
|
1018
|
+
/** 接收消息 */
|
|
981
1019
|
acceptMessage
|
|
982
1020
|
};
|
|
983
1021
|
}
|
|
@@ -985,9 +1023,6 @@ function createChatStore() {
|
|
|
985
1023
|
// src/ui/layouts/index.tsx
|
|
986
1024
|
init_Context();
|
|
987
1025
|
|
|
988
|
-
// src/components/MessageRender.tsx
|
|
989
|
-
init_utils();
|
|
990
|
-
|
|
991
1026
|
// src/ui/common/markdownAlert/index.ts
|
|
992
1027
|
var customComponents = {
|
|
993
1028
|
appCard: () => Promise.resolve().then(() => (init_AppCard(), AppCard_exports)),
|
|
@@ -1006,17 +1041,17 @@ var styles_module_default2 = {
|
|
|
1006
1041
|
chatSender: "styles_module_chatSender",
|
|
1007
1042
|
chatQuoteMsg: "styles_module_chatQuoteMsg"
|
|
1008
1043
|
};
|
|
1009
|
-
var MessageRender_default = ({ message:
|
|
1010
|
-
return /* @__PURE__ */ jsx(Flex, { vertical: true, children: !(
|
|
1011
|
-
|
|
1044
|
+
var MessageRender_default = ({ message: message2, placement }) => {
|
|
1045
|
+
return /* @__PURE__ */ jsx(Flex, { vertical: true, children: !(message2.msgContent || message2.msgFiles.length) ? /* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(Spin, { size: "small" }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1046
|
+
message2.msgContent && /* @__PURE__ */ jsx(
|
|
1012
1047
|
Bubble,
|
|
1013
1048
|
{
|
|
1014
1049
|
placement,
|
|
1015
|
-
className: classNames8({ [styles_module_default2.loadingMessage]:
|
|
1016
|
-
content: /* @__PURE__ */ jsx(RenderMarkdown, { content: replaceThinkTags(
|
|
1050
|
+
className: classNames8({ [styles_module_default2.loadingMessage]: message2.type }),
|
|
1051
|
+
content: /* @__PURE__ */ jsx(RenderMarkdown, { content: replaceThinkTags(message2.msgContent), customComponents })
|
|
1017
1052
|
}
|
|
1018
1053
|
),
|
|
1019
|
-
|
|
1054
|
+
message2.msgFiles?.map((file) => /* @__PURE__ */ jsx(
|
|
1020
1055
|
Bubble,
|
|
1021
1056
|
{
|
|
1022
1057
|
className: "m-t-8",
|
|
@@ -1036,19 +1071,19 @@ var MessageRender_default = ({ message: message3, placement }) => {
|
|
|
1036
1071
|
},
|
|
1037
1072
|
file.content
|
|
1038
1073
|
)),
|
|
1039
|
-
|
|
1074
|
+
message2.quoteMsg?.id && /* @__PURE__ */ jsx(
|
|
1040
1075
|
Bubble,
|
|
1041
1076
|
{
|
|
1042
1077
|
className: classNames8(styles_module_default2.chatQuoteMsg),
|
|
1043
1078
|
placement,
|
|
1044
1079
|
content: /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, children: [
|
|
1045
|
-
|
|
1080
|
+
message2.quoteMsg.msgContent && /* @__PURE__ */ jsxs(Flex, { children: [
|
|
1046
1081
|
/* @__PURE__ */ jsx("span", { children: "\u3010\u5F15\u7528\u6D88\u606F\u3011\uFF1A" }),
|
|
1047
|
-
/* @__PURE__ */ jsx(Flex, { flex: 1, className: "text-ellipsis", children:
|
|
1082
|
+
/* @__PURE__ */ jsx(Flex, { flex: 1, className: "text-ellipsis", children: message2.quoteMsg.msgContent })
|
|
1048
1083
|
] }),
|
|
1049
|
-
|
|
1084
|
+
message2.quoteMsg?.msgFiles && message2.quoteMsg.msgFiles.length > 0 && /* @__PURE__ */ jsxs(Flex, { children: [
|
|
1050
1085
|
/* @__PURE__ */ jsx("span", { children: "\u3010\u5F15\u7528\u6587\u4EF6\u3011\uFF1A" }),
|
|
1051
|
-
/* @__PURE__ */ jsx(Flex, { gap: 8, wrap: true, flex: 1, children:
|
|
1086
|
+
/* @__PURE__ */ jsx(Flex, { gap: 8, wrap: true, flex: 1, children: message2.quoteMsg.msgFiles.map((file) => /* @__PURE__ */ jsx(
|
|
1052
1087
|
Attachments.FileCard,
|
|
1053
1088
|
{
|
|
1054
1089
|
item: {
|
|
@@ -1074,7 +1109,6 @@ var MEMBER_TYPE = {
|
|
|
1074
1109
|
};
|
|
1075
1110
|
|
|
1076
1111
|
// src/ui/common/BubbleListItems.tsx
|
|
1077
|
-
init_utils();
|
|
1078
1112
|
init_Context();
|
|
1079
1113
|
|
|
1080
1114
|
// src/ui/common/styles.module.less
|
|
@@ -1207,36 +1241,36 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
|
|
|
1207
1241
|
[chatMessage?.questionList]
|
|
1208
1242
|
);
|
|
1209
1243
|
const chatRecords = useMemo(() => {
|
|
1210
|
-
return (chatMessage?.message || []).map((
|
|
1211
|
-
const role = conversationRoles[MEMBER_TYPE[
|
|
1244
|
+
return (chatMessage?.message || []).map((message2, index) => {
|
|
1245
|
+
const role = conversationRoles[MEMBER_TYPE[message2.sender.type]] || {};
|
|
1212
1246
|
return {
|
|
1213
|
-
key:
|
|
1247
|
+
key: message2.id,
|
|
1214
1248
|
placement: role.placement,
|
|
1215
1249
|
variant: "borderless",
|
|
1216
1250
|
avatar: role.avatar,
|
|
1217
|
-
content: /* @__PURE__ */ jsx(MessageRender_default, { message:
|
|
1251
|
+
content: /* @__PURE__ */ jsx(MessageRender_default, { message: message2, placement: role.placement }),
|
|
1218
1252
|
footer: role.user === "agent" && /* @__PURE__ */ jsxs(Flex, { children: [
|
|
1219
|
-
/* @__PURE__ */ jsx(Button, { onClick: () =>
|
|
1253
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => copyText(message2.msgContent), color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsx(CopyOutlined, {}) }),
|
|
1220
1254
|
/* @__PURE__ */ jsx(
|
|
1221
1255
|
Button,
|
|
1222
1256
|
{
|
|
1223
|
-
color:
|
|
1224
|
-
disabled: !!
|
|
1257
|
+
color: message2.msgFeedback === 1 ? "primary" : "default",
|
|
1258
|
+
disabled: !!message2.type,
|
|
1225
1259
|
size: "small",
|
|
1226
1260
|
variant: "text",
|
|
1227
1261
|
icon: /* @__PURE__ */ jsx(LikeOutlined, {}),
|
|
1228
|
-
onClick: () => chatStore.feedback(conversationState.active.id,
|
|
1262
|
+
onClick: () => chatStore.feedback(conversationState.active.id, message2.id, 1, index)
|
|
1229
1263
|
}
|
|
1230
1264
|
),
|
|
1231
1265
|
/* @__PURE__ */ jsx(
|
|
1232
1266
|
Button,
|
|
1233
1267
|
{
|
|
1234
|
-
color:
|
|
1235
|
-
disabled: !!
|
|
1268
|
+
color: message2.msgFeedback === 2 ? "primary" : "default",
|
|
1269
|
+
disabled: !!message2.type,
|
|
1236
1270
|
size: "small",
|
|
1237
1271
|
variant: "text",
|
|
1238
1272
|
icon: /* @__PURE__ */ jsx(DislikeOutlined, {}),
|
|
1239
|
-
onClick: () => chatStore.feedback(conversationState.active.id,
|
|
1273
|
+
onClick: () => chatStore.feedback(conversationState.active.id, message2.id, 2, index)
|
|
1240
1274
|
}
|
|
1241
1275
|
)
|
|
1242
1276
|
] })
|
|
@@ -1275,7 +1309,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
|
|
|
1275
1309
|
const handleScroll = (el) => {
|
|
1276
1310
|
const target = el.target;
|
|
1277
1311
|
const distanceToBottom = target.scrollHeight - target.scrollTop - target.clientHeight;
|
|
1278
|
-
autoScrollRef.current = distanceToBottom <
|
|
1312
|
+
autoScrollRef.current = distanceToBottom < 150;
|
|
1279
1313
|
};
|
|
1280
1314
|
useEffect(() => {
|
|
1281
1315
|
autoScrollRef.current = true;
|
|
@@ -1481,7 +1515,7 @@ var ChatHeader_default = ({
|
|
|
1481
1515
|
] }) });
|
|
1482
1516
|
};
|
|
1483
1517
|
var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig = [], fileList = [], onChange, extraParams }, ref) => {
|
|
1484
|
-
const { message:
|
|
1518
|
+
const { message: message2 } = App.useApp();
|
|
1485
1519
|
const fileListRef = useRef([]);
|
|
1486
1520
|
const [attachedFiles, setAttachedFiles, getAttachedFiles] = useRefState([]);
|
|
1487
1521
|
useEffect(() => {
|
|
@@ -1509,7 +1543,7 @@ var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig = [], fileL
|
|
|
1509
1543
|
onChange(files);
|
|
1510
1544
|
}, [attachedFiles]);
|
|
1511
1545
|
const onErrorTip = useDebounce((errorMsg) => {
|
|
1512
|
-
|
|
1546
|
+
message2.error(errorMsg);
|
|
1513
1547
|
}, 300);
|
|
1514
1548
|
const findConfigByFile = (file) => {
|
|
1515
1549
|
return fileUploadConfig.find((cfg) => cfg.allowedFileTypes?.includes(getFileSuffixName(file.name).toLocaleUpperCase()));
|