@zero-library/chat-agent 2.1.9 → 2.1.11

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,13 @@
1
- import { useRefState, useDebounce, useSyncInput, RenderWrapper, shouldRender, useDeepEffect, useWebSocket, getWebSocketUrl, getToken, isLocalhost, downloadFile, FilePreview, MarkdownEditor, useCreateValtioContext, isNumber, getFileSuffixName, isObject, isNullOrUnDef, isBoolean, UserAvatar, request, deepCopy, getCurrentUser, deepMerge, RenderMarkdown, copyText, FileIcon, isExternal } from '@zero-library/common';
1
+ import { useRefState, useDebounce, useSyncInput, RenderWrapper, shouldRender, isFunction, useDeepEffect, useWebSocket, getWebSocketUrl, getToken, isLocalhost, downloadFile, FilePreview, MarkdownEditor, useCreateValtioContext, isNumber, getFileSuffixName, isObject, isNullOrUnDef, isBoolean, UserAvatar, deepCopy, getCurrentUser, deepMerge, createRequest, RenderMarkdown, copyText, FileIcon, isExternal } from '@zero-library/common';
2
2
  import { App, Badge, Button, Flex, Typography, Spin, Splitter, Tag, Popover, List, Avatar, Space, message, Empty, Collapse, Modal, Row, Col, Drawer } from 'antd';
