@zero-library/chat-agent 1.0.0 → 2.0.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.esm.js CHANGED
@@ -1,13 +1,12 @@
1
- import { useRefState, useDebounce, isNumber, useSyncInput, shouldRender, RenderWrapper, downloadFile, FilePreview, isObject, isNullOrUnDef, isBoolean, UserAvatar, request as request$1, OK, getCurrentUser, deepMerge, copyText, RenderMarkdown, getToken, TOKEN_KEY, createValtioContext, FileIcon } from '@zero-library/common';
2
- import { message, Badge, Button, Flex, Spin, Splitter, Avatar, Space, Popover, List, Typography, Collapse, Tag, Card } from 'antd';
1
+ import { useRefState, useDebounce, isNumber, useSyncInput, shouldRender, RenderWrapper, downloadFile, FilePreview, MarkdownEditor, isObject, isNullOrUnDef, isBoolean, UserAvatar, request as request$1, getCurrentUser, deepMerge, copyText, RenderMarkdown, OK, getToken, TOKEN_KEY, createValtioContext, FileIcon } from '@zero-library/common';
2
+ import { message, Badge, Button, Flex, Spin, Splitter, Tag, Avatar, Space, Popover, List, Typography, Collapse } from 'antd';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
- import TextArea from 'antd/es/input/TextArea';
5
4
  import { forwardRef, useRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
6
- import { CloudUploadOutlined, PaperClipOutlined, PlusOutlined, DeleteOutlined, RedoOutlined, CommentOutlined, CloseOutlined, OpenAIOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, EnterOutlined, CloseCircleOutlined, CaretRightOutlined } from '@ant-design/icons';
7
- import { useSnapshot, proxy } from 'valtio';
8
- import dayjs from 'dayjs';
5
+ import { CloudUploadOutlined, PaperClipOutlined, CloseOutlined, PlusOutlined, DeleteOutlined, RedoOutlined, CommentOutlined, OpenAIOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, EnterOutlined, CloseCircleOutlined, PlayCircleOutlined, CaretRightOutlined } from '@ant-design/icons';
9
6
  import { Attachments, Sender, Suggestion, XProvider, Conversations, Welcome, Prompts, Bubble } from '@ant-design/x';
10
7
  import classNames2 from 'classnames';
8
+ import { useSnapshot, proxy } from 'valtio';
9
+ import dayjs from 'dayjs';
11
10
  import InfiniteScroll from 'react-infinite-scroll-component';
12
11
 
13
12
  var __defProp = Object.defineProperty;
@@ -33,7 +32,11 @@ var init_styles_module = __esm({
33
32
  styles_module_default2 = {
34
33
  appCard: "styles_module_appCard",
35
34
  fileView: "styles_module_fileView",
36
- quoteList: "styles_module_quoteList"
35
+ fileEdit: "styles_module_fileEdit",
36
+ fileEditHeader: "styles_module_fileEditHeader",
37
+ fileEditContent: "styles_module_fileEditContent",
38
+ quoteList: "styles_module_quoteList",
39
+ mdEdit: "styles_module_mdEdit"
37
40
  };
38
41
  }
39
42
  });
@@ -96,48 +99,36 @@ var init_IndexQuote = __esm({
96
99
  const onClick = () => {
97
100
  window.open(data.fileUrl, "_blank");
98
101
  };
99
- const Content = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 8, children: [
100
- /* @__PURE__ */ jsx(FileIcon, { suffix: data.suffix, fontSize: 16 }),
101
- /* @__PURE__ */ jsx("a", { onClick, children: data.fileName })
102
- ] }) });
103
- return /* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", wrapperClassName: "inline-block index-quote", children: /* @__PURE__ */ jsx(Popover, { content: Content, title: data.title, children: /* @__PURE__ */ jsx(Tag, { bordered: false, color: "processing", className: "cursor-pointer", children: data.index }) }) });
102
+ const Content = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Flex, { align: "center", gap: 8, children: /* @__PURE__ */ jsx("a", { onClick, children: data.fileName }) }) });
103
+ return /* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", wrapperClassName: "inline-block index-quote", children: /* @__PURE__ */ jsx(Popover, { content: Content, children: /* @__PURE__ */ jsx(Tag, { bordered: false, color: "processing", className: "cursor-pointer", children: data.index }) }) });
104
104
  };
105
105
  }
