@zero-library/chat-agent 2.2.19 → 2.3.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/dist/index.cjs.js +563 -80
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +36 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +117 -9
- package/dist/index.d.ts +117 -9
- package/dist/index.esm.js +565 -82
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createSecureManager, createTokenManager, useRefState, useDebounce, useSyncInput, markdownToText, RenderWrapper, shouldRender, isFunction, useDeepEffect, useWebSocket, downloadFile, FilePreview, MarkdownEditor,
|
|
2
|
-
import { App, Badge, Button, Flex, Typography, Spin, Splitter, Tag, Popover, List, Avatar, Space, message, Empty, Tooltip, Modal, Row, Col, Collapse, Skeleton, Alert, Drawer } from 'antd';
|
|
1
|
+
import { createSecureManager, createTokenManager, useRefState, useDebounce, useSyncInput, markdownToText, RenderWrapper, shouldRender, isFunction, useDeepEffect, useWebSocket, downloadFile, FilePreview, MarkdownEditor, isObject, isNullOrUnDef, isNumber, getFileSuffixName, isBoolean, UserAvatar, htmlToMarkdown, copyText, deepCopy, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, isEmptyObj, RenderMarkdown, transform, emit, buildUrlParams, getWebSocketUrl, useCreateValtioContext, FileIcon, isExternal, LazyComponent } from '@zero-library/common';
|
|
2
|
+
import { App, Badge, Button, Flex, Typography, Spin, Splitter, Tag, Popover, List, Avatar, Space, Input, Popconfirm, message, Empty, Tooltip, Form, Modal, AutoComplete, Row, Col, Collapse, Skeleton, Alert, Drawer } from 'antd';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { forwardRef, useRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
|
5
5
|
import { useSnapshot, proxy } from 'valtio';
|
|
6
|
-
import { CloudUploadOutlined, PaperClipOutlined, EnterOutlined,
|
|
6
|
+
import { CloudUploadOutlined, PaperClipOutlined, EnterOutlined, CloseOutlined, FileSearchOutlined, UserSwitchOutlined, PlusOutlined, CommentOutlined, OpenAIOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, SearchOutlined, PushpinOutlined, EditOutlined, DeleteOutlined, RedoOutlined, SignatureOutlined, PlayCircleOutlined, DotChartOutlined } from '@ant-design/icons';
|
|
7
|
+
import classNames11 from 'classnames';
|
|
7
8
|
import { Attachments, Sender, Suggestion, XProvider, Prompts, Bubble, Conversations, Welcome } from '@ant-design/x';
|
|
8
|
-
import classNames9 from 'classnames';
|
|
9
9
|
import dayjs from 'dayjs';
|
|
10
10
|
import InfiniteScroll from 'react-infinite-scroll-component';
|
|
11
11
|
|
|
@@ -303,7 +303,7 @@ var init_Charts = __esm({
|
|
|
303
303
|
);
|
|
304
304
|
Charts_default = ({ data, loading }) => {
|
|
305
305
|
const { type, config } = data;
|
|
306
|
-
return /* @__PURE__ */ jsx("div", { className: styles_module_default.chart, children: loading ? (
|
|
306
|
+
return /* @__PURE__ */ jsx("div", { className: classNames11(styles_module_default.chart, "scroll-fade-in"), children: loading ? (
|
|
307
307
|
// Antd 骨架屏
|
|
308
308
|
/* @__PURE__ */ jsx(Skeleton.Node, { active: true, className: styles_module_default.chartSkeleton, children: /* @__PURE__ */ jsx(DotChartOutlined, { className: styles_module_default.chartSkeletonIcon }) })
|
|
309
309
|
) : /* @__PURE__ */ jsx(
|
|
@@ -407,6 +407,27 @@ var createChatService = (request) => {
|
|
|
407
407
|
const fileUpload = (formData) => {
|
|
408
408
|
return request.post("/lolr/storage/upload", formData, { timeout: 5 * 60 * 1e3 });
|
|
409
409
|
};
|
|
410
|
+
const labelItemUpdate = (agentId, params) => {
|
|
411
|
+
return request.post("/lolr/label/item", { agentId, ...params });
|
|
412
|
+
};
|
|
413
|
+
const labelItemDelete = (id) => {
|
|
414
|
+
return request.delete("/lolr/label/item", { id });
|
|
415
|
+
};
|
|
416
|
+
const labelsQuery = (agentId, params) => {
|
|
417
|
+
return request.get("/lolr/label", { agentId, ...params });
|
|
418
|
+
};
|
|
419
|
+
const labelItemsQuery = (agentId, params) => {
|
|
420
|
+
return request.get("/lolr/label/item", { ...params, agentId });
|
|
421
|
+
};
|
|
422
|
+
const labelItemTop = (params) => {
|
|
423
|
+
return request.put("/lolr/label/item/top", params);
|
|
424
|
+
};
|
|
425
|
+
const labelItemPromptAssistant = (prompt) => {
|
|
426
|
+
return request.post("/lolr/agent/prompts/optimization", { prompt });
|
|
427
|
+
};
|
|
428
|
+
const recommendQuestionsQuery = (agentId, conversationId) => {
|
|
429
|
+
return request.get("/lolr/agent/suggest", { maxCount: 3, agentId, conversationId });
|
|
430
|
+
};
|
|
410
431
|
return {
|
|
411
432
|
conversationsQuery,
|
|
412
433
|
conversationCreate,
|
|
@@ -424,7 +445,14 @@ var createChatService = (request) => {
|
|
|
424
445
|
agentInfoQuery,
|
|
425
446
|
agentCharacterQuery,
|
|
426
447
|
agentCharacterSelect,
|
|
427
|
-
fileUpload
|
|
448
|
+
fileUpload,
|
|
449
|
+
labelItemUpdate,
|
|
450
|
+
labelItemDelete,
|
|
451
|
+
labelsQuery,
|
|
452
|
+
labelItemsQuery,
|
|
453
|
+
labelItemTop,
|
|
454
|
+
labelItemPromptAssistant,
|
|
455
|
+
recommendQuestionsQuery
|
|
428
456
|
};
|
|
429
457
|
};
|
|
430
458
|
var createFileService = (request) => {
|
|
@@ -448,20 +476,19 @@ var defaultAgentLayout = {
|
|
|
448
476
|
conversationList: true,
|
|
449
477
|
preview: true,
|
|
450
478
|
messageList: true,
|
|
451
|
-
firstMessage: false,
|
|
452
479
|
senderHeader: false,
|
|
453
480
|
sender: true,
|
|
454
481
|
senderFooter: false,
|
|
455
482
|
globalHeader: false,
|
|
456
483
|
chatHeader: true,
|
|
457
|
-
disclaimerNotice: true
|
|
484
|
+
disclaimerNotice: true,
|
|
485
|
+
recommendQuestions: false
|
|
458
486
|
};
|
|
459
487
|
var defaultExpertLayout = {
|
|
460
488
|
leftPanel: false,
|
|
461
489
|
conversationList: false,
|
|
462
490
|
preview: false,
|
|
463
491
|
messageList: true,
|
|
464
|
-
firstMessage: false,
|
|
465
492
|
senderHeader: false,
|
|
466
493
|
sender: {
|
|
467
494
|
props: {
|
|
@@ -477,7 +504,8 @@ var defaultExpertLayout = {
|
|
|
477
504
|
conversationListBtn: false
|
|
478
505
|
}
|
|
479
506
|
},
|
|
480
|
-
disclaimerNotice: false
|
|
507
|
+
disclaimerNotice: false,
|
|
508
|
+
recommendQuestions: false
|
|
481
509
|
};
|
|
482
510
|
function createChatStore() {
|
|
483
511
|
const config = proxy({
|
|
@@ -571,6 +599,8 @@ function createChatStore() {
|
|
|
571
599
|
const receiver = proxy({
|
|
572
600
|
/** 当前激活的接收者信息(智能体或专家) */
|
|
573
601
|
active: {},
|
|
602
|
+
/** 智能体推荐问题列表 */
|
|
603
|
+
recommendQuestions: [],
|
|
574
604
|
/** 接收者加载状态 */
|
|
575
605
|
loading: false,
|
|
576
606
|
/** 接收者透传参数,后期可能扩展不透传参数 */
|
|
@@ -763,6 +793,9 @@ function createChatStore() {
|
|
|
763
793
|
const setContent = (content) => {
|
|
764
794
|
conversation.messages[conversation.active.id].content = content;
|
|
765
795
|
};
|
|
796
|
+
const setContentParams = (params) => {
|
|
797
|
+
conversation.messages[conversation.active.id].params = params;
|
|
798
|
+
};
|
|
766
799
|
const setFileList = (files = []) => {
|
|
767
800
|
conversation.messages[conversation.active.id].files = files;
|
|
768
801
|
};
|
|
@@ -785,6 +818,17 @@ function createChatStore() {
|
|
|
785
818
|
if (lastMessage.id !== messageId) return;
|
|
786
819
|
conversation.messages[conversationId].questionList = data;
|
|
787
820
|
};
|
|
821
|
+
const getRecommendQuestions = async (conversationId) => {
|
|
822
|
+
if (conversationId === conversation.active.id && conversation.active.member.agent?.id && !conversation.messages[conversationId].message.length) {
|
|
823
|
+
try {
|
|
824
|
+
const { data } = await config.services.request.recommendQuestionsQuery(conversation.active.member.agent.id, conversationId);
|
|
825
|
+
if (conversationId === conversation.active.id) {
|
|
826
|
+
receiver.recommendQuestions = data;
|
|
827
|
+
}
|
|
828
|
+
} catch (e) {
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
};
|
|
788
832
|
const feedback = async (conversationId, messageId, msgFeedback, index) => {
|
|
789
833
|
try {
|
|
790
834
|
conversation.feedback.loading = true;
|
|
@@ -874,6 +918,7 @@ function createChatStore() {
|
|
|
874
918
|
throw new Error("\u64CD\u4F5C\u88AB\u963B\u6B62");
|
|
875
919
|
}
|
|
876
920
|
await initConversation(conversationId);
|
|
921
|
+
receiver.recommendQuestions = [];
|
|
877
922
|
await setPreview();
|
|
878
923
|
config.hooks?.onAfterSwitchConversation?.(conversationId);
|
|
879
924
|
try {
|
|
@@ -902,6 +947,7 @@ function createChatStore() {
|
|
|
902
947
|
});
|
|
903
948
|
conversation.messages[conversationId].message = data.items;
|
|
904
949
|
}
|
|
950
|
+
getRecommendQuestions(conversationId);
|
|
905
951
|
config.hooks?.onAfterInitMessages?.(conversation.messages[conversationId].message);
|
|
906
952
|
config.hooks?.onAfterInit?.();
|
|
907
953
|
};
|
|
@@ -946,10 +992,11 @@ function createChatStore() {
|
|
|
946
992
|
stream: true
|
|
947
993
|
};
|
|
948
994
|
const extraParams = deepCopy(config.params.params || {});
|
|
949
|
-
Object.assign(extraParams, receiver.params, message2 ? {} : references?.params, params);
|
|
995
|
+
Object.assign(extraParams, receiver.params, message2 ? {} : { ...references?.params, ...conversation.messages[conversationId].params }, params);
|
|
950
996
|
sendParams.params = JSON.stringify(extraParams);
|
|
951
997
|
if (!message2) {
|
|
952
998
|
setContent("");
|
|
999
|
+
setContentParams();
|
|
953
1000
|
setFileList([]);
|
|
954
1001
|
setReferences();
|
|
955
1002
|
setHeaderOpen(false);
|
|
@@ -1116,6 +1163,8 @@ function createChatStore() {
|
|
|
1116
1163
|
setReferences,
|
|
1117
1164
|
/** 设置消息内容 */
|
|
1118
1165
|
setContent,
|
|
1166
|
+
/** 设置内容参数,透传大模型后清空 */
|
|
1167
|
+
setContentParams,
|
|
1119
1168
|
/** 设置文件列表 */
|
|
1120
1169
|
setFileList,
|
|
1121
1170
|
/** 设置头部展开状态 */
|
|
@@ -1161,7 +1210,7 @@ var styles_module_default2 = {
|
|
|
1161
1210
|
quoteTooltip: "styles_module_quoteTooltip",
|
|
1162
1211
|
quoteTooltipContainer: "styles_module_quoteTooltipContainer"
|
|
1163
1212
|
};
|
|
1164
|
-
var MessageRender_default = ({ message: message2, placement, onFilePreview }) => {
|
|
1213
|
+
var MessageRender_default = ({ message: message2, placement, onFilePreview, customComponents: propsCustomComponents }) => {
|
|
1165
1214
|
const msgContent = useMemo(
|
|
1166
1215
|
() => `${message2.msgContent || ""}${message2.msgContent && message2.tempContent ? "\n\n" : ""}${message2.tempContent || ""}`,
|
|
1167
1216
|
[message2.msgContent, message2.tempContent]
|
|
@@ -1194,13 +1243,16 @@ var MessageRender_default = ({ message: message2, placement, onFilePreview }) =>
|
|
|
1194
1243
|
onFilePreview?.(file);
|
|
1195
1244
|
}
|
|
1196
1245
|
};
|
|
1246
|
+
const mergedCustomComponents = useMemo(() => {
|
|
1247
|
+
return { ...customComponents, ...propsCustomComponents };
|
|
1248
|
+
}, [propsCustomComponents]);
|
|
1197
1249
|
return /* @__PURE__ */ jsx(Flex, { vertical: true, children: !(msgContent || message2.msgFiles.length) ? /* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(Spin, { size: "small" }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1198
1250
|
msgContent && /* @__PURE__ */ jsx(
|
|
1199
1251
|
Bubble,
|
|
1200
1252
|
{
|
|
1201
1253
|
placement,
|
|
1202
|
-
className:
|
|
1203
|
-
content: /* @__PURE__ */ jsx(RenderMarkdown, { content: replaceMarkdownTags(msgContent), customComponents, message: message2 })
|
|
1254
|
+
className: classNames11({ [styles_module_default2.loadingMessage]: message2.type }),
|
|
1255
|
+
content: /* @__PURE__ */ jsx(RenderMarkdown, { content: replaceMarkdownTags(msgContent), customComponents: mergedCustomComponents, message: message2 })
|
|
1204
1256
|
}
|
|
1205
1257
|
),
|
|
1206
1258
|
message2.msgFiles?.map((file) => /* @__PURE__ */ jsx(
|
|
@@ -1301,7 +1353,7 @@ var WelcomeItem_default = ({ icon = true, title = true, description = true, prom
|
|
|
1301
1353
|
/* @__PURE__ */ jsx(
|
|
1302
1354
|
Welcome,
|
|
1303
1355
|
{
|
|
1304
|
-
className:
|
|
1356
|
+
className: classNames11(styles_module_default3.chatWelcome, "p-t-32"),
|
|
1305
1357
|
variant: "borderless",
|
|
1306
1358
|
icon: /* @__PURE__ */ jsx(RenderWrapper, { control: icon, DefaultComponent: /* @__PURE__ */ jsx(Avatar, { shape: "square", size: 58, src: receiverState.active.logo }) }),
|
|
1307
1359
|
title: /* @__PURE__ */ jsx(RenderWrapper, { control: title, DefaultComponent: `\u4F60\u597D\uFF0C\u6211\u662F${receiverState.active.name || ""}` }),
|
|
@@ -1314,22 +1366,23 @@ var WelcomeItem_default = ({ icon = true, title = true, description = true, prom
|
|
|
1314
1366
|
)
|
|
1315
1367
|
}
|
|
1316
1368
|
),
|
|
1317
|
-
|
|
1369
|
+
/* @__PURE__ */ jsx(
|
|
1318
1370
|
RenderWrapper,
|
|
1319
1371
|
{
|
|
1320
1372
|
control: prompts,
|
|
1321
|
-
DefaultComponent: /* @__PURE__ */ jsx(
|
|
1373
|
+
DefaultComponent: receiverState?.recommendQuestions?.length > 0 && /* @__PURE__ */ jsx(
|
|
1322
1374
|
Prompts,
|
|
1323
1375
|
{
|
|
1324
1376
|
className: "m-t-16",
|
|
1325
1377
|
wrap: true,
|
|
1378
|
+
onItemClick: ({ data }) => chatStore.sendMessage(data.key),
|
|
1326
1379
|
items: [
|
|
1327
1380
|
{
|
|
1328
1381
|
key: "1",
|
|
1329
1382
|
label: "\u{1F914} \u63A8\u8350\u95EE\u9898:",
|
|
1330
|
-
children: receiverState
|
|
1383
|
+
children: receiverState?.recommendQuestions.map((question) => ({
|
|
1331
1384
|
key: question,
|
|
1332
|
-
description: /* @__PURE__ */ jsx("span", {
|
|
1385
|
+
description: /* @__PURE__ */ jsx("span", { className: classNames11(styles_module_default3.chatWelcomePrompts, "text-ellipsis"), children: question })
|
|
1333
1386
|
}))
|
|
1334
1387
|
}
|
|
1335
1388
|
]
|
|
@@ -1339,7 +1392,13 @@ var WelcomeItem_default = ({ icon = true, title = true, description = true, prom
|
|
|
1339
1392
|
)
|
|
1340
1393
|
] });
|
|
1341
1394
|
};
|
|
1342
|
-
var BubbleListItems_default = ({
|
|
1395
|
+
var BubbleListItems_default = ({
|
|
1396
|
+
firstMessages = [],
|
|
1397
|
+
welcomeMessage = true,
|
|
1398
|
+
avatar = { user: false, agent: true, other: true },
|
|
1399
|
+
agentActions = false,
|
|
1400
|
+
customComponents: customComponents2 = {}
|
|
1401
|
+
}) => {
|
|
1343
1402
|
const chatStore = useChatStore();
|
|
1344
1403
|
const receiverState = useSnapshot(chatStore.receiver);
|
|
1345
1404
|
const conversationState = useSnapshot(chatStore.conversation);
|
|
@@ -1422,6 +1481,7 @@ var BubbleListItems_default = ({ firstMessage = false, welcomeMessage = true, av
|
|
|
1422
1481
|
const roleKey = Object.keys(conversationRoles).find((key) => conversationRoles[key].id === sender.id);
|
|
1423
1482
|
return conversationRoles[roleKey] || {};
|
|
1424
1483
|
};
|
|
1484
|
+
const messageRefs = useRef({});
|
|
1425
1485
|
const chatRecords = useMemo(() => {
|
|
1426
1486
|
return (chatMessage?.message || []).map((message2, index) => {
|
|
1427
1487
|
const role = getRole(message2.sender);
|
|
@@ -1431,19 +1491,42 @@ var BubbleListItems_default = ({ firstMessage = false, welcomeMessage = true, av
|
|
|
1431
1491
|
variant: "borderless",
|
|
1432
1492
|
avatar: role.avatar,
|
|
1433
1493
|
content: /* @__PURE__ */ jsx(
|
|
1434
|
-
|
|
1494
|
+
"div",
|
|
1435
1495
|
{
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1496
|
+
ref: (el) => {
|
|
1497
|
+
messageRefs.current[message2.id] = el;
|
|
1498
|
+
},
|
|
1499
|
+
children: /* @__PURE__ */ jsx(
|
|
1500
|
+
MessageRender_default,
|
|
1501
|
+
{
|
|
1502
|
+
message: message2,
|
|
1503
|
+
placement: role.placement,
|
|
1504
|
+
customComponents: customComponents2,
|
|
1505
|
+
onFilePreview: (file) => chatStore.setPreview({
|
|
1506
|
+
fileUrl: file.content,
|
|
1507
|
+
suffix: file.extension,
|
|
1508
|
+
fileName: file.name
|
|
1509
|
+
})
|
|
1510
|
+
}
|
|
1511
|
+
)
|
|
1443
1512
|
}
|
|
1444
1513
|
),
|
|
1445
1514
|
footer: /* @__PURE__ */ jsx(Flex, { children: role.user === "agent" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1446
|
-
/* @__PURE__ */ jsx(
|
|
1515
|
+
/* @__PURE__ */ jsx(
|
|
1516
|
+
Button,
|
|
1517
|
+
{
|
|
1518
|
+
onClick: () => {
|
|
1519
|
+
const container = messageRefs.current[message2.id];
|
|
1520
|
+
if (!container) return;
|
|
1521
|
+
const markdown = htmlToMarkdown(container?.innerHTML) || message2.msgContent;
|
|
1522
|
+
copyText(markdown);
|
|
1523
|
+
},
|
|
1524
|
+
color: "default",
|
|
1525
|
+
variant: "text",
|
|
1526
|
+
size: "small",
|
|
1527
|
+
icon: /* @__PURE__ */ jsx(CopyOutlined, {})
|
|
1528
|
+
}
|
|
1529
|
+
),
|
|
1447
1530
|
/* @__PURE__ */ jsx(
|
|
1448
1531
|
Button,
|
|
1449
1532
|
{
|
|
@@ -1465,6 +1548,18 @@ var BubbleListItems_default = ({ firstMessage = false, welcomeMessage = true, av
|
|
|
1465
1548
|
icon: /* @__PURE__ */ jsx(DislikeOutlined, {}),
|
|
1466
1549
|
onClick: () => chatStore.feedback(conversationState.active.id, message2.id, 2, index)
|
|
1467
1550
|
}
|
|
1551
|
+
),
|
|
1552
|
+
/* @__PURE__ */ jsx(
|
|
1553
|
+
RenderWrapper,
|
|
1554
|
+
{
|
|
1555
|
+
control: agentActions,
|
|
1556
|
+
ctx: {
|
|
1557
|
+
message: message2,
|
|
1558
|
+
get dom() {
|
|
1559
|
+
return messageRefs.current[message2.id];
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1468
1563
|
)
|
|
1469
1564
|
] }) })
|
|
1470
1565
|
// ...(isHasTime
|
|
@@ -1473,26 +1568,28 @@ var BubbleListItems_default = ({ firstMessage = false, welcomeMessage = true, av
|
|
|
1473
1568
|
};
|
|
1474
1569
|
});
|
|
1475
1570
|
}, [chatMessage?.message]);
|
|
1476
|
-
const
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
{
|
|
1480
|
-
key:
|
|
1481
|
-
|
|
1482
|
-
|
|
1571
|
+
const firstMessagesRecord = useMemo(() => {
|
|
1572
|
+
return (firstMessages || []).map((firstMessage, index) => {
|
|
1573
|
+
const { member, ...args } = firstMessage;
|
|
1574
|
+
return {
|
|
1575
|
+
key: `firstMessage-${index}`,
|
|
1576
|
+
placement: conversationRoles[member]?.placement,
|
|
1577
|
+
avatar: conversationRoles[member]?.avatar,
|
|
1483
1578
|
// avatar: { style: { visibility: 'hidden' } }
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1579
|
+
variant: "borderless",
|
|
1580
|
+
...args
|
|
1581
|
+
};
|
|
1582
|
+
});
|
|
1583
|
+
}, [firstMessages]);
|
|
1487
1584
|
const bubbleListItems = useMemo(() => {
|
|
1488
1585
|
const list = [];
|
|
1489
|
-
list.push(...
|
|
1586
|
+
list.push(...firstMessagesRecord);
|
|
1490
1587
|
list.push(...chatRecords, ...questionList);
|
|
1491
1588
|
if (list.length) {
|
|
1492
1589
|
return list;
|
|
1493
1590
|
}
|
|
1494
1591
|
return [...welcomeMessageRecord];
|
|
1495
|
-
}, [chatRecords, questionList, welcomeMessageRecord,
|
|
1592
|
+
}, [chatRecords, questionList, welcomeMessageRecord, firstMessagesRecord]);
|
|
1496
1593
|
const listRef = useRef(null);
|
|
1497
1594
|
const autoScrollRef = useRef(true);
|
|
1498
1595
|
const handleScroll = (el) => {
|
|
@@ -1523,7 +1620,7 @@ var BubbleListItems_default = ({ firstMessage = false, welcomeMessage = true, av
|
|
|
1523
1620
|
autoScroll: false,
|
|
1524
1621
|
ref: listRef,
|
|
1525
1622
|
items: bubbleListItems,
|
|
1526
|
-
className:
|
|
1623
|
+
className: classNames11(styles_module_default3.nsBubbleList, "height-full", "scroll-fade-in", "zero-chat-bubbles"),
|
|
1527
1624
|
onScroll: handleScroll
|
|
1528
1625
|
},
|
|
1529
1626
|
conversationState.active.id
|
|
@@ -1558,7 +1655,7 @@ var CharacterList_default = () => {
|
|
|
1558
1655
|
/* @__PURE__ */ jsx(
|
|
1559
1656
|
Avatar,
|
|
1560
1657
|
{
|
|
1561
|
-
className:
|
|
1658
|
+
className: classNames11(styles_module_default3.nsAvatarListItemIcon, "cursor-pointer", {
|
|
1562
1659
|
[styles_module_default3.nsAvatarListItemIconActive]: activeCharacter.id === item.id
|
|
1563
1660
|
}),
|
|
1564
1661
|
size: 50,
|
|
@@ -1654,7 +1751,7 @@ var ChatHeader_default = ({
|
|
|
1654
1751
|
const chatStore = useChatStore();
|
|
1655
1752
|
const receiverState = useSnapshot(chatStore.receiver);
|
|
1656
1753
|
const configState = useSnapshot(chatStore.config);
|
|
1657
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className:
|
|
1754
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className: classNames11(styles_module_default3.nsChatHeader, "zero-chat-header"), children: [
|
|
1658
1755
|
/* @__PURE__ */ jsxs(Flex, { gap: 4, align: "center", children: [
|
|
1659
1756
|
/* @__PURE__ */ jsx(RenderWrapper, { control: avatar, DefaultComponent: /* @__PURE__ */ jsx(Avatar, { size: 22, src: receiverState.active.logo, alt: receiverState.active.name }) }),
|
|
1660
1757
|
/* @__PURE__ */ jsx(RenderWrapper, { control: title, DefaultComponent: /* @__PURE__ */ jsx("div", { className: styles_module_default3.nsChatTitle, children: receiverState.active.name }) }),
|
|
@@ -1932,6 +2029,396 @@ var ChatSender_default = forwardRef(
|
|
|
1932
2029
|
// src/ui/common/ChatSender.tsx
|
|
1933
2030
|
init_Context();
|
|
1934
2031
|
|
|
2032
|
+
// src/ui/common/FeaturesRenderer.tsx
|
|
2033
|
+
init_Context();
|
|
2034
|
+
|
|
2035
|
+
// src/ui/common/QuickAsk/QuickAskPanel.tsx
|
|
2036
|
+
init_Context();
|
|
2037
|
+
|
|
2038
|
+
// src/ui/common/QuickAsk/QuickAskEditModal.tsx
|
|
2039
|
+
init_Context();
|
|
2040
|
+
var QuickAskEditModal_default = ({ open, onCancel, loading, onConfirm, initialValues, categories = [] }) => {
|
|
2041
|
+
const [form] = Form.useForm();
|
|
2042
|
+
const chatStore = useChatStore();
|
|
2043
|
+
const configState = useSnapshot(chatStore.config);
|
|
2044
|
+
const [promptLoading, setPromptLoading] = useState(false);
|
|
2045
|
+
const [description, setDescription] = useState("");
|
|
2046
|
+
const handleOk = async () => {
|
|
2047
|
+
try {
|
|
2048
|
+
const values = await form.validateFields();
|
|
2049
|
+
if (values) {
|
|
2050
|
+
onConfirm(values);
|
|
2051
|
+
}
|
|
2052
|
+
} catch (error) {
|
|
2053
|
+
console.error("Validation failed:", error);
|
|
2054
|
+
}
|
|
2055
|
+
};
|
|
2056
|
+
const handleGenerate = async () => {
|
|
2057
|
+
if (!description.trim()) return;
|
|
2058
|
+
setPromptLoading(true);
|
|
2059
|
+
try {
|
|
2060
|
+
const res = await configState.services.request?.labelItemPromptAssistant?.(description);
|
|
2061
|
+
if (res.data) {
|
|
2062
|
+
form.setFieldsValue({
|
|
2063
|
+
title: res.data.title,
|
|
2064
|
+
labelName: res.data.labelName,
|
|
2065
|
+
content: res.data.content
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
} finally {
|
|
2069
|
+
setPromptLoading(false);
|
|
2070
|
+
}
|
|
2071
|
+
};
|
|
2072
|
+
return /* @__PURE__ */ jsxs(
|
|
2073
|
+
Modal,
|
|
2074
|
+
{
|
|
2075
|
+
title: initialValues?.id ? "\u7F16\u8F91\u5FEB\u901F\u63D0\u95EE" : "\u65B0\u589E\u5FEB\u901F\u63D0\u95EE",
|
|
2076
|
+
open,
|
|
2077
|
+
onCancel,
|
|
2078
|
+
onOk: handleOk,
|
|
2079
|
+
width: 600,
|
|
2080
|
+
okText: "\u786E\u5B9A",
|
|
2081
|
+
okButtonProps: {
|
|
2082
|
+
loading
|
|
2083
|
+
},
|
|
2084
|
+
cancelText: "\u53D6\u6D88",
|
|
2085
|
+
children: [
|
|
2086
|
+
/* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 4, children: [
|
|
2087
|
+
/* @__PURE__ */ jsx(
|
|
2088
|
+
Input.TextArea,
|
|
2089
|
+
{
|
|
2090
|
+
rows: 4,
|
|
2091
|
+
placeholder: "\u8BF7\u8F93\u5165\u95EE\u9898\u63CF\u8FF0\uFF0C\u7F57\u62C9\u63D0\u793A\u8BCD\u52A9\u624B\u5C06\u5E2E\u60A8\u751F\u6210\u95EE\u9898\u540D\u79F0\uFF0C\u5206\u7C7B\u548C\u5185\u5BB9\u3002",
|
|
2092
|
+
value: description,
|
|
2093
|
+
onChange: (e) => setDescription(e.target.value),
|
|
2094
|
+
disabled: promptLoading
|
|
2095
|
+
}
|
|
2096
|
+
),
|
|
2097
|
+
/* @__PURE__ */ jsx(Flex, { justify: "end", children: /* @__PURE__ */ jsx(
|
|
2098
|
+
Button,
|
|
2099
|
+
{
|
|
2100
|
+
type: "primary",
|
|
2101
|
+
size: "small",
|
|
2102
|
+
icon: /* @__PURE__ */ jsx(SignatureOutlined, {}),
|
|
2103
|
+
onClick: handleGenerate,
|
|
2104
|
+
loading: promptLoading,
|
|
2105
|
+
disabled: !description.trim(),
|
|
2106
|
+
children: "\u7F57\u62C9\u63D0\u793A\u8BCD\u52A9\u624B"
|
|
2107
|
+
}
|
|
2108
|
+
) })
|
|
2109
|
+
] }),
|
|
2110
|
+
/* @__PURE__ */ jsxs(Form, { form, layout: "vertical", initialValues, children: [
|
|
2111
|
+
/* @__PURE__ */ jsx(Form.Item, { label: "\u95EE\u9898ID", name: "id", hidden: true, children: /* @__PURE__ */ jsx(Input, { disabled: true }) }),
|
|
2112
|
+
/* @__PURE__ */ jsx(Form.Item, { label: "\u95EE\u9898\u540D\u79F0", name: "title", rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u95EE\u9898\u540D\u79F0" }], children: /* @__PURE__ */ jsx(Input, { placeholder: "\u8BF7\u8F93\u5165\u95EE\u9898\u540D\u79F0" }) }),
|
|
2113
|
+
/* @__PURE__ */ jsx(Form.Item, { label: "\u95EE\u9898\u5206\u7C7B", name: "labelName", rules: [{ required: true, message: "\u8BF7\u9009\u62E9\u6216\u8F93\u5165\u95EE\u9898\u5206\u7C7B" }], children: /* @__PURE__ */ jsx(
|
|
2114
|
+
AutoComplete,
|
|
2115
|
+
{
|
|
2116
|
+
fieldNames: { value: "labelName" },
|
|
2117
|
+
placeholder: "\u8BF7\u9009\u62E9\u95EE\u9898\u5206\u7C7B\u6216\u8F93\u5165\u65B0\u7684\u5206\u7C7B",
|
|
2118
|
+
options: categories
|
|
2119
|
+
}
|
|
2120
|
+
) }),
|
|
2121
|
+
/* @__PURE__ */ jsx(Form.Item, { label: "\u95EE\u9898\u5185\u5BB9", name: "content", rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u5177\u4F53\u63D0\u95EE\u5185\u5BB9" }], children: /* @__PURE__ */ jsx(Input.TextArea, { placeholder: "\u8BF7\u8F93\u5165\u5177\u4F53\u63D0\u95EE\u5185\u5BB9\uFF0C\u5982\uFF1A\u5E2E\u6211\u6269\u5199\u4E00\u4EFD\u8BC1\u636E\u8BF4\u660E", rows: 6 }) })
|
|
2122
|
+
] })
|
|
2123
|
+
]
|
|
2124
|
+
}
|
|
2125
|
+
);
|
|
2126
|
+
};
|
|
2127
|
+
|
|
2128
|
+
// src/ui/common/QuickAsk/styles.module.less
|
|
2129
|
+
var styles_module_default4 = {
|
|
2130
|
+
quickAskPanel: "styles_module_quickAskPanel",
|
|
2131
|
+
tagContainer: "styles_module_tagContainer",
|
|
2132
|
+
quickAskItem: "styles_module_quickAskItem",
|
|
2133
|
+
quickAskItemHeader: "styles_module_quickAskItemHeader",
|
|
2134
|
+
quickAskItemBody: "styles_module_quickAskItemBody"
|
|
2135
|
+
};
|
|
2136
|
+
var QuickAskPanel_default = () => {
|
|
2137
|
+
const { message: message2 } = App.useApp();
|
|
2138
|
+
const chatStore = useChatStore();
|
|
2139
|
+
const configState = useSnapshot(chatStore.config);
|
|
2140
|
+
const receiverState = useSnapshot(chatStore.receiver);
|
|
2141
|
+
const [searchText, setSearchText, getSearchText] = useRefState("");
|
|
2142
|
+
const [searchExpanded, setSearchExpanded] = useState(false);
|
|
2143
|
+
const [activeTab, setActiveTab, getActiveTab] = useRefState({});
|
|
2144
|
+
const [categories, setCategories] = useState([]);
|
|
2145
|
+
const [items, setItems] = useState([]);
|
|
2146
|
+
const [editModalOpen, setEditModalOpen] = useState(false);
|
|
2147
|
+
const [editingItem, setEditingItem] = useState();
|
|
2148
|
+
const fetchCategories = async () => {
|
|
2149
|
+
try {
|
|
2150
|
+
const res = await configState.services.request?.labelsQuery?.(receiverState.active?.id, { pageNo: 1, pageSize: 1e3 });
|
|
2151
|
+
if (res?.data) {
|
|
2152
|
+
setCategories(res.data?.items);
|
|
2153
|
+
}
|
|
2154
|
+
} catch (err) {
|
|
2155
|
+
}
|
|
2156
|
+
};
|
|
2157
|
+
const fetchItems = useDebounce(async () => {
|
|
2158
|
+
try {
|
|
2159
|
+
const res = await configState.services.request?.labelItemsQuery?.(receiverState.active?.id, {
|
|
2160
|
+
labelId: getActiveTab().id,
|
|
2161
|
+
keyword: getSearchText()
|
|
2162
|
+
});
|
|
2163
|
+
if (res?.data) {
|
|
2164
|
+
setItems(res.data);
|
|
2165
|
+
}
|
|
2166
|
+
} catch (err) {
|
|
2167
|
+
}
|
|
2168
|
+
});
|
|
2169
|
+
useEffect(() => {
|
|
2170
|
+
if (receiverState.active?.id) {
|
|
2171
|
+
fetchCategories();
|
|
2172
|
+
fetchItems();
|
|
2173
|
+
}
|
|
2174
|
+
}, [receiverState.active?.id]);
|
|
2175
|
+
const [loading, setLoading] = useState(false);
|
|
2176
|
+
const handleEditConfirm = async (values) => {
|
|
2177
|
+
try {
|
|
2178
|
+
setLoading(true);
|
|
2179
|
+
await configState.services.request?.labelItemUpdate?.(receiverState.active?.id, values);
|
|
2180
|
+
setEditModalOpen(false);
|
|
2181
|
+
message2.success("\u4FDD\u5B58\u6210\u529F");
|
|
2182
|
+
if (!getActiveTab().id || values.labelName === getActiveTab().labelName) {
|
|
2183
|
+
fetchItems();
|
|
2184
|
+
}
|
|
2185
|
+
fetchCategories();
|
|
2186
|
+
} finally {
|
|
2187
|
+
setLoading(false);
|
|
2188
|
+
}
|
|
2189
|
+
};
|
|
2190
|
+
const handleDelete = async (id) => {
|
|
2191
|
+
try {
|
|
2192
|
+
await configState.services.request?.labelItemDelete?.(id);
|
|
2193
|
+
message2.success("\u5220\u9664\u6210\u529F");
|
|
2194
|
+
fetchItems();
|
|
2195
|
+
} catch (err) {
|
|
2196
|
+
}
|
|
2197
|
+
};
|
|
2198
|
+
const handleTop = async (item) => {
|
|
2199
|
+
try {
|
|
2200
|
+
await configState.services.request?.labelItemTop?.({
|
|
2201
|
+
id: item.id,
|
|
2202
|
+
isTop: !item.isTop
|
|
2203
|
+
});
|
|
2204
|
+
message2.success(item.isTop ? "\u53D6\u6D88\u7F6E\u9876\u6210\u529F" : "\u7F6E\u9876\u6210\u529F");
|
|
2205
|
+
fetchItems();
|
|
2206
|
+
} catch (err) {
|
|
2207
|
+
}
|
|
2208
|
+
};
|
|
2209
|
+
return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: styles_module_default4.quickAskPanel, children: [
|
|
2210
|
+
/* @__PURE__ */ jsx(Flex, { justify: "space-between", align: "center", children: /* @__PURE__ */ jsx(Typography.Title, { level: 5, children: "\u5FEB\u901F\u63D0\u95EE" }) }),
|
|
2211
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 8, className: "m-b-16 m-t-16", children: [
|
|
2212
|
+
!searchExpanded && /* @__PURE__ */ jsx(
|
|
2213
|
+
Button,
|
|
2214
|
+
{
|
|
2215
|
+
type: "dashed",
|
|
2216
|
+
block: true,
|
|
2217
|
+
icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
|
|
2218
|
+
className: "flex-1",
|
|
2219
|
+
onClick: () => {
|
|
2220
|
+
setEditingItem(null);
|
|
2221
|
+
setEditModalOpen(true);
|
|
2222
|
+
},
|
|
2223
|
+
children: "\u65B0\u589E\u5FEB\u901F\u63D0\u95EE"
|
|
2224
|
+
}
|
|
2225
|
+
),
|
|
2226
|
+
searchExpanded ? /* @__PURE__ */ jsx(
|
|
2227
|
+
Input,
|
|
2228
|
+
{
|
|
2229
|
+
autoFocus: true,
|
|
2230
|
+
placeholder: "\u8F93\u5165\u95EE\u9898\u540D\u79F0\u6216\u5185\u5BB9\u68C0\u7D22",
|
|
2231
|
+
prefix: /* @__PURE__ */ jsx(SearchOutlined, {}),
|
|
2232
|
+
value: searchText,
|
|
2233
|
+
onChange: (e) => {
|
|
2234
|
+
setSearchText(e.target.value);
|
|
2235
|
+
fetchItems();
|
|
2236
|
+
},
|
|
2237
|
+
className: "flex-1",
|
|
2238
|
+
allowClear: true,
|
|
2239
|
+
onBlur: () => setSearchExpanded(false)
|
|
2240
|
+
}
|
|
2241
|
+
) : /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(SearchOutlined, {}), onClick: () => setSearchExpanded(true) })
|
|
2242
|
+
] }),
|
|
2243
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", className: classNames11("scroll-fade-in", "m-b-16", styles_module_default4.tagContainer), children: [
|
|
2244
|
+
/* @__PURE__ */ jsx(
|
|
2245
|
+
Tag,
|
|
2246
|
+
{
|
|
2247
|
+
color: !activeTab.id ? "processing" : "default",
|
|
2248
|
+
className: "cursor-pointer",
|
|
2249
|
+
bordered: false,
|
|
2250
|
+
onClick: () => {
|
|
2251
|
+
setActiveTab({});
|
|
2252
|
+
fetchItems();
|
|
2253
|
+
},
|
|
2254
|
+
children: "\u5168\u90E8"
|
|
2255
|
+
}
|
|
2256
|
+
),
|
|
2257
|
+
categories.map((c) => /* @__PURE__ */ jsx(
|
|
2258
|
+
Tag,
|
|
2259
|
+
{
|
|
2260
|
+
color: activeTab.id === c.id ? "processing" : "default",
|
|
2261
|
+
className: "cursor-pointer",
|
|
2262
|
+
bordered: false,
|
|
2263
|
+
onClick: () => {
|
|
2264
|
+
setActiveTab(c);
|
|
2265
|
+
fetchItems();
|
|
2266
|
+
},
|
|
2267
|
+
children: c.labelName
|
|
2268
|
+
},
|
|
2269
|
+
c.id
|
|
2270
|
+
))
|
|
2271
|
+
] }),
|
|
2272
|
+
/* @__PURE__ */ jsx(Flex, { vertical: true, className: "flex-1", children: /* @__PURE__ */ jsx(Flex, { vertical: true, gap: 8, className: "height-full scroll-fade-in", children: items.map((item) => /* @__PURE__ */ jsxs(
|
|
2273
|
+
"div",
|
|
2274
|
+
{
|
|
2275
|
+
className: styles_module_default4.quickAskItem,
|
|
2276
|
+
onClick: () => {
|
|
2277
|
+
chatStore.setContent(item.content);
|
|
2278
|
+
chatStore.setContentParams({
|
|
2279
|
+
use_template: 1
|
|
2280
|
+
});
|
|
2281
|
+
},
|
|
2282
|
+
children: [
|
|
2283
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 8, justify: "space-between", className: styles_module_default4.quickAskItemHeader, children: [
|
|
2284
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 text-ellipsis", children: item.title }),
|
|
2285
|
+
/* @__PURE__ */ jsxs(Space, { size: 4, children: [
|
|
2286
|
+
/* @__PURE__ */ jsx(
|
|
2287
|
+
Button,
|
|
2288
|
+
{
|
|
2289
|
+
type: "primary",
|
|
2290
|
+
size: "small",
|
|
2291
|
+
icon: /* @__PURE__ */ jsx(PushpinOutlined, { rotate: item.isTop ? -45 : 0 }),
|
|
2292
|
+
title: item.isTop ? "\u53D6\u6D88\u7F6E\u9876" : "\u7F6E\u9876",
|
|
2293
|
+
onClick: (e) => {
|
|
2294
|
+
e.stopPropagation();
|
|
2295
|
+
handleTop(item);
|
|
2296
|
+
}
|
|
2297
|
+
},
|
|
2298
|
+
"top"
|
|
2299
|
+
),
|
|
2300
|
+
/* @__PURE__ */ jsx(
|
|
2301
|
+
Button,
|
|
2302
|
+
{
|
|
2303
|
+
type: "primary",
|
|
2304
|
+
size: "small",
|
|
2305
|
+
icon: /* @__PURE__ */ jsx(CopyOutlined, {}),
|
|
2306
|
+
title: "\u590D\u5236",
|
|
2307
|
+
onClick: (e) => {
|
|
2308
|
+
e.stopPropagation();
|
|
2309
|
+
handleEditConfirm({
|
|
2310
|
+
title: item.title,
|
|
2311
|
+
labelName: item.labelName,
|
|
2312
|
+
content: item.content
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
},
|
|
2316
|
+
"copy"
|
|
2317
|
+
),
|
|
2318
|
+
/* @__PURE__ */ jsx(
|
|
2319
|
+
Button,
|
|
2320
|
+
{
|
|
2321
|
+
type: "primary",
|
|
2322
|
+
size: "small",
|
|
2323
|
+
icon: /* @__PURE__ */ jsx(EditOutlined, {}),
|
|
2324
|
+
title: "\u7F16\u8F91",
|
|
2325
|
+
onClick: (e) => {
|
|
2326
|
+
e.stopPropagation();
|
|
2327
|
+
setEditingItem(item);
|
|
2328
|
+
setEditModalOpen(true);
|
|
2329
|
+
}
|
|
2330
|
+
},
|
|
2331
|
+
"edit"
|
|
2332
|
+
),
|
|
2333
|
+
item.canDelete && /* @__PURE__ */ jsx(
|
|
2334
|
+
Popconfirm,
|
|
2335
|
+
{
|
|
2336
|
+
title: "\u63D0\u793A",
|
|
2337
|
+
okText: "\u786E\u5B9A",
|
|
2338
|
+
cancelText: "\u53D6\u6D88",
|
|
2339
|
+
description: "\u786E\u8BA4\u5220\u9664\u95EE\u9898\u5417?",
|
|
2340
|
+
onConfirm: (e) => {
|
|
2341
|
+
e.stopPropagation();
|
|
2342
|
+
handleDelete(item.id);
|
|
2343
|
+
},
|
|
2344
|
+
children: /* @__PURE__ */ jsx(Button, { type: "primary", size: "small", icon: /* @__PURE__ */ jsx(DeleteOutlined, {}), title: "\u5220\u9664", onClick: (e) => e.stopPropagation() })
|
|
2345
|
+
},
|
|
2346
|
+
"delete"
|
|
2347
|
+
)
|
|
2348
|
+
] })
|
|
2349
|
+
] }),
|
|
2350
|
+
/* @__PURE__ */ jsx("div", { className: classNames11(styles_module_default4.quickAskItemBody), children: /* @__PURE__ */ jsx("div", { className: "text-ellipsis-3", children: item.content }) })
|
|
2351
|
+
]
|
|
2352
|
+
},
|
|
2353
|
+
item.id
|
|
2354
|
+
)) }) }),
|
|
2355
|
+
editModalOpen && /* @__PURE__ */ jsx(
|
|
2356
|
+
QuickAskEditModal_default,
|
|
2357
|
+
{
|
|
2358
|
+
open: editModalOpen,
|
|
2359
|
+
onCancel: () => setEditModalOpen(false),
|
|
2360
|
+
onConfirm: handleEditConfirm,
|
|
2361
|
+
loading,
|
|
2362
|
+
initialValues: editingItem,
|
|
2363
|
+
categories
|
|
2364
|
+
}
|
|
2365
|
+
)
|
|
2366
|
+
] });
|
|
2367
|
+
};
|
|
2368
|
+
var FeaturesRenderer_default = () => {
|
|
2369
|
+
const chatStore = useChatStore();
|
|
2370
|
+
const receiverState = useSnapshot(chatStore.receiver);
|
|
2371
|
+
const conversationState = useSnapshot(chatStore.conversation);
|
|
2372
|
+
const chatMessage = useMemo(
|
|
2373
|
+
() => conversationState.messages[conversationState.active.id] || {},
|
|
2374
|
+
[conversationState.messages[conversationState.active.id]]
|
|
2375
|
+
);
|
|
2376
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2377
|
+
receiverState.active.feature?.deepThink && /* @__PURE__ */ jsx(
|
|
2378
|
+
Button,
|
|
2379
|
+
{
|
|
2380
|
+
size: "small",
|
|
2381
|
+
color: receiverState.params.thinkMode === "1" ? "primary" : "default",
|
|
2382
|
+
variant: "filled",
|
|
2383
|
+
onClick: () => chatStore.setReceiverParams({ thinkMode: receiverState.params.thinkMode === "1" ? "2" : "1" }),
|
|
2384
|
+
children: "\u6DF1\u5EA6\u601D\u8003"
|
|
2385
|
+
}
|
|
2386
|
+
),
|
|
2387
|
+
receiverState.active.feature?.switchManual && /* @__PURE__ */ jsx(
|
|
2388
|
+
Button,
|
|
2389
|
+
{
|
|
2390
|
+
size: "small",
|
|
2391
|
+
title: chatMessage?.speakHuman ? "\u5F53\u524D\u72B6\u6001\u4E3A\u4EBA\u5DE5\u6A21\u5F0F\u3002\u60A8\u53D1\u9001\u7684\u95EE\u9898\u5C06\u76F4\u63A5\u53D1\u9001\u7ED9\u4E13\u5BB6\uFF0C\u667A\u80FD\u52A9\u624B\u5C06\u4E0D\u518D\u56DE\u590D" : "\u5F53\u524D\u72B6\u6001\u4E3A\u667A\u80FD\u52A9\u624B\u6A21\u5F0F\u3002\u60A8\u53D1\u9001\u7684\u95EE\u9898\u5C06\u53D1\u9001\u7ED9\u667A\u80FD\u52A9\u624B\uFF0C\u667A\u80FD\u52A9\u624B\u5C06\u56DE\u590D\u60A8",
|
|
2392
|
+
shape: "round",
|
|
2393
|
+
icon: /* @__PURE__ */ jsx(UserSwitchOutlined, {}),
|
|
2394
|
+
color: chatMessage?.speakHuman ? "primary" : "default",
|
|
2395
|
+
variant: "filled",
|
|
2396
|
+
onClick: () => {
|
|
2397
|
+
chatStore.setSpeakHuman?.(!chatMessage?.speakHuman);
|
|
2398
|
+
},
|
|
2399
|
+
children: "\u5411\u4E13\u5BB6\u54A8\u8BE2"
|
|
2400
|
+
}
|
|
2401
|
+
),
|
|
2402
|
+
/* @__PURE__ */ jsx(
|
|
2403
|
+
Popover,
|
|
2404
|
+
{
|
|
2405
|
+
trigger: "click",
|
|
2406
|
+
placement: "topLeft",
|
|
2407
|
+
content: /* @__PURE__ */ jsx(QuickAskPanel_default, {}),
|
|
2408
|
+
children: /* @__PURE__ */ jsx(
|
|
2409
|
+
Button,
|
|
2410
|
+
{
|
|
2411
|
+
size: "small",
|
|
2412
|
+
color: "primary",
|
|
2413
|
+
variant: "filled",
|
|
2414
|
+
children: "\u5FEB\u901F\u63D0\u95EE"
|
|
2415
|
+
}
|
|
2416
|
+
)
|
|
2417
|
+
}
|
|
2418
|
+
)
|
|
2419
|
+
] });
|
|
2420
|
+
};
|
|
2421
|
+
|
|
1935
2422
|
// src/ui/common/SenderPromptsItems.tsx
|
|
1936
2423
|
init_Context();
|
|
1937
2424
|
var SenderPromptsItems_default = () => {
|
|
@@ -1950,14 +2437,14 @@ var SenderPromptsItems_default = () => {
|
|
|
1950
2437
|
split: false,
|
|
1951
2438
|
className: styles_module_default3.nsSenderList,
|
|
1952
2439
|
dataSource: question.items,
|
|
1953
|
-
renderItem: (item) => /* @__PURE__ */ jsx(List.Item, { onClick: () => chatStore.sendMessage(item.question), className: styles_module_default3.nsSenderListItem, children: item.question }),
|
|
2440
|
+
renderItem: (item) => /* @__PURE__ */ jsx(List.Item, { onClick: () => chatStore.sendMessage(item.question), className: styles_module_default3.nsSenderListItem, children: /* @__PURE__ */ jsx("div", { className: "text-ellipsis", children: item.question }) }),
|
|
1954
2441
|
footer: /* @__PURE__ */ jsx(Flex, { justify: "end", className: styles_module_default3.nsSenderListFooter, children: "(\u60A8\u53EF\u70B9\u51FB\u4EE5\u4E0A\u95EE\u9898\u5F00\u542FAI\u4F53\u9A8C)" })
|
|
1955
2442
|
}
|
|
1956
2443
|
),
|
|
1957
2444
|
title: /* @__PURE__ */ jsx(
|
|
1958
2445
|
"div",
|
|
1959
2446
|
{
|
|
1960
|
-
className:
|
|
2447
|
+
className: classNames11(styles_module_default3.nsSenderListTitle, "text-ellipsis"),
|
|
1961
2448
|
children: `${receiverState.active.name}\u5F00\u59CB\u5173\u6CE8${question.name}\u5185\u5BB9\uFF01`
|
|
1962
2449
|
}
|
|
1963
2450
|
),
|
|
@@ -2015,31 +2502,7 @@ var ChatSender_default2 = forwardRef(
|
|
|
2015
2502
|
sendBtnProps: isFunction(sendBtnProps) ? sendBtnProps() : {},
|
|
2016
2503
|
extraFooterBelow: /* @__PURE__ */ jsx(RenderWrapper, { control: footerBelow }),
|
|
2017
2504
|
extraFooter: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2018
|
-
|
|
2019
|
-
Button,
|
|
2020
|
-
{
|
|
2021
|
-
size: "small",
|
|
2022
|
-
color: receiverState.params.thinkMode === "1" ? "primary" : "default",
|
|
2023
|
-
variant: "filled",
|
|
2024
|
-
onClick: () => chatStore.setReceiverParams({ thinkMode: receiverState.params.thinkMode === "1" ? "2" : "1" }),
|
|
2025
|
-
children: "\u6DF1\u5EA6\u601D\u8003"
|
|
2026
|
-
}
|
|
2027
|
-
),
|
|
2028
|
-
receiverState.active.feature?.switchManual && /* @__PURE__ */ jsx(
|
|
2029
|
-
Button,
|
|
2030
|
-
{
|
|
2031
|
-
size: "small",
|
|
2032
|
-
title: chatMessage?.speakHuman ? "\u5F53\u524D\u72B6\u6001\u4E3A\u4EBA\u5DE5\u6A21\u5F0F\u3002\u60A8\u53D1\u9001\u7684\u95EE\u9898\u5C06\u76F4\u63A5\u53D1\u9001\u7ED9\u4E13\u5BB6\uFF0C\u667A\u80FD\u52A9\u624B\u5C06\u4E0D\u518D\u56DE\u590D" : "\u5F53\u524D\u72B6\u6001\u4E3A\u667A\u80FD\u52A9\u624B\u6A21\u5F0F\u3002\u60A8\u53D1\u9001\u7684\u95EE\u9898\u5C06\u53D1\u9001\u7ED9\u667A\u80FD\u52A9\u624B\uFF0C\u667A\u80FD\u52A9\u624B\u5C06\u56DE\u590D\u60A8",
|
|
2033
|
-
shape: "round",
|
|
2034
|
-
icon: /* @__PURE__ */ jsx(UserSwitchOutlined, {}),
|
|
2035
|
-
color: chatMessage?.speakHuman ? "primary" : "default",
|
|
2036
|
-
variant: "filled",
|
|
2037
|
-
onClick: () => {
|
|
2038
|
-
chatStore.setSpeakHuman?.(!chatMessage?.speakHuman);
|
|
2039
|
-
},
|
|
2040
|
-
children: "\u5411\u4E13\u5BB6\u54A8\u8BE2"
|
|
2041
|
-
}
|
|
2042
|
-
),
|
|
2505
|
+
/* @__PURE__ */ jsx(FeaturesRenderer_default, {}),
|
|
2043
2506
|
/* @__PURE__ */ jsx(RenderWrapper, { control: extraBtn })
|
|
2044
2507
|
] }),
|
|
2045
2508
|
extraHeader: /* @__PURE__ */ jsx(
|
|
@@ -2090,7 +2553,7 @@ var ConversationListHeader_default = () => {
|
|
|
2090
2553
|
type: "primary",
|
|
2091
2554
|
shape: "round",
|
|
2092
2555
|
onClick: () => chatStore.createConversation(),
|
|
2093
|
-
className:
|
|
2556
|
+
className: classNames11("m-t-16"),
|
|
2094
2557
|
icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
|
|
2095
2558
|
children: "\u65B0\u5EFA\u4F1A\u8BDD"
|
|
2096
2559
|
}
|
|
@@ -2098,14 +2561,14 @@ var ConversationListHeader_default = () => {
|
|
|
2098
2561
|
] });
|
|
2099
2562
|
};
|
|
2100
2563
|
var ConversationListPanel_default = ({ header }) => {
|
|
2101
|
-
return /* @__PURE__ */ jsxs(Flex, { vertical: true, className:
|
|
2564
|
+
return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames11("height-full", "zero-chat-conversations", styles_module_default3.nsConversationListPanel), children: [
|
|
2102
2565
|
/* @__PURE__ */ jsx(RenderWrapper, { control: header, DefaultComponent: ConversationListHeader_default }),
|
|
2103
2566
|
/* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(ConversationList_default, {}) })
|
|
2104
2567
|
] });
|
|
2105
2568
|
};
|
|
2106
2569
|
|
|
2107
2570
|
// src/ui/layouts/styles.module.less
|
|
2108
|
-
var
|
|
2571
|
+
var styles_module_default5 = {
|
|
2109
2572
|
nsPreviewHeader: "styles_module_nsPreviewHeader",
|
|
2110
2573
|
nsPreviewHeaderTitle: "styles_module_nsPreviewHeaderTitle",
|
|
2111
2574
|
nsChatSenderHeader: "styles_module_nsChatSenderHeader",
|
|
@@ -2152,6 +2615,7 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
|
|
|
2152
2615
|
createConversation: chatStore.createConversation,
|
|
2153
2616
|
setReferences: chatStore.setReferences,
|
|
2154
2617
|
setMessage: chatStore.setContent,
|
|
2618
|
+
setMessageParams: chatStore.setContentParams,
|
|
2155
2619
|
setFiles: chatStore.setFileList,
|
|
2156
2620
|
setServices: chatStore.setServices,
|
|
2157
2621
|
setParams: chatStore.setParams,
|
|
@@ -2190,7 +2654,7 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
|
|
|
2190
2654
|
useEffect(() => {
|
|
2191
2655
|
configState.hooks?.onBeforeInit?.();
|
|
2192
2656
|
}, []);
|
|
2193
|
-
return /* @__PURE__ */ jsx(XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsx(Spin, { spinning: receiverState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className:
|
|
2657
|
+
return /* @__PURE__ */ jsx(XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsx(Spin, { spinning: receiverState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames11(styles_module_default5.nsChatLayout, "zero-chat-layout", "height-full"), children: [
|
|
2194
2658
|
/* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
|
|
2195
2659
|
/* @__PURE__ */ jsxs(Flex, { className: "full-scroll", children: [
|
|
2196
2660
|
/* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.leftPanel }),
|
|
@@ -2198,8 +2662,8 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
|
|
|
2198
2662
|
/* @__PURE__ */ jsxs(Splitter, { className: "flex-1", onResize: setSplitterSizes, children: [
|
|
2199
2663
|
/* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, min: 600, size: sizes[0], children: hasPreView && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2200
2664
|
configState.preview.file.fileUrl && /* @__PURE__ */ jsxs(Flex, { vertical: true, className: "height-full", children: [
|
|
2201
|
-
/* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", gap: 16, className:
|
|
2202
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
2665
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", gap: 16, className: styles_module_default5.nsPreviewHeader, children: [
|
|
2666
|
+
/* @__PURE__ */ jsx("div", { className: classNames11(styles_module_default5.nsPreviewHeaderTitle, "text-ellipsis"), title: configState.preview.file.fileName, children: configState.preview.file.fileName }),
|
|
2203
2667
|
/* @__PURE__ */ jsxs(Flex, { gap: 8, justify: "center", align: "center", children: [
|
|
2204
2668
|
/* @__PURE__ */ jsx(
|
|
2205
2669
|
Button,
|
|
@@ -2243,15 +2707,15 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
|
|
|
2243
2707
|
}
|
|
2244
2708
|
)
|
|
2245
2709
|
] }) }),
|
|
2246
|
-
/* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className:
|
|
2710
|
+
/* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames11("height-full"), children: [
|
|
2247
2711
|
/* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
|
|
2248
|
-
/* @__PURE__ */ jsx(Flex, { vertical: true, className:
|
|
2712
|
+
/* @__PURE__ */ jsx(Flex, { vertical: true, className: classNames11("full-scroll"), children: /* @__PURE__ */ jsxs(
|
|
2249
2713
|
Flex,
|
|
2250
2714
|
{
|
|
2251
2715
|
justify: "center",
|
|
2252
2716
|
vertical: true,
|
|
2253
2717
|
gap: 24,
|
|
2254
|
-
className:
|
|
2718
|
+
className: classNames11("height-full", styles_module_default5.nsChatBody, "zero-chat-body", styles_module_default5.nsBodyWidth),
|
|
2255
2719
|
children: [
|
|
2256
2720
|
shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
|
|
2257
2721
|
/* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, children: [
|
|
@@ -2259,7 +2723,7 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
|
|
|
2259
2723
|
RenderWrapper,
|
|
2260
2724
|
{
|
|
2261
2725
|
control: configState.layout.senderHeader,
|
|
2262
|
-
DefaultComponent: /* @__PURE__ */ jsxs("div", { className:
|
|
2726
|
+
DefaultComponent: /* @__PURE__ */ jsxs("div", { className: styles_module_default5.nsChatSenderHeader, children: [
|
|
2263
2727
|
"\u6211\u662F ",
|
|
2264
2728
|
receiverState.active.name
|
|
2265
2729
|
] })
|
|
@@ -2270,7 +2734,26 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
|
|
|
2270
2734
|
RenderWrapper,
|
|
2271
2735
|
{
|
|
2272
2736
|
control: configState.layout.disclaimerNotice,
|
|
2273
|
-
DefaultComponent: /* @__PURE__ */ jsx("div", { className:
|
|
2737
|
+
DefaultComponent: /* @__PURE__ */ jsx("div", { className: styles_module_default5.nsDisclaimerNotice, children: "\u5185\u5BB9\u7531AI\u751F\u6210\uFF0C\u4EC5\u4F9B\u53C2\u8003\uFF0C\u8BF7\u4ED4\u7EC6\u7504\u522B" })
|
|
2738
|
+
}
|
|
2739
|
+
),
|
|
2740
|
+
/* @__PURE__ */ jsx(
|
|
2741
|
+
RenderWrapper,
|
|
2742
|
+
{
|
|
2743
|
+
control: configState.layout.recommendQuestions,
|
|
2744
|
+
DefaultComponent: receiverState?.recommendQuestions?.length > 0 && /* @__PURE__ */ jsx(
|
|
2745
|
+
Prompts,
|
|
2746
|
+
{
|
|
2747
|
+
vertical: true,
|
|
2748
|
+
title: "\u63A8\u8350\u95EE\u9898:",
|
|
2749
|
+
onItemClick: ({ data }) => chatStore.sendMessage(data.key),
|
|
2750
|
+
items: receiverState?.recommendQuestions.map((question) => ({
|
|
2751
|
+
key: question,
|
|
2752
|
+
icon: /* @__PURE__ */ jsx(FileSearchOutlined, {}),
|
|
2753
|
+
description: question
|
|
2754
|
+
}))
|
|
2755
|
+
}
|
|
2756
|
+
)
|
|
2274
2757
|
}
|
|
2275
2758
|
)
|
|
2276
2759
|
] }),
|