3
3
  import dayjs from 'dayjs';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import { forwardRef, useRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
6
+ import { useSnapshot, proxy } from 'valtio';
6
7
  import { CloudUploadOutlined, PaperClipOutlined, EnterOutlined, UserSwitchOutlined, CloseOutlined, PlusOutlined, CommentOutlined, OpenAIOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, DeleteOutlined, RedoOutlined, PlayCircleOutlined, CaretRightOutlined } from '@ant-design/icons';
7
8
  import { Attachments, Sender, Suggestion, XProvider, Welcome, Prompts, Bubble, Conversations } from '@ant-design/x';
8
9
  export * from '@ant-design/x';
9
- import classNames7 from 'classnames';
10
- import { useSnapshot, proxy } from 'valtio';
10
+ import classNames8 from 'classnames';
11
11
  import InfiniteScroll from 'react-infinite-scroll-component';
12
12
 
13
13
  var __defProp = Object.defineProperty;
@@ -19,19 +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 docQuery, fileCreate;
23
- var init_file = __esm({
24
- "src/services/file.ts"() {
25
- docQuery = (paramsStr) => {
26
- return request.get(`/uc/doc?${paramsStr}`);
27
- };
28
- fileCreate = async (fileContent, fileName, targetFormat = "docx") => {
29
- const blob = await request.post(`/uc/doc/convert`, { fileContent, fileName, targetFormat }, { responseType: "blob" });
30
- const url = URL.createObjectURL(blob);
31
- downloadFile(url, fileName);
32
- };
33
- }
34
- });
35
22
  function transform(source, fieldMap) {
36
23
  const result = {};
37
24
  for (const [targetKey, mapping] of Object.entries(fieldMap)) {
@@ -147,14 +134,16 @@ var init_FileView = __esm({
147
134
  var DocDrawer_default;
148
135
  var init_DocDrawer = __esm({
149
136
  "src/ui/common/markdownAlert/components/DocDrawer.tsx"() {
150
- init_file();
137
+ init_Context();
151
138
  DocDrawer_default = ({ title, open, onClose, fileUrl }) => {
139
+ const chatStore = useChatStore();
140
+ const configState = useSnapshot(chatStore.config);
152
141
  const [content, setContent] = useState("");
153
142
  const [loading, setLoading] = useState(false);
154
143
  const getContent = async () => {
155
144
  try {
156
145
  setLoading(true);
157
- const res = await docQuery(fileUrl);
146
+ const res = await configState.services.request.docQuery(fileUrl);
158
147
  setContent(res.data?.content);
159
148
  } finally {
160
149
  setLoading(false);
@@ -301,52 +290,95 @@ var init_QuoteList = __esm({
301
290
  }
302
291
  });
303
292
 
304
- // src/ui/layouts/index.tsx
305
- init_file();
306
-
307
293
  // src/stores/index.ts
308
294
  init_utils();
309
- var conversationsQuery = (params) => {
310
- return request.get("/lolr/conversation", params);
311
- };
312
- var conversationCreate = (params) => {
313
- return request.post("/lolr/conversation", params);
314
- };
315
- var conversationDelete = (conversationId) => {
316
- return request.delete("/agent/conversation", { conversationId });
317
- };
318
- var conversationRecentQuery = (params) => {
319
- return request.get("/lolr/conversation/recent", params);
320
- };
321
- var conversationMessagesQuery = (params) => {
322
- return request.get("/lolr/conversation/message", params);
323
- };
324
- var feedbackUpdate = (params) => {
325
- return request.put("/lolr/conversation/message/feedback", params);
326
- };
327
- var messageSuggestedQuery = (msgId, maxCount = 3) => {
328
- return request.get("/lolr/conversation/suggest", { msgId, maxCount });
329
- };
330
- var conversationMemberQuery = (conversationId) => {
331
- return request.get("/lolr/conversation/member", { conversationId });
332
- };
333
- var conversationMessageSend = (params) => {
334
- return request.post("/lolr/conversation/send", params);
335
- };
336
- var conversationStop = (conversationId) => {
337
- return request.post("/lolr/conversation/stop", { conversationId });
338
- };
339
- var agentInfoQuery = (agentId) => {
340
- return request.get("/lolr/agent/detail", { agentId });
341
- };
342
- var agentCharacterQuery = (agentId) => {
343
- return request.get("/lolr/character", { agentId });
344
- };
345
- var agentCharacterSelect = (agentId, characterId) => {
346
- return request.post("/lolr/character/user", { agentId, characterId });
295
+
296
+ // src/services/index.ts
297
+ var createChatService = (request) => {
298
+ const conversationsQuery = (params) => {
299
+ return request.get("/lolr/conversation", params);
300
+ };
301
+ const conversationCreate = (params) => {
302
+ return request.post("/lolr/conversation", params);
303
+ };
304
+ const conversationDelete = (conversationId) => {
305
+ return request.delete("/lolr/conversation", { conversationId });
306
+ };
307
+ const conversationRecentUpdate = (params) => {
308
+ return request.put("/lolr/conversation/recent", params);
309
+ };
310
+ const conversationRecentQuery = (params) => {
311
+ return request.get("/lolr/conversation/recent", params);
312
+ };
313
+ const conversationMessagesQuery = (params) => {
314
+ return request.get("/lolr/conversation/message", params);
315
+ };
316
+ const conversationMessageRead = (conversationId) => {
317
+ return request.put("/lolr/conversation/message/read", { conversationId });
318
+ };
319
+ const feedbackUpdate = (params) => {
320
+ return request.put("/lolr/conversation/message/feedback", params);
321
+ };
322
+ const messageSuggestedQuery = (msgId, maxCount = 3) => {
323
+ return request.get("/lolr/conversation/suggest", { msgId, maxCount });
324
+ };
325
+ const conversationMemberQuery = (conversationId) => {
326
+ return request.get("/lolr/conversation/member", { conversationId });
327
+ };
328
+ const conversationStateUpdate = (conversationId, state) => {
329
+ return request.put("/lolr/conversation/state", { conversationId, state });
330
+ };
331
+ const conversationMessageSend = (params) => {
332
+ return request.post("/lolr/conversation/send", params);
333
+ };
334
+ const conversationStop = (conversationId) => {
335
+ return request.post("/lolr/conversation/stop", { conversationId });
336
+ };
337
+ const agentInfoQuery = (agentId) => {
338
+ return request.get("/lolr/agent/detail", { agentId });
339
+ };
340
+ const agentCharacterQuery = (agentId) => {
341
+ return request.get("/lolr/character", { agentId });
342
+ };
343
+ const agentCharacterSelect = (agentId, characterId) => {
344
+ return request.post("/lolr/character/user", { agentId, characterId });
345
+ };
346
+ const fileUpload = (formData) => {
347
+ return request.post("/lolr/storage/upload", formData, { timeout: 5 * 60 * 1e3 });
348
+ };
349
+ return {
350
+ conversationsQuery,
351
+ conversationCreate,
352
+ conversationDelete,
353
+ conversationRecentUpdate,
354
+ conversationRecentQuery,
355
+ conversationMessagesQuery,
356
+ conversationMessageRead,
357
+ feedbackUpdate,
358
+ messageSuggestedQuery,
359
+ conversationMemberQuery,
360
+ conversationStateUpdate,
361
+ conversationMessageSend,
362
+ conversationStop,
363
+ agentInfoQuery,
364
+ agentCharacterQuery,
365
+ agentCharacterSelect,
366
+ fileUpload
367
+ };
347
368
  };
348
- var fileUpload = (formData) => {
349
- return request.post("/lolr/storage/upload", formData, { timeout: 5 * 60 * 1e3 });
369
+ var createFileService = (request) => {
370
+ const docQuery = (paramsStr) => {
371
+ return request.get(`/uc/doc?${paramsStr}`);
372
+ };
373
+ const fileCreate = async (fileContent, fileName, targetFormat = "docx") => {
374
+ const blob = await request.post(`/uc/doc/convert`, { fileContent, fileName, targetFormat }, { responseType: "blob" });
375
+ const url = URL.createObjectURL(blob);
376
+ downloadFile(url, fileName);
377
+ };
378
+ return {
379
+ docQuery,
380
+ fileCreate
381
+ };
350
382
  };
351
383
 
352
384
  // src/stores/index.ts
@@ -390,6 +422,9 @@ var defaultExpertLayout = {
390
422
  };
391
423
  function createChatStore() {
392
424
  const config = proxy({
425
+ services: {
426
+ websocketBaseUrls: []
427
+ },
393
428
  hooks: {},
394
429
  layout: {},
395
430
  preview: {
@@ -402,6 +437,14 @@ function createChatStore() {
402
437
  userInfo: {},
403
438
  params: {}
404
439
  });
440
+ const setServices = ({ baseUrl = "/api" } = {}) => {
441
+ config.services.baseUrl = baseUrl;
442
+ if (!config.services.websocketBaseUrls?.includes(baseUrl)) {
443
+ config.services.websocketBaseUrls = [...config.services.websocketBaseUrls, baseUrl];
444
+ }
445
+ const request = createRequest(baseUrl);
446
+ config.services.request = { ...createChatService(request), ...createFileService(request) };
447
+ };
405
448
  const setPreview = (file = {}, isEdit = false) => {
406
449
  if (shouldRender(config.layout.preview)) {
407
450
  config.preview = {
@@ -427,7 +470,7 @@ function createChatStore() {
427
470
  config.hooks = hooks;
428
471
  };
429
472
  const setUserInfo = (userInfo) => {
430
- config.userInfo = transform(userInfo || getCurrentUser(), {
473
+ config.userInfo = transform(userInfo || getCurrentUser() || {}, {
431
474
  id: (userInfo2) => {
432
475
  return String(userInfo2["id"]);
433
476
  },
@@ -457,7 +500,7 @@ function createChatStore() {
457
500
  }
458
501
  try {
459
502
  receiver.loading = true;
460
- const { data } = await agentInfoQuery(agentId);
503
+ const { data } = await config.services.request.agentInfoQuery(agentId);
461
504
  receiver.active = transform(data, {
462
505
  name: "agentName",
463
506
  logo: "logo",
@@ -508,7 +551,7 @@ function createChatStore() {
508
551
  const getCharacters = async (agentId) => {
509
552
  try {
510
553
  character.loading = true;
511
- const { data } = await agentCharacterQuery(agentId);
554
+ const { data } = await config.services.request.agentCharacterQuery(agentId);
512
555
  if (receiver.active.id !== agentId) return;
513
556
  character.list = data;
514
557
  const active = data.find((item) => item.selected);
@@ -529,7 +572,7 @@ function createChatStore() {
529
572
  if (!c.id) return;
530
573
  try {
531
574
  character.switchLoading = true;
532
- await agentCharacterSelect(receiver.active.id, c.id);
575
+ await config.services.request.agentCharacterSelect(receiver.active.id, c.id);
533
576
  character.active = { ...c };
534
577
  closeCharacterList();
535
578
  } finally {
@@ -552,7 +595,7 @@ function createChatStore() {
552
595
  const getConversations = async (targetId, targetType) => {
553
596
  try {
554
597
  conversations.loading = true;
555
- const { data } = await conversationsQuery({
598
+ const { data } = await config.services.request.conversationsQuery({
556
599
  targetId,
557
600
  targetType,
558
601
  businessId: config.params.businessId,
@@ -579,7 +622,7 @@ function createChatStore() {
579
622
  const canProceed = await config.hooks?.onBeforeDelConversation?.(conversationId);
580
623
  if (canProceed === false) return;
581
624
  conversations.delLoading = true;
582
- await conversationDelete(conversationId);
625
+ await config.services.request.conversationDelete(conversationId);
583
626
  message.success("\u5220\u9664\u6210\u529F");
584
627
  conversations.list.items = conversations.list.items.filter((item) => item.key !== conversationId);
585
628
  delete conversation.messages[conversationId];
@@ -630,7 +673,7 @@ function createChatStore() {
630
673
  if (!messages?.length) return;
631
674
  let lastMessage = messages[messages.length - 1];
632
675
  if (!lastMessage || lastMessage.sender.type !== 3 || lastMessage.id !== messageId) return;
633
- const { data } = await messageSuggestedQuery(messageId);
676
+ const { data } = await config.services.request.messageSuggestedQuery(messageId);
634
677
  lastMessage = messages[messages.length - 1];
635
678
  if (lastMessage.id !== messageId) return;
636
679
  conversation.messages[conversationId].questionList = data;
@@ -638,7 +681,7 @@ function createChatStore() {
638
681
  const feedback = async (conversationId, messageId, msgFeedback, index) => {
639
682
  try {
640
683
  conversation.feedback.loading = true;
641
- await feedbackUpdate({ conversationId, id: messageId, msgFeedback });
684
+ await config.services.request.feedbackUpdate({ conversationId, id: messageId, msgFeedback });
642
685
  message.success("\u611F\u8C22\u60A8\u7684\u53CD\u9988");
643
686
  conversation.messages[conversationId].message[index].msgFeedback = msgFeedback;
644
687
  } finally {
@@ -659,7 +702,7 @@ function createChatStore() {
659
702
  };
660
703
  const resolveConversationId = async (receiverId, strategy = 2) => {
661
704
  if (strategy === 1) {
662
- const { data } = await conversationRecentQuery({
705
+ const { data } = await config.services.request.conversationRecentQuery({
663
706
  receiverId,
664
707
  receiverType: 3,
665
708
  businessId: config.params.businessId,
@@ -667,7 +710,7 @@ function createChatStore() {
667
710
  });
668
711
  return data;
669
712
  } else {
670
- const { data } = await conversationCreate({
713
+ const { data } = await config.services.request.conversationCreate({
671
714
  receiverId,
672
715
  receiverType: 3,
673
716
  businessId: config.params.businessId,
@@ -682,7 +725,7 @@ function createChatStore() {
682
725
  };
683
726
  const initConversation = async (conversationId) => {
684
727
  try {
685
- const { data } = await conversationMemberQuery(conversationId);
728
+ const { data } = await config.services.request.conversationMemberQuery(conversationId);
686
729
  conversation.active = { id: conversationId, member: {} };
687
730
  data.forEach((member) => {
688
731
  if (member.memberType === 3) {
@@ -742,7 +785,7 @@ function createChatStore() {
742
785
  setInitMessage(conversationId);
743
786
  }
744
787
  if (conversation.messages[conversationId].message.length === 0) {
745
- const { data } = await conversationMessagesQuery({
788
+ const { data } = await config.services.request.conversationMessagesQuery({
746
789
  pageNo: 1,
747
790
  pageSize: 1e3,
748
791
  conversationId
@@ -802,7 +845,7 @@ function createChatStore() {
802
845
  setHeaderOpen(false);
803
846
  }
804
847
  try {
805
- await conversationMessageSend(sendParams);
848
+ await config.services.request.conversationMessageSend(sendParams);
806
849
  config.hooks?.onAfterSend?.();
807
850
  } finally {
808
851
  conversation.messages[conversationId].loading = false;
@@ -810,7 +853,7 @@ function createChatStore() {
810
853
  };
811
854
  const cancelReceive = async () => {
812
855
  console.log("\u53D6\u6D88\u63A5\u6536");
813
- await conversationStop(conversation.active.id);
856
+ await config.services.request.conversationStop(conversation.active.id);
814
857
  };
815
858
  const updateConversationTitle = (conversationId, title) => {
816
859
  const idx = conversations.list.items.findIndex((item) => item.id === conversationId);
@@ -880,6 +923,7 @@ function createChatStore() {
880
923
  };
881
924
  return {
882
925
  config,
926
+ setServices,
883
927
  setPreview,
884
928
  setLayout,
885
929
  setHooks,
@@ -963,9 +1007,8 @@ init_Context();
963
1007
  // src/ui/common/styles.module.less
964
1008
  var styles_module_default2 = {
965
1009
  loadingMessage: "styles_module_loadingMessage",
966
- conversationListPanel: "styles_module_conversationListPanel",
1010
+ nsConversationListPanel: "styles_module_nsConversationListPanel",
967
1011
  nsConversations: "styles_module_nsConversations",
968
- nsBodyWidth: "styles_module_nsBodyWidth",
969
1012
  nsBubbleList: "styles_module_nsBubbleList",
970
1013
  nsChatHeader: "styles_module_nsChatHeader",
971
1014
  nsChatTitle: "styles_module_nsChatTitle",
@@ -973,19 +1016,19 @@ var styles_module_default2 = {
973
1016
  chatWelcomeWrap: "styles_module_chatWelcomeWrap",
974
1017
  chatWelcome: "styles_module_chatWelcome",
975
1018
  chatWelcomePrompts: "styles_module_chatWelcomePrompts",
976
- senderListTitle: "styles_module_senderListTitle",
977
- senderList: "styles_module_senderList",
978
- senderListItem: "styles_module_senderListItem",
979
- senderListFooter: "styles_module_senderListFooter",
1019
+ nsSenderListTitle: "styles_module_nsSenderListTitle",
1020
+ nsSenderList: "styles_module_nsSenderList",
1021
+ nsSenderListItem: "styles_module_nsSenderListItem",
1022
+ nsSenderListFooter: "styles_module_nsSenderListFooter",
980
1023
  nsChatUserName: "styles_module_nsChatUserName",
981
1024
  nsSenderReferenceHeaderTitle: "styles_module_nsSenderReferenceHeaderTitle",
982
1025
  nsSenderReferenceHeaderContent: "styles_module_nsSenderReferenceHeaderContent",
983
- avatarListContainer: "styles_module_avatarListContainer",
984
- avatarList: "styles_module_avatarList",
985
- avatarListItem: "styles_module_avatarListItem",
986
- avatarListItemIcon: "styles_module_avatarListItemIcon",
987
- avatarListItemIconActive: "styles_module_avatarListItemIconActive",
988
- avatarListItemName: "styles_module_avatarListItemName"
1026
+ nsAvatarListContainer: "styles_module_nsAvatarListContainer",
1027
+ nsAvatarList: "styles_module_nsAvatarList",
1028
+ nsAvatarListItem: "styles_module_nsAvatarListItem",
1029
+ nsAvatarListItemIcon: "styles_module_nsAvatarListItemIcon",
1030
+ nsAvatarListItemIconActive: "styles_module_nsAvatarListItemIconActive",
1031
+ nsAvatarListItemName: "styles_module_nsAvatarListItemName"
989
1032
  };
990
1033
  function extractThinkContent(content) {
991
1034
  let main = content;
@@ -1024,7 +1067,7 @@ var MessageAIRender_default = ({ message: message3, placement }) => {
1024
1067
  Bubble,
1025
1068
  {
1026
1069
  placement,
1027
- className: classNames7({ [styles_module_default2.loadingMessage]: message3.type && message3.type !== "TEXT_MESSAGE_END" }),
1070
+ className: classNames8({ [styles_module_default2.loadingMessage]: message3.type && message3.type !== "TEXT_MESSAGE_END" }),
1028
1071
  content: /* @__PURE__ */ jsxs(Fragment, { children: [
1029
1072
  thinkContents.length > 0 && /* @__PURE__ */ jsx(
1030
1073
  Collapse,
@@ -1097,7 +1140,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1097
1140
  /* @__PURE__ */ jsx(
1098
1141
  Welcome,
1099
1142
  {
1100
- className: classNames7(styles_module_default2.chatWelcome, "p-t-32"),
1143
+ className: classNames8(styles_module_default2.chatWelcome, "p-t-32"),
1101
1144
  variant: "borderless",
1102
1145
  icon: /* @__PURE__ */ jsx(Avatar, { shape: "square", size: 58, src: receiverState.active.logo }),
1103
1146
  title: `\u4F60\u597D\uFF0C\u6211\u662F${receiverState.active.name || ""}`,
@@ -1115,7 +1158,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1115
1158
  label: "\u{1F914} \u63A8\u8350\u95EE\u9898:",
1116
1159
  children: receiverState.active.config.recommendQuestions.map(({ question }) => ({
1117
1160
  key: question,
1118
- description: /* @__PURE__ */ jsx("span", { onClick: () => chatStore.sendMessage(question), className: classNames7(styles_module_default2.chatWelcomePrompts, "text-ellipsis"), children: question })
1161
+ description: /* @__PURE__ */ jsx("span", { onClick: () => chatStore.sendMessage(question), className: classNames8(styles_module_default2.chatWelcomePrompts, "text-ellipsis"), children: question })
1119
1162
  }))
1120
1163
  }
1121
1164
  ]
@@ -1248,7 +1291,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1248
1291
  autoScroll: false,
1249
1292
  ref: listRef,
1250
1293
  items: bubbleListItems,
1251
- className: classNames7(styles_module_default2.nsBubbleList, "height-full", "scroll-fade-in"),
1294
+ className: classNames8(styles_module_default2.nsBubbleList, "height-full", "scroll-fade-in", "zero-chat-bubbles"),
1252
1295
  onScroll: handleScroll
1253
1296
  },
1254
1297
  conversationState.active.id
@@ -1279,18 +1322,18 @@ var CharacterList_default = () => {
1279
1322
  okText: "\u5207\u6362\u6027\u683C",
1280
1323
  onOk: () => chatStore.switchCharacter(activeCharacter),
1281
1324
  confirmLoading: characterState.switchLoading,
1282
- children: /* @__PURE__ */ jsx("div", { className: styles_module_default2.avatarListContainer, children: /* @__PURE__ */ jsx(Row, { wrap: true, gutter: [16, 32], className: styles_module_default2.avatarList, children: characterState.list.map((item) => /* @__PURE__ */ jsx(Col, { span: 6, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, align: "center", className: styles_module_default2.avatarListItem, onClick: () => setActiveCharacter(item), children: [
1325
+ children: /* @__PURE__ */ jsx("div", { className: styles_module_default2.nsAvatarListContainer, children: /* @__PURE__ */ jsx(Row, { wrap: true, gutter: [16, 32], className: styles_module_default2.nsAvatarList, children: characterState.list.map((item) => /* @__PURE__ */ jsx(Col, { span: 6, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, align: "center", className: styles_module_default2.nsAvatarListItem, onClick: () => setActiveCharacter(item), children: [
1283
1326
  /* @__PURE__ */ jsx(
1284
1327
  Avatar,
1285
1328
  {
1286
- className: classNames7(styles_module_default2.avatarListItemIcon, "cursor-pointer", {
1287
- [styles_module_default2.avatarListItemIconActive]: activeCharacter.id === item.id
1329
+ className: classNames8(styles_module_default2.nsAvatarListItemIcon, "cursor-pointer", {
1330
+ [styles_module_default2.nsAvatarListItemIconActive]: activeCharacter.id === item.id
1288
1331
  }),
1289
1332
  size: 50,
1290
1333
  src: /* @__PURE__ */ jsx("img", { src: item.logo, alt: "\u5934\u50CF" })
1291
1334
  }
1292
1335
  ),
1293
- /* @__PURE__ */ jsx("div", { className: styles_module_default2.avatarListItemName, children: item.characterName })
1336
+ /* @__PURE__ */ jsx("div", { className: styles_module_default2.nsAvatarListItemName, children: item.characterName })
1294
1337
  ] }) }, item.id)) }) })
1295
1338
  }
1296
1339
  );
@@ -1378,7 +1421,7 @@ var ChatHeader_default = ({
1378
1421
  const chatStore = useChatStore();
1379
1422
  const receiverState = useSnapshot(chatStore.receiver);
1380
1423
  const configState = useSnapshot(chatStore.config);
1381
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className: styles_module_default2.nsChatHeader, children: [
1424
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className: classNames8(styles_module_default2.nsChatHeader, "zero-chat-header"), children: [
1382
1425
  /* @__PURE__ */ jsxs(Flex, { gap: 4, align: "center", children: [
1383
1426
  /* @__PURE__ */ jsx(
1384
1427
  RenderWrapper,
@@ -1431,9 +1474,10 @@ var ChatHeader_default = ({
1431
1474
 
1432
1475
  // src/components/styles.module.less
1433
1476
  var styles_module_default3 = {
1434
- nsAttachments: "styles_module_nsAttachments"
1477
+ chatAttachments: "styles_module_chatAttachments",
1478
+ chatSender: "styles_module_chatSender"
1435
1479
  };
1436
- var Attachments_default = forwardRef(({ fileUploadConfig = [], fileList = [], onChange, extraParams }, ref) => {
1480
+ var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig = [], fileList = [], onChange, extraParams }, ref) => {
1437
1481
  const { message: message3 } = App.useApp();
1438
1482
  const fileListRef = useRef([]);
1439
1483
  const [attachedFiles, setAttachedFiles, getAttachedFiles] = useRefState([]);
@@ -1566,7 +1610,7 @@ var Attachments_default = forwardRef(({ fileUploadConfig = [], fileList = [], on
1566
1610
  return /* @__PURE__ */ jsx(
1567
1611
  Attachments,
1568
1612
  {
1569
- className: styles_module_default3.nsAttachments,
1613
+ className: styles_module_default3.chatAttachments,
1570
1614
  accept: acceptStr,
1571
1615
  multiple: true,
1572
1616
  customRequest: onCustomRequest,
@@ -1598,11 +1642,11 @@ var ChatSender_default = forwardRef(
1598
1642
  extraFooter,
1599
1643
  extraFooterBelow,
1600
1644
  sendBtnProps,
1601
- fileUpload: fileUpload2
1645
+ fileUpload
1602
1646
  }, ref) => {
1603
1647
  const senderRef = useRef(null);
1604
1648
  const { inputValue, setInputValue } = useSyncInput(content || "", onContentChange);
1605
- const attachmentsNode = (fileUpload2?.config?.length ?? 0 > 0) && /* @__PURE__ */ jsx(Badge, { dot: !!fileList?.length && !headerOpen, children: /* @__PURE__ */ jsx(Button, { type: "text", icon: /* @__PURE__ */ jsx(PaperClipOutlined, {}), onClick: () => onHeaderOpenChange(!headerOpen) }) });
1649
+ const attachmentsNode = (fileUpload?.config?.length ?? 0 > 0) && /* @__PURE__ */ jsx(Badge, { dot: !!fileList?.length && !headerOpen, children: /* @__PURE__ */ jsx(Button, { type: "text", icon: /* @__PURE__ */ jsx(PaperClipOutlined, {}), onClick: () => onHeaderOpenChange(!headerOpen) }) });
1606
1650
  const attachmentsRef = useRef();
1607
1651
  const senderHeader = /* @__PURE__ */ jsxs(Fragment, { children: [
1608
1652
  /* @__PURE__ */ jsx(Sender.Header, { title: "\u9009\u62E9\u6587\u4EF6", open: headerOpen, onOpenChange: onHeaderOpenChange, children: /* @__PURE__ */ jsx(
@@ -1610,9 +1654,10 @@ var ChatSender_default = forwardRef(
1610
1654
  {
1611
1655
  ref: attachmentsRef,
1612
1656
  fileList,
1657
+ fileUpload: fileUpload.request,
1613
1658
  onChange: onFileListChange,
1614
- fileUploadConfig: fileUpload2.config,
1615
- extraParams: fileUpload2.params
1659
+ fileUploadConfig: fileUpload.config,
1660
+ extraParams: fileUpload.params
1616
1661
  }
1617
1662
  ) }),
1618
1663
  extraHeader
@@ -1634,6 +1679,7 @@ var ChatSender_default = forwardRef(
1634
1679
  return /* @__PURE__ */ jsx(Suggestion, { items: [], onSelect: (itemVal) => setInputValue(`[${itemVal}]:`), children: ({}) => /* @__PURE__ */ jsx(
1635
1680
  Sender,
1636
1681
  {
1682
+ className: styles_module_default3.chatSender,
1637
1683
  ref: senderRef,
1638
1684
  value: inputValue,
1639
1685
  header: senderHeader,
@@ -1682,16 +1728,16 @@ var SenderPromptsItems_default = () => {
1682
1728
  {
1683
1729
  itemLayout: "horizontal",
1684
1730
  split: false,
1685
- className: styles_module_default2.senderList,
1731
+ className: styles_module_default2.nsSenderList,
1686
1732
  dataSource: question.items,
1687
- renderItem: (item) => /* @__PURE__ */ jsx(List.Item, { onClick: () => chatStore.sendMessage(item.question), className: styles_module_default2.senderListItem, children: item.question }),
1688
- footer: /* @__PURE__ */ jsx(Flex, { justify: "end", className: styles_module_default2.senderListFooter, children: "(\u60A8\u53EF\u70B9\u51FB\u4EE5\u4E0A\u95EE\u9898\u5F00\u542FAI\u4F53\u9A8C)" })
1733
+ renderItem: (item) => /* @__PURE__ */ jsx(List.Item, { onClick: () => chatStore.sendMessage(item.question), className: styles_module_default2.nsSenderListItem, children: item.question }),
1734
+ footer: /* @__PURE__ */ jsx(Flex, { justify: "end", className: styles_module_default2.nsSenderListFooter, children: "(\u60A8\u53EF\u70B9\u51FB\u4EE5\u4E0A\u95EE\u9898\u5F00\u542FAI\u4F53\u9A8C)" })
1689
1735
  }
1690
1736
  ),
1691
1737
  title: /* @__PURE__ */ jsx(
1692
1738
  "div",
1693
1739
  {
1694
- className: classNames7(styles_module_default2.senderListTitle, "text-ellipsis"),
1740
+ className: classNames8(styles_module_default2.nsSenderListTitle, "text-ellipsis"),
1695
1741
  children: `${receiverState.active.name}\u5F00\u59CB\u5173\u6CE8${question.name}\u5185\u5BB9\uFF01`
1696
1742
  }
1697
1743
  ),
@@ -1705,8 +1751,9 @@ var SenderPromptsItems_default = () => {
1705
1751
  return component;
1706
1752
  };
1707
1753
  var ChatSender_default2 = forwardRef(
1708
- ({ placeholder, extraBtn = false, referencesBtn = false, sendBtnProps = {}, footerBelow = false, prompts = true }, ref) => {
1754
+ ({ placeholder, extraBtn = false, referencesBtn = false, sendBtnProps, footerBelow = false, prompts = true }, ref) => {
1709
1755
  const chatStore = useChatStore();
1756
+ const configState = useSnapshot(chatStore.config);
1710
1757
  const receiverState = useSnapshot(chatStore.receiver);
1711
1758
  const conversationState = useSnapshot(chatStore.conversation);
1712
1759
  const chatMessage = useMemo(
@@ -1720,7 +1767,7 @@ var ChatSender_default2 = forwardRef(
1720
1767
  chatStore.sendMessage();
1721
1768
  }, 10);
1722
1769
  };
1723
- return /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, children: [
1770
+ return /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, className: "zero-chat-sender", children: [
1724
1771
  /* @__PURE__ */ jsx(RenderWrapper, { control: prompts, DefaultComponent: SenderPromptsItems_default }),
1725
1772
  /* @__PURE__ */ jsx(
1726
1773
  ChatSender_default,
@@ -1738,9 +1785,10 @@ var ChatSender_default2 = forwardRef(
1738
1785
  onCancel: chatStore.cancelReceive,
1739
1786
  onFocus: chatStore.config.hooks?.onSenderFocus,
1740
1787
  fileUpload: {
1788
+ request: configState.services.request?.fileUpload,
1741
1789
  config: receiverState.active.config?.fileUpload
1742
1790
  },
1743
- sendBtnProps,
1791
+ sendBtnProps: isFunction(sendBtnProps) ? sendBtnProps() : {},
1744
1792
  extraFooterBelow: /* @__PURE__ */ jsx(RenderWrapper, { control: footerBelow }),
1745
1793
  extraFooter: /* @__PURE__ */ jsxs(Fragment, { children: [
1746
1794
  receiverState.active.feature?.deepThink && /* @__PURE__ */ jsx(
@@ -1818,7 +1866,7 @@ var ConversationListHeader_default = () => {
1818
1866
  type: "primary",
1819
1867
  shape: "round",
1820
1868
  onClick: () => chatStore.createConversation(),
1821
- className: classNames7("m-t-16"),
1869
+ className: classNames8("m-t-16"),
1822
1870
  icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
1823
1871
  children: "\u65B0\u5EFA\u4F1A\u8BDD"
1824
1872
  }
@@ -1826,7 +1874,7 @@ var ConversationListHeader_default = () => {
1826
1874
  ] });
1827
1875
  };
1828
1876
  var ConversationListPanel_default = ({ header }) => {
1829
- return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames7("height-full", styles_module_default2.conversationListPanel), children: [
1877
+ return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames8("height-full", "zero-chat-conversations", styles_module_default2.nsConversationListPanel), children: [
1830
1878
  /* @__PURE__ */ jsx(RenderWrapper, { control: header, DefaultComponent: ConversationListHeader_default }),
1831
1879
  /* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(ConversationList_default, {}) })
1832
1880
  ] });
@@ -1838,11 +1886,16 @@ var styles_module_default4 = {
1838
1886
  nsPreviewHeaderTitle: "styles_module_nsPreviewHeaderTitle",
1839
1887
  nsChatSenderHeader: "styles_module_nsChatSenderHeader",
1840
1888
  nsDisclaimerNotice: "styles_module_nsDisclaimerNotice",
1841
- nsChatLayout: "styles_module_nsChatLayout"
1889
+ nsChatLayout: "styles_module_nsChatLayout",
1890
+ nsChatBody: "styles_module_nsChatBody",
1891
+ nsBodyWidth: "styles_module_nsBodyWidth"
1842
1892
  };
1843
- var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, config }, ref) => {
1893
+ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, config, services }, ref) => {
1844
1894
  const chatStore = useMemo(() => createChatStore(), []);
1845
1895
  const senderRef = useRef();
1896
+ useDeepEffect(() => {
1897
+ chatStore.setServices(services);
1898
+ }, [services]);
1846
1899
  useDeepEffect(() => {
1847
1900
  if (config?.conversationId) {
1848
1901
  chatStore.switchConversation(config.conversationId);
@@ -1876,6 +1929,7 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
1876
1929
  setReferences: chatStore.setReferences,
1877
1930
  setMessage: chatStore.setContent,
1878
1931
  setFiles: chatStore.setFileList,
1932
+ setServices: chatStore.setServices,
1879
1933
  setParams: chatStore.setParams,
1880
1934
  senderFocus: (options) => {
1881
1935
  senderRef.current?.focus(options);
@@ -1898,7 +1952,19 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
1898
1952
  }
1899
1953
  }, [hasPreView]);
1900
1954
  useWebSocket({
1901
- url: getWebSocketUrl(`/api/lolr/conversation/ws/subscribe?NS-TOKEN=${getToken()}`, isLocalhost() ? "192.168.6.23" : ""),
1955
+ url: configState.services.websocketBaseUrls?.[0] && getWebSocketUrl(
1956
+ `${configState.services.websocketBaseUrls?.[0]}/lolr/conversation/ws/subscribe?NS-TOKEN=${getToken()}`,
1957
+ isLocalhost() ? "192.168.6.23" : ""
1958
+ ),
1959
+ onMessage: chatStore.acceptMessage,
1960
+ clientHeartbeat: false,
1961
+ reconnectInterval: 1e4
1962
+ });
1963
+ useWebSocket({
1964
+ url: configState.services.websocketBaseUrls?.[1] && getWebSocketUrl(
1965
+ `${configState.services.websocketBaseUrls?.[1]}/lolr/conversation/ws/subscribe?NS-TOKEN=${getToken()}`,
1966
+ isLocalhost() ? "192.168.6.23" : ""
1967
+ ),
1902
1968
  onMessage: chatStore.acceptMessage,
1903
1969
  clientHeartbeat: false,
1904
1970
  reconnectInterval: 1e4
@@ -1906,7 +1972,7 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
1906
1972
  useEffect(() => {
1907
1973
  configState.hooks?.onBeforeInit?.();
1908
1974
  }, []);
1909
- 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: classNames7(styles_module_default4.nsChatLayout, "height-full"), children: [
1975
+ 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: classNames8(styles_module_default4.nsChatLayout, "zero-chat-layout", "height-full"), children: [
1910
1976
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
1911
1977
  /* @__PURE__ */ jsxs(Flex, { className: "full-scroll", children: [
1912
1978
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.leftPanel }),
@@ -1955,37 +2021,46 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
1955
2021
  }
1956
2022
  });
1957
2023
  },
1958
- onDownloadFile: (content, type) => fileCreate(content, configState.preview.file.fileName, type),
2024
+ onDownloadFile: (content, type) => configState.services.request.fileCreate(content, configState.preview.file.fileName, type),
1959
2025
  extraNav: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Tag, { bordered: false, color: "default", className: "cursor-pointer", onClick: () => chatStore.setPreview(), children: /* @__PURE__ */ jsx(CloseOutlined, {}) }) })
1960
2026
  }
1961
2027
  )
1962
2028
  ] }) }),
1963
- /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames7("height-full"), children: [
2029
+ /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames8("height-full"), children: [
1964
2030
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
1965
- /* @__PURE__ */ jsx(Flex, { vertical: true, className: classNames7("full-scroll"), children: /* @__PURE__ */ jsxs(Flex, { justify: "center", vertical: true, gap: 24, className: classNames7("height-full p-t-8 p-b-8", styles_module_default2.nsBodyWidth), children: [
1966
- shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
1967
- /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, children: [
1968
- /* @__PURE__ */ jsx(
1969
- RenderWrapper,
1970
- {
1971
- control: configState.layout.senderHeader,
1972
- DefaultComponent: /* @__PURE__ */ jsxs("div", { className: styles_module_default4.nsChatSenderHeader, children: [
1973
- "\u6211\u662F ",
1974
- receiverState.active.name
1975
- ] })
1976
- }
1977
- ),
1978
- /* @__PURE__ */ jsx(RenderWrapper, { ref: senderRef, control: configState.layout.sender, DefaultComponent: ChatSender_default2 }),
1979
- /* @__PURE__ */ jsx(
1980
- RenderWrapper,
1981
- {
1982
- control: configState.layout.disclaimerNotice,
1983
- DefaultComponent: /* @__PURE__ */ jsx("div", { className: styles_module_default4.nsDisclaimerNotice, children: "\u5185\u5BB9\u7531AI\u751F\u6210\uFF0C\u4EC5\u4F9B\u53C2\u8003\uFF0C\u8BF7\u4ED4\u7EC6\u7504\u522B" })
1984
- }
1985
- )
1986
- ] }),
1987
- /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.senderFooter })
1988
- ] }) })
2031
+ /* @__PURE__ */ jsx(Flex, { vertical: true, className: classNames8("full-scroll"), children: /* @__PURE__ */ jsxs(
2032
+ Flex,
2033
+ {
2034
+ justify: "center",
2035
+ vertical: true,
2036
+ gap: 24,
2037
+ className: classNames8("height-full", styles_module_default4.nsChatBody, "zero-chat-body", styles_module_default4.nsBodyWidth),
2038
+ children: [
2039
+ shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
2040
+ /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, children: [
2041
+ /* @__PURE__ */ jsx(
2042
+ RenderWrapper,
2043
+ {
2044
+ control: configState.layout.senderHeader,
2045
+ DefaultComponent: /* @__PURE__ */ jsxs("div", { className: styles_module_default4.nsChatSenderHeader, children: [
2046
+ "\u6211\u662F ",
2047
+ receiverState.active.name
2048
+ ] })
2049
+ }
2050
+ ),
2051
+ /* @__PURE__ */ jsx(RenderWrapper, { ref: senderRef, control: configState.layout.sender, DefaultComponent: ChatSender_default2 }),
2052
+ /* @__PURE__ */ jsx(
2053
+ RenderWrapper,
2054
+ {
2055
+ control: configState.layout.disclaimerNotice,
2056
+ DefaultComponent: /* @__PURE__ */ jsx("div", { className: styles_module_default4.nsDisclaimerNotice, children: "\u5185\u5BB9\u7531AI\u751F\u6210\uFF0C\u4EC5\u4F9B\u53C2\u8003\uFF0C\u8BF7\u4ED4\u7EC6\u7504\u522B" })
2057
+ }
2058
+ )
2059
+ ] }),
2060
+ /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.senderFooter })
2061
+ ]
2062
+ }
2063
+ ) })
1989
2064
  ] }) })
1990
2065
  ] })
1991
2066
  ] })