106
106
  });
107
107
 
108
- // src/ui/common/markdownAlert/EditableMarkdownCard.tsx
109
- var EditableMarkdownCard_exports = {};
110
- __export(EditableMarkdownCard_exports, {
111
- default: () => EditableMarkdownCard_default
108
+ // src/ui/common/markdownAlert/MdEdit.tsx
109
+ var MdEdit_exports = {};
110
+ __export(MdEdit_exports, {
111
+ default: () => MdEdit_default
112
112
  });
113
- var EditableMarkdownCard_default;
114
- var init_EditableMarkdownCard = __esm({
115
- "src/ui/common/markdownAlert/EditableMarkdownCard.tsx"() {
116
- EditableMarkdownCard_default = ({ data, loading }) => {
117
- const [editing, setEditing] = useState(false);
118
- const [value, setValue] = useState(data.content || "");
119
- const wrapperRef = useRef(null);
120
- useEffect(() => {
121
- const handleClickOutside = (e) => {
122
- if (editing && wrapperRef.current && !wrapperRef.current.contains(e.target)) {
123
- setEditing(false);
124
- }
125
- };
126
- document.addEventListener("mousedown", handleClickOutside);
127
- return () => document.removeEventListener("mousedown", handleClickOutside);
128
- }, [editing]);
113
+ var MdEdit_default;
114
+ var init_MdEdit = __esm({
115
+ "src/ui/common/markdownAlert/MdEdit.tsx"() {
116
+ init_Context();
117
+ init_styles_module();
118
+ MdEdit_default = ({ data, loading }) => {
119
+ const chatStore = useChatStore();
120
+ const [value, setValue] = useState("");
121
+ const onOk = () => {
122
+ console.log("value", value);
123
+ chatStore.sendMessage("\u5F00\u59CB\u5199\u4F5C", [], { outline: value });
124
+ };
129
125
  useEffect(() => {
130
- if (value !== data.content) ;
131
- }, [value]);
132
- return /* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsx(Card, { ref: wrapperRef, children: editing ? /* @__PURE__ */ jsx(
133
- TextArea,
134
- {
135
- autoSize: { minRows: 4, maxRows: 16 },
136
- value,
137
- onChange: (e) => setValue(e.target.value),
138
- placeholder: "\u8BF7\u8F93\u5165 Markdown \u5185\u5BB9..."
139
- }
140
- ) : /* @__PURE__ */ jsx("div", { onClick: () => setEditing(true), style: { cursor: "pointer", minHeight: 24 }, children: /* @__PURE__ */ jsx(RenderMarkdown, { content: value }) }) }) });
126
+ setValue(data.content);
127
+ }, [data.content]);
128
+ return /* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxs("div", { className: styles_module_default2.mdEdit, children: [
129
+ /* @__PURE__ */ jsx(MarkdownEditor, { disabled: loading, value, onChange: setValue, showToolbar: false }),
130
+ !loading && /* @__PURE__ */ jsx(Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsx(Button, { color: "primary", variant: "outlined", onClick: onOk, children: "\u786E\u8BA4\u63D0\u7EB2\u601D\u8DEF\uFF0C\u5F00\u59CB\u5199\u4F5C" }) })
131
+ ] }) });
141
132
  };
142
133
  }
143
134
  });
@@ -155,11 +146,14 @@ var init_FileEdit = __esm({
155
146
  FileEdit_default = ({ data, loading }) => {
156
147
  const chatStore = useChatStore();
157
148
  const onClick = () => {
158
- chatStore.setPreview(data, false);
149
+ chatStore.setPreview(data, true);
159
150
  };
160
- return /* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxs(Flex, { gap: 8, align: "center", className: styles_module_default2.fileView, onClick, children: [
161
- /* @__PURE__ */ jsx(FileIcon, { suffix: data.suffix }),
162
- /* @__PURE__ */ jsx("div", { className: "text-ellipsis", title: data.fileName, children: data.fileName })
151
+ return /* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: styles_module_default2.fileEdit, children: [
152
+ /* @__PURE__ */ jsx(Flex, { gap: 8, justify: "end", className: styles_module_default2.fileEditHeader, children: /* @__PURE__ */ jsx(Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsx(PlayCircleOutlined, {}), onClick, children: "\u9884\u89C8\u7F16\u8F91" }) }),
153
+ /* @__PURE__ */ jsxs(Flex, { gap: 8, align: "center", className: styles_module_default2.fileEditContent, children: [
154
+ /* @__PURE__ */ jsx(FileIcon, { suffix: "md" }),
155
+ /* @__PURE__ */ jsx("div", { className: "text-ellipsis", title: data.fileName, children: data.fileName })
156
+ ] })
163
157
  ] }) });
164
158
  };
165
159
  }
@@ -175,7 +169,6 @@ var init_QuoteList = __esm({
175
169
  "src/ui/common/markdownAlert/QuoteList.tsx"() {
176
170
  init_styles_module();
177
171
  QuoteList_default = ({ data, loading }) => {
178
- console.log("QuoteList data", data, loading);
179
172
  const onClick = (item) => {
180
173
  window.open(item.fileUrl, "_blank");
181
174
  };
@@ -190,7 +183,7 @@ var init_QuoteList = __esm({
190
183
  {
191
184
  key: "1",
192
185
  label: "\u53C2\u8003\u8D44\u6599",
193
- children: /* @__PURE__ */ jsx(Flex, { vertical: true, gap: 4, children: data.list.map((item) => /* @__PURE__ */ jsx("p", { onClick: () => onClick(item), className: "cursor-pointer", children: item.displayName }, item.fileUrl)) })
186
+ children: /* @__PURE__ */ jsx(Flex, { vertical: true, gap: 4, children: data.list.map((item) => /* @__PURE__ */ jsx("p", { onClick: () => onClick(item), className: "cursor-pointer", children: item.title }, item.fileUrl)) })
194
187
  }
195
188
  ]
196
189
  }
@@ -389,7 +382,7 @@ var updateFeedback = (params) => {
389
382
  var uploadFile = (formData) => {
390
383
  return request$1.post("/agent/file", formData);
391
384
  };
392
- var sendMessage = (params) => {
385
+ var sendChatMessage = (params) => {
393
386
  return fetchRequest_default.post(
394
387
  "/agent/chat",
395
388
  { ...params, stream: true },
@@ -430,12 +423,15 @@ function createChatStore() {
430
423
  preview: {
431
424
  file: {},
432
425
  isEdit: false
426
+ // 未使用
427
+ // isShow: 0, // 0 不显示 1 显示 2 用户关闭
428
+ // isIntact: false // true 完整 false 不完整
433
429
  },
434
430
  userInfo: {},
435
431
  params: {}
436
432
  });
437
433
  const setPreview = (file = {}, isEdit = false) => {
438
- if (config.layout.preview) {
434
+ if (shouldRender(config.layout.preview)) {
439
435
  config.preview = {
440
436
  file,
441
437
  isEdit
@@ -443,6 +439,8 @@ function createChatStore() {
443
439
  } else {
444
440
  if (file?.fileUrl) {
445
441
  window.open(file.fileUrl, "_blank");
442
+ } else {
443
+ console.log("\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9884\u89C8");
446
444
  }
447
445
  }
448
446
  };
@@ -544,8 +542,15 @@ function createChatStore() {
544
542
  };
545
543
  const agent = proxy({
546
544
  active: {},
547
- loading: false
545
+ loading: false,
546
+ params: {}
548
547
  });
548
+ const setAgentParams = (params = {}) => {
549
+ agent.params = {
550
+ thinkMode: 2,
551
+ ...params
552
+ };
553
+ };
549
554
  const switchAgent = async ({ appKey, agentKey, isVerify = false }, conversationId) => {
550
555
  const agentId = `${appKey}:${agentKey}`;
551
556
  if (agent.active.id === agentId) return;
@@ -557,6 +562,7 @@ function createChatStore() {
557
562
  }
558
563
  const { data } = await agentInfoQuery(agentId);
559
564
  agent.active = data;
565
+ setAgentParams();
560
566
  config.hooks?.onAfterSwitchAgent?.(agentId);
561
567
  switchConversation({ key: conversationId });
562
568
  } finally {
@@ -689,16 +695,16 @@ function createChatStore() {
689
695
  }
690
696
  conversation.messages[chunk.conversationId].loading = false;
691
697
  };
692
- const onSendMessage = async (message4, files = []) => {
698
+ const sendMessage = async (message4, files = [], params) => {
693
699
  const conversationId = conversation.active.key;
694
700
  if (conversation.messages[conversationId].loading) return;
695
701
  let newMsgContent = "", newImgList;
702
+ const references = conversation.messages[conversationId].references;
696
703
  if (message4) {
697
704
  newMsgContent = message4;
698
705
  newImgList = files;
699
706
  } else {
700
- const references = conversation.messages[conversationId].references;
701
- if (references?.type === 1 && references.content.markdown) {
707
+ if (references?.type === 1 && references?.content?.markdown) {
702
708
  newMsgContent = references.content.markdown + "\n";
703
709
  }
704
710
  newMsgContent = newMsgContent + conversation.messages[conversationId].content;
@@ -723,6 +729,13 @@ function createChatStore() {
723
729
  status: "loading"
724
730
  };
725
731
  conversation.messages[conversationId].message.items.push(userMsg, placeholder);
732
+ const extraParams = {
733
+ ...config.params
734
+ };
735
+ if (!extraParams.params) {
736
+ extraParams.params = {};
737
+ }
738
+ Object.assign(extraParams.params, agent.params, message4 ? {} : references?.params, params);
726
739
  if (!message4) {
727
740
  setContent("");
728
741
  setFileList([]);
@@ -731,12 +744,12 @@ function createChatStore() {
731
744
  }
732
745
  removeQuestionList(conversationId);
733
746
  try {
734
- sendMessage({
747
+ sendChatMessage({
735
748
  agentId: agent.active.id,
736
749
  conversationId: conversationId.endsWith(DEFAULT_NEW_CONV_ID) ? void 0 : conversationId,
737
750
  message: userMsg.content,
738
751
  files: userMsg.files,
739
- ...config.params,
752
+ ...extraParams,
740
753
  onMessageEvent: (event) => {
741
754
  updatePlaceholderMessage(conversationId, placeholderId, event);
742
755
  }
@@ -747,7 +760,7 @@ function createChatStore() {
747
760
  conversation.messages[conversationId].loading = false;
748
761
  }
749
762
  };
750
- const onCancelReceive = () => {
763
+ const cancelReceive = () => {
751
764
  conversation.messages[conversation.active.key].loading = false;
752
765
  };
753
766
  return {
@@ -770,17 +783,19 @@ function createChatStore() {
770
783
  conversations,
771
784
  setInitMessage,
772
785
  agent,
786
+ setAgentParams,
773
787
  switchAgent,
774
788
  getConversations,
775
789
  getMessages,
776
790
  switchConversation,
777
791
  delConversation,
778
792
  removePlaceholder,
779
- updatePlaceholderMessage,
780
- onSendMessage,
781
- onCancelReceive
793
+ sendMessage,
794
+ cancelReceive
782
795
  };
783
796
  }
797
+
798
+ // src/ui/layouts/index.tsx
784
799
  init_Context();
785
800
 
786
801
  // src/ui/common/AgentHeader.tsx
@@ -796,6 +811,7 @@ var styles_module_default = {
796
811
  nsBody: "styles_module_nsBody",
797
812
  nsBodyWidth: "styles_module_nsBodyWidth",
798
813
  nsBubbleList: "styles_module_nsBubbleList",
814
+ nsAgentHeader: "styles_module_nsAgentHeader",
799
815
  nsChatTitle: "styles_module_nsChatTitle",
800
816
  nsChatHeaderPopover: "styles_module_nsChatHeaderPopover",
801
817
  chatWelcomeWrap: "styles_module_chatWelcomeWrap",
@@ -806,7 +822,8 @@ var styles_module_default = {
806
822
  senderListItem: "styles_module_senderListItem",
807
823
  senderListFooter: "styles_module_senderListFooter",
808
824
  nsChatUserName: "styles_module_nsChatUserName",
809
- nsSenderHeaderContent: "styles_module_nsSenderHeaderContent"
825
+ nsSenderReferenceHeaderTitle: "styles_module_nsSenderReferenceHeaderTitle",
826
+ nsSenderReferenceHeaderContent: "styles_module_nsSenderReferenceHeaderContent"
810
827
  };
811
828
  var ConversationList_default = () => {
812
829
  const chatStore = useChatStore();
@@ -862,7 +879,7 @@ var AgentHeader_default = () => {
862
879
  const agentState = useSnapshot(chatStore.agent);
863
880
  const configState = useSnapshot(chatStore.config);
864
881
  const conversationsState = useSnapshot(chatStore.conversations);
865
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className: "p-l-16 p-r-16 p-t-8 p-b-8", children: [
882
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className: styles_module_default.nsAgentHeader, children: [
866
883
  /* @__PURE__ */ jsxs(Flex, { gap: 4, align: "center", children: [
867
884
  /* @__PURE__ */ jsx(
868
885
  RenderWrapper,
@@ -905,7 +922,7 @@ var AgentHeader_default = () => {
905
922
  RenderWrapper,
906
923
  {
907
924
  control: configState.layout.headerCloseBtn,
908
- DefaultComponent: /* @__PURE__ */ jsx(Button, { type: "text", size: "large", onClick: configState.hooks?.onClose, icon: /* @__PURE__ */ jsx(CloseOutlined, {}) })
925
+ DefaultComponent: /* @__PURE__ */ jsx(Button, { type: "text", size: "large", onClick: configState.hooks?.onHeaderClose, icon: /* @__PURE__ */ jsx(CloseOutlined, {}) })
909
926
  }
910
927
  )
911
928
  ] })
@@ -917,7 +934,7 @@ var customComponents = {
917
934
  appCard: () => Promise.resolve().then(() => (init_AppCard(), AppCard_exports)),
918
935
  fileView: () => Promise.resolve().then(() => (init_FileView(), FileView_exports)),
919
936
  indexQuote: () => Promise.resolve().then(() => (init_IndexQuote(), IndexQuote_exports)),
920
- editableMarkdownCard: () => Promise.resolve().then(() => (init_EditableMarkdownCard(), EditableMarkdownCard_exports)),
937
+ mdEdit: () => Promise.resolve().then(() => (init_MdEdit(), MdEdit_exports)),
921
938
  fileEdit: () => Promise.resolve().then(() => (init_FileEdit(), FileEdit_exports)),
922
939
  quoteList: () => Promise.resolve().then(() => (init_QuoteList(), QuoteList_exports))
923
940
  };
@@ -1343,6 +1360,7 @@ var ChatSender_default = forwardRef(
1343
1360
  onHeaderOpenChange,
1344
1361
  onSend,
1345
1362
  onCancel,
1363
+ onFocus,
1346
1364
  extraHeader,
1347
1365
  extraFooter,
1348
1366
  extraFooterBelow,
@@ -1389,6 +1407,7 @@ var ChatSender_default = forwardRef(
1389
1407
  header: senderHeader,
1390
1408
  onSubmit,
1391
1409
  onChange: setInputValue,
1410
+ onFocus,
1392
1411
  autoSize: { minRows: 2, maxRows: 6 },
1393
1412
  onCancel,
1394
1413
  footer: ({ components }) => {
@@ -1427,12 +1446,13 @@ var ChatSender_default2 = () => {
1427
1446
  if (chatMessage?.loading) return;
1428
1447
  chatStore.setContent(con);
1429
1448
  setTimeout(() => {
1430
- chatStore.onSendMessage();
1449
+ chatStore.sendMessage();
1431
1450
  }, 10);
1432
1451
  };
1433
1452
  return /* @__PURE__ */ jsx(
1434
1453
  ChatSender_default,
1435
1454
  {
1455
+ placeholder: configState.layout.sender?.props?.placeholder,
1436
1456
  content: chatMessage.content,
1437
1457
  fileList: chatMessage.files,
1438
1458
  headerOpen: chatMessage.headerOpen,
@@ -1440,26 +1460,37 @@ var ChatSender_default2 = () => {
1440
1460
  onContentChange: chatStore.setContent,
1441
1461
  onFileListChange: chatStore.setFileList,
1442
1462
  onHeaderOpenChange: chatStore.setHeaderOpen,
1443
- onSend: () => chatStore.onSendMessage(),
1463
+ onSend: () => chatStore.sendMessage(),
1464
+ onFocus: chatStore.config.hooks?.onSenderFocus,
1444
1465
  fileUpload: {
1445
1466
  ...agentState.active?.parameters?.fileUpload,
1446
1467
  extraParams: { agentId: agentState.active.id }
1447
1468
  },
1448
1469
  extraFooter: /* @__PURE__ */ jsxs(Fragment, { children: [
1449
- /* @__PURE__ */ jsx(Button, { size: "small", color: "primary", variant: "filled", children: "\u6DF1\u5EA6\u601D\u8003" }),
1470
+ /* @__PURE__ */ jsx(
1471
+ Button,
1472
+ {
1473
+ size: "small",
1474
+ color: agentState.params.thinkMode === 1 ? "primary" : "default",
1475
+ variant: "filled",
1476
+ onClick: () => chatStore.setAgentParams({ thinkMode: agentState.params.thinkMode === 1 ? 2 : 1 }),
1477
+ children: "\u6DF1\u5EA6\u601D\u8003"
1478
+ }
1479
+ ),
1450
1480
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.senderExtraBtn })
1451
1481
  ] }),
1452
1482
  extraHeader: /* @__PURE__ */ jsx(
1453
1483
  Sender.Header,
1454
1484
  {
1455
- title: /* @__PURE__ */ jsxs(Space, { children: [
1485
+ title: /* @__PURE__ */ jsxs(Flex, { gap: 4, children: [
1456
1486
  /* @__PURE__ */ jsx(EnterOutlined, {}),
1457
- /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", children: chatMessage?.references?.content?.name })
1487
+ /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", ellipsis: true, children: chatMessage?.references?.content?.name })
1458
1488
  ] }),
1459
1489
  open: !!chatMessage?.references?.content?.name,
1460
1490
  onOpenChange: () => chatStore.setReferences(),
1461
1491
  classNames: {
1462
- content: shouldRender(configState.layout.referencesBtn) ? "" : styles_module_default.nsSenderHeaderContent
1492
+ header: styles_module_default.nsSenderReferenceHeaderTitle,
1493
+ content: shouldRender(configState.layout.referencesBtn) ? "" : styles_module_default.nsSenderReferenceHeaderContent
1463
1494
  },
1464
1495
  children: /* @__PURE__ */ jsx(
1465
1496
  RenderWrapper,
@@ -1520,7 +1551,7 @@ var SenderPromptsItems_default = () => {
1520
1551
  split: false,
1521
1552
  className: styles_module_default.senderList,
1522
1553
  dataSource: question.hotQuestionList,
1523
- renderItem: (item) => /* @__PURE__ */ jsx(List.Item, { onClick: () => chatStore.onSendMessage(item.question), className: styles_module_default.senderListItem, children: item.question }),
1554
+ renderItem: (item) => /* @__PURE__ */ jsx(List.Item, { onClick: () => chatStore.sendMessage(item.question), className: styles_module_default.senderListItem, children: item.question }),
1524
1555
  footer: /* @__PURE__ */ jsx(Flex, { justify: "end", className: styles_module_default.senderListFooter, children: "(\u60A8\u53EF\u70B9\u51FB\u4EE5\u4E0A\u95EE\u9898\u5F00\u542FAI\u4F53\u9A8C)" })
1525
1556
  }
1526
1557
  ),
@@ -1569,7 +1600,7 @@ var layouts_default = forwardRef(({ theme, params, hooks, layout, defaultAgent }
1569
1600
  useImperativeHandle(
1570
1601
  ref,
1571
1602
  () => ({
1572
- sendMessage: chatStore.onSendMessage,
1603
+ sendMessage: chatStore.sendMessage,
1573
1604
  switchAgent: chatStore.switchAgent,
1574
1605
  switchConversation: chatStore.switchConversation,
1575
1606
  setReferences: chatStore.setReferences,
@@ -1583,6 +1614,9 @@ var layouts_default = forwardRef(({ theme, params, hooks, layout, defaultAgent }
1583
1614
  const setSplitterSizes = (sizes) => {
1584
1615
  console.log(sizes);
1585
1616
  };
1617
+ const hasPreView = useMemo(() => {
1618
+ return shouldRender(configState.layout.preview) && (!!configState.preview.file.fileUrl || !!configState.preview.file.content);
1619
+ }, [configState.layout.preview, configState.preview.file]);
1586
1620
  return /* @__PURE__ */ jsx(XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsx(Spin, { spinning: agentState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsx("div", { className: "overflow-hidden height-full", children: /* @__PURE__ */ jsxs(Splitter, { onResize: setSplitterSizes, children: [
1587
1621
  shouldRender(configState.layout.conversationList) && /* @__PURE__ */ jsx(Splitter.Panel, { size: 360, collapsible: false, resizable: false, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: "height-full", children: [
1588
1622
  /* @__PURE__ */ jsx(
@@ -1600,33 +1634,54 @@ var layouts_default = forwardRef(({ theme, params, hooks, layout, defaultAgent }
1600
1634
  }
1601
1635
  ) })
1602
1636
  ] }) }),
1603
- configState.preview.file.fileUrl && shouldRender(configState.layout.preview) && /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, resizable: false, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: "height-full", children: [
1604
- /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", gap: 16, className: styles_module_default3.nsPreviewHeader, children: [
1605
- /* @__PURE__ */ jsx("div", { className: styles_module_default3.nsPreviewHeaderTitle, children: configState.preview.file.fileName }),
1606
- /* @__PURE__ */ jsxs(Flex, { gap: 8, justify: "center", align: "center", children: [
1607
- /* @__PURE__ */ jsx(
1608
- Button,
1609
- {
1610
- color: "primary",
1611
- variant: "outlined",
1612
- onClick: () => downloadFile(configState.preview.file.fileUrl, configState.preview.file.fileName),
1613
- children: "\u4E0B\u8F7D"
1637
+ hasPreView && /* @__PURE__ */ jsxs(Splitter.Panel, { collapsible: false, resizable: false, children: [
1638
+ configState.preview.file.fileUrl && /* @__PURE__ */ jsxs(Flex, { vertical: true, className: "height-full", children: [
1639
+ /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", gap: 16, className: styles_module_default3.nsPreviewHeader, children: [
1640
+ /* @__PURE__ */ jsx("div", { className: styles_module_default3.nsPreviewHeaderTitle, children: configState.preview.file.fileName }),
1641
+ /* @__PURE__ */ jsxs(Flex, { gap: 8, justify: "center", align: "center", children: [
1642
+ /* @__PURE__ */ jsx(
1643
+ Button,
1644
+ {
1645
+ color: "primary",
1646
+ variant: "outlined",
1647
+ onClick: () => downloadFile(configState.preview.file.fileUrl, configState.preview.file.fileName),
1648
+ children: "\u4E0B\u8F7D"
1649
+ }
1650
+ ),
1651
+ /* @__PURE__ */ jsx(Button, { onClick: () => chatStore.setPreview(), children: "\u5173\u95ED" })
1652
+ ] })
1653
+ ] }),
1654
+ /* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(
1655
+ FilePreview,
1656
+ {
1657
+ ...configState.preview.file,
1658
+ pdfParams: {
1659
+ isHasThumbnails: false
1614
1660
  }
1615
- ),
1616
- /* @__PURE__ */ jsx(Button, { onClick: () => chatStore.setPreview(), children: "\u5173\u95ED" })
1617
- ] })
1661
+ }
1662
+ ) })
1618
1663
  ] }),
1619
- /* @__PURE__ */ jsx("div", { className: "full-scroll", children: configState.preview.file.fileUrl && /* @__PURE__ */ jsx(
1620
- FilePreview,
1664
+ configState.preview.file.content && /* @__PURE__ */ jsx(
1665
+ MarkdownEditor,
1621
1666
  {
1622
- ...configState.preview.file,
1623
- pdfParams: {
1624
- isHasThumbnails: false
1625
- }
1667
+ value: configState.preview.file.content,
1668
+ onQuote: (text) => {
1669
+ chatStore.setReferences({
1670
+ type: 2,
1671
+ content: {
1672
+ name: text,
1673
+ markdown: text
1674
+ },
1675
+ params: {
1676
+ outline: text
1677
+ }
1678
+ });
1679
+ },
1680
+ extraNav: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Tag, { bordered: false, color: "default", className: "cursor-pointer", onClick: () => chatStore.setPreview(), children: /* @__PURE__ */ jsx(CloseOutlined, {}) }) })
1626
1681
  }
1627
- ) })
1628
- ] }) }),
1629
- /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, resizable: false, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2("height-full"), children: [
1682
+ )
1683
+ ] }),
1684
+ /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, resizable: false, size: hasPreView ? 400 : void 0, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2("height-full"), children: [
1630
1685
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.header, DefaultComponent: AgentHeader_default }),
1631
1686
  /* @__PURE__ */ jsx(Flex, { vertical: true, className: classNames2("full-scroll", styles_module_default.nsBody), children: /* @__PURE__ */ jsxs(Flex, { justify: "center", vertical: true, gap: 24, className: classNames2("height-full", styles_module_default.nsBodyWidth), children: [
1632
1687
  shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(