@zero-library/chat-agent 2.1.10 → 2.1.12

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, isFunction, 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 classNames8 from 'classnames';
10
- import { useSnapshot, proxy } from 'valtio';
10
+ import classNames9 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("/lolr/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 = {
@@ -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,
@@ -923,6 +967,13 @@ var customComponents = {
923
967
  fileEdit: () => Promise.resolve().then(() => (init_FileEdit(), FileEdit_exports)),
924
968
  quoteList: () => Promise.resolve().then(() => (init_QuoteList(), QuoteList_exports))
925
969
  };
970
+
971
+ // src/components/styles.module.less
972
+ var styles_module_default2 = {
973
+ chatAttachments: "styles_module_chatAttachments",
974
+ chatSender: "styles_module_chatSender",
975
+ chatQuoteMsg: "styles_module_chatQuoteMsg"
976
+ };
926
977
  var MessageRender_default = ({ message: message3, placement }) => {
927
978
  return /* @__PURE__ */ jsxs(Flex, { vertical: true, children: [
928
979
  message3.msgContent && /* @__PURE__ */ jsx(Bubble, { placement, content: /* @__PURE__ */ jsx(RenderMarkdown, { content: message3.msgContent, customComponents }) }),
@@ -945,7 +996,34 @@ var MessageRender_default = ({ message: message3, placement }) => {
945
996
  )
946
997
  },
947
998
  file.content
948
- ))
999
+ )),
1000
+ message3.quoteMsg?.id && /* @__PURE__ */ jsx(
1001
+ Bubble,
1002
+ {
1003
+ className: classNames9(styles_module_default2.chatQuoteMsg),
1004
+ placement,
1005
+ content: /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, children: [
1006
+ message3.quoteMsg.msgContent && /* @__PURE__ */ jsxs(Flex, { children: [
1007
+ /* @__PURE__ */ jsx("span", { children: "\u3010\u5F15\u7528\u6D88\u606F\u3011\uFF1A" }),
1008
+ /* @__PURE__ */ jsx(Flex, { flex: 1, className: "text-ellipsis", children: message3.quoteMsg.msgContent })
1009
+ ] }),
1010
+ message3.quoteMsg?.msgFiles && message3.quoteMsg.msgFiles.length > 0 && /* @__PURE__ */ jsxs(Flex, { children: [
1011
+ /* @__PURE__ */ jsx("span", { children: "\u3010\u5F15\u7528\u6587\u4EF6\u3011\uFF1A" }),
1012
+ /* @__PURE__ */ jsx(Flex, { gap: 8, wrap: true, flex: 1, children: message3.quoteMsg.msgFiles.map((file) => /* @__PURE__ */ jsx(
1013
+ Attachments.FileCard,
1014
+ {
1015
+ item: {
1016
+ uid: file.content,
1017
+ name: file.name,
1018
+ url: file.content
1019
+ }
1020
+ },
1021
+ file.content
1022
+ )) })
1023
+ ] })
1024
+ ] })
1025
+ }
1026
+ )
949
1027
  ] });
950
1028
  };
951
1029
 
@@ -961,7 +1039,7 @@ init_utils();
961
1039
  init_Context();
962
1040
 
963
1041
  // src/ui/common/styles.module.less
964
- var styles_module_default2 = {
1042
+ var styles_module_default3 = {
965
1043
  loadingMessage: "styles_module_loadingMessage",
966
1044
  nsConversationListPanel: "styles_module_nsConversationListPanel",
967
1045
  nsConversations: "styles_module_nsConversations",
@@ -1023,7 +1101,7 @@ var MessageAIRender_default = ({ message: message3, placement }) => {
1023
1101
  Bubble,
1024
1102
  {
1025
1103
  placement,
1026
- className: classNames8({ [styles_module_default2.loadingMessage]: message3.type && message3.type !== "TEXT_MESSAGE_END" }),
1104
+ className: classNames9({ [styles_module_default3.loadingMessage]: message3.type && message3.type !== "TEXT_MESSAGE_END" }),
1027
1105
  content: /* @__PURE__ */ jsxs(Fragment, { children: [
1028
1106
  thinkContents.length > 0 && /* @__PURE__ */ jsx(
1029
1107
  Collapse,
@@ -1092,11 +1170,11 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1092
1170
  () => [
1093
1171
  {
1094
1172
  key: "placeholder",
1095
- content: /* @__PURE__ */ jsxs(Space, { direction: "vertical", size: 16, className: styles_module_default2.chatWelcomeWrap, children: [
1173
+ content: /* @__PURE__ */ jsxs(Space, { direction: "vertical", size: 16, className: styles_module_default3.chatWelcomeWrap, children: [
1096
1174
  /* @__PURE__ */ jsx(
1097
1175
  Welcome,
1098
1176
  {
1099
- className: classNames8(styles_module_default2.chatWelcome, "p-t-32"),
1177
+ className: classNames9(styles_module_default3.chatWelcome, "p-t-32"),
1100
1178
  variant: "borderless",
1101
1179
  icon: /* @__PURE__ */ jsx(Avatar, { shape: "square", size: 58, src: receiverState.active.logo }),
1102
1180
  title: `\u4F60\u597D\uFF0C\u6211\u662F${receiverState.active.name || ""}`,
@@ -1114,7 +1192,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1114
1192
  label: "\u{1F914} \u63A8\u8350\u95EE\u9898:",
1115
1193
  children: receiverState.active.config.recommendQuestions.map(({ question }) => ({
1116
1194
  key: question,
1117
- description: /* @__PURE__ */ jsx("span", { onClick: () => chatStore.sendMessage(question), className: classNames8(styles_module_default2.chatWelcomePrompts, "text-ellipsis"), children: question })
1195
+ description: /* @__PURE__ */ jsx("span", { onClick: () => chatStore.sendMessage(question), className: classNames9(styles_module_default3.chatWelcomePrompts, "text-ellipsis"), children: question })
1118
1196
  }))
1119
1197
  }
1120
1198
  ]
@@ -1247,7 +1325,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1247
1325
  autoScroll: false,
1248
1326
  ref: listRef,
1249
1327
  items: bubbleListItems,
1250
- className: classNames8(styles_module_default2.nsBubbleList, "height-full", "scroll-fade-in", "zero-chat-bubbles"),
1328
+ className: classNames9(styles_module_default3.nsBubbleList, "height-full", "scroll-fade-in", "zero-chat-bubbles"),
1251
1329
  onScroll: handleScroll
1252
1330
  },
1253
1331
  conversationState.active.id
@@ -1278,18 +1356,18 @@ var CharacterList_default = () => {
1278
1356
  okText: "\u5207\u6362\u6027\u683C",
1279
1357
  onOk: () => chatStore.switchCharacter(activeCharacter),
1280
1358
  confirmLoading: characterState.switchLoading,
1281
- 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: [
1359
+ children: /* @__PURE__ */ jsx("div", { className: styles_module_default3.nsAvatarListContainer, children: /* @__PURE__ */ jsx(Row, { wrap: true, gutter: [16, 32], className: styles_module_default3.nsAvatarList, children: characterState.list.map((item) => /* @__PURE__ */ jsx(Col, { span: 6, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, align: "center", className: styles_module_default3.nsAvatarListItem, onClick: () => setActiveCharacter(item), children: [
1282
1360
  /* @__PURE__ */ jsx(
1283
1361
  Avatar,
1284
1362
  {
1285
- className: classNames8(styles_module_default2.nsAvatarListItemIcon, "cursor-pointer", {
1286
- [styles_module_default2.nsAvatarListItemIconActive]: activeCharacter.id === item.id
1363
+ className: classNames9(styles_module_default3.nsAvatarListItemIcon, "cursor-pointer", {
1364
+ [styles_module_default3.nsAvatarListItemIconActive]: activeCharacter.id === item.id
1287
1365
  }),
1288
1366
  size: 50,
1289
1367
  src: /* @__PURE__ */ jsx("img", { src: item.logo, alt: "\u5934\u50CF" })
1290
1368
  }
1291
1369
  ),
1292
- /* @__PURE__ */ jsx("div", { className: styles_module_default2.nsAvatarListItemName, children: item.characterName })
1370
+ /* @__PURE__ */ jsx("div", { className: styles_module_default3.nsAvatarListItemName, children: item.characterName })
1293
1371
  ] }) }, item.id)) }) })
1294
1372
  }
1295
1373
  );
@@ -1341,7 +1419,7 @@ var ConversationList_default = () => {
1341
1419
  children: /* @__PURE__ */ jsx(
1342
1420
  Conversations,
1343
1421
  {
1344
- className: styles_module_default2.nsConversations,
1422
+ className: styles_module_default3.nsConversations,
1345
1423
  items: conversationList,
1346
1424
  activeKey: conversationState.active.id,
1347
1425
  onActiveChange: async (id) => chatStore.switchConversation(id),
@@ -1377,7 +1455,7 @@ var ChatHeader_default = ({
1377
1455
  const chatStore = useChatStore();
1378
1456
  const receiverState = useSnapshot(chatStore.receiver);
1379
1457
  const configState = useSnapshot(chatStore.config);
1380
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className: classNames8(styles_module_default2.nsChatHeader, "zero-chat-header"), children: [
1458
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className: classNames9(styles_module_default3.nsChatHeader, "zero-chat-header"), children: [
1381
1459
  /* @__PURE__ */ jsxs(Flex, { gap: 4, align: "center", children: [
1382
1460
  /* @__PURE__ */ jsx(
1383
1461
  RenderWrapper,
@@ -1385,7 +1463,7 @@ var ChatHeader_default = ({
1385
1463
  control: title,
1386
1464
  DefaultComponent: /* @__PURE__ */ jsxs(Fragment, { children: [
1387
1465
  /* @__PURE__ */ jsx(Avatar, { size: 22, src: receiverState.active.logo, alt: receiverState.active.name }),
1388
- /* @__PURE__ */ jsx("div", { className: styles_module_default2.nsChatTitle, children: receiverState.active.name })
1466
+ /* @__PURE__ */ jsx("div", { className: styles_module_default3.nsChatTitle, children: receiverState.active.name })
1389
1467
  ] })
1390
1468
  }
1391
1469
  ),
@@ -1409,7 +1487,7 @@ var ChatHeader_default = ({
1409
1487
  {
1410
1488
  getPopupContainer: (e) => e,
1411
1489
  placement: "bottom",
1412
- classNames: { body: styles_module_default2.nsChatHeaderPopover },
1490
+ classNames: { body: styles_module_default3.nsChatHeaderPopover },
1413
1491
  content: /* @__PURE__ */ jsx(ConversationList_default, {}),
1414
1492
  trigger: ["click"],
1415
1493
  children: /* @__PURE__ */ jsx(Button, { title: "\u5386\u53F2\u4F1A\u8BDD", type: "text", size: "large", icon: /* @__PURE__ */ jsx(CommentOutlined, {}) })
@@ -1427,13 +1505,7 @@ var ChatHeader_default = ({
1427
1505
  ] })
1428
1506
  ] }) });
1429
1507
  };
1430
-
1431
- // src/components/styles.module.less
1432
- var styles_module_default3 = {
1433
- chatAttachments: "styles_module_chatAttachments",
1434
- chatSender: "styles_module_chatSender"
1435
- };
1436
- var Attachments_default = forwardRef(({ fileUploadConfig = [], fileList = [], onChange, extraParams }, ref) => {
1508
+ var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig = [], fileList = [], onChange, extraParams }, ref) => {
1437
1509
  const { message: message3 } = App.useApp();
1438
1510
  const fileListRef = useRef([]);
1439
1511
  const [attachedFiles, setAttachedFiles, getAttachedFiles] = useRefState([]);
@@ -1566,7 +1638,7 @@ var Attachments_default = forwardRef(({ fileUploadConfig = [], fileList = [], on
1566
1638
  return /* @__PURE__ */ jsx(
1567
1639
  Attachments,
1568
1640
  {
1569
- className: styles_module_default3.chatAttachments,
1641
+ className: styles_module_default2.chatAttachments,
1570
1642
  accept: acceptStr,
1571
1643
  multiple: true,
1572
1644
  customRequest: onCustomRequest,
@@ -1598,11 +1670,11 @@ var ChatSender_default = forwardRef(
1598
1670
  extraFooter,
1599
1671
  extraFooterBelow,
1600
1672
  sendBtnProps,
1601
- fileUpload: fileUpload2
1673
+ fileUpload
1602
1674
  }, ref) => {
1603
1675
  const senderRef = useRef(null);
1604
1676
  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) }) });
1677
+ 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
1678
  const attachmentsRef = useRef();
1607
1679
  const senderHeader = /* @__PURE__ */ jsxs(Fragment, { children: [
1608
1680
  /* @__PURE__ */ jsx(Sender.Header, { title: "\u9009\u62E9\u6587\u4EF6", open: headerOpen, onOpenChange: onHeaderOpenChange, children: /* @__PURE__ */ jsx(
@@ -1610,9 +1682,10 @@ var ChatSender_default = forwardRef(
1610
1682
  {
1611
1683
  ref: attachmentsRef,
1612
1684
  fileList,
1685
+ fileUpload: fileUpload.request,
1613
1686
  onChange: onFileListChange,
1614
- fileUploadConfig: fileUpload2.config,
1615
- extraParams: fileUpload2.params
1687
+ fileUploadConfig: fileUpload.config,
1688
+ extraParams: fileUpload.params
1616
1689
  }
1617
1690
  ) }),
1618
1691
  extraHeader
@@ -1634,7 +1707,7 @@ var ChatSender_default = forwardRef(
1634
1707
  return /* @__PURE__ */ jsx(Suggestion, { items: [], onSelect: (itemVal) => setInputValue(`[${itemVal}]:`), children: ({}) => /* @__PURE__ */ jsx(
1635
1708
  Sender,
1636
1709
  {
1637
- className: styles_module_default3.chatSender,
1710
+ className: styles_module_default2.chatSender,
1638
1711
  ref: senderRef,
1639
1712
  value: inputValue,
1640
1713
  header: senderHeader,
@@ -1683,16 +1756,16 @@ var SenderPromptsItems_default = () => {
1683
1756
  {
1684
1757
  itemLayout: "horizontal",
1685
1758
  split: false,
1686
- className: styles_module_default2.nsSenderList,
1759
+ className: styles_module_default3.nsSenderList,
1687
1760
  dataSource: question.items,
1688
- renderItem: (item) => /* @__PURE__ */ jsx(List.Item, { onClick: () => chatStore.sendMessage(item.question), className: styles_module_default2.nsSenderListItem, children: item.question }),
1689
- footer: /* @__PURE__ */ jsx(Flex, { justify: "end", className: styles_module_default2.nsSenderListFooter, children: "(\u60A8\u53EF\u70B9\u51FB\u4EE5\u4E0A\u95EE\u9898\u5F00\u542FAI\u4F53\u9A8C)" })
1761
+ renderItem: (item) => /* @__PURE__ */ jsx(List.Item, { onClick: () => chatStore.sendMessage(item.question), className: styles_module_default3.nsSenderListItem, children: item.question }),
1762
+ footer: /* @__PURE__ */ jsx(Flex, { justify: "end", className: styles_module_default3.nsSenderListFooter, children: "(\u60A8\u53EF\u70B9\u51FB\u4EE5\u4E0A\u95EE\u9898\u5F00\u542FAI\u4F53\u9A8C)" })
1690
1763
  }
1691
1764
  ),
1692
1765
  title: /* @__PURE__ */ jsx(
1693
1766
  "div",
1694
1767
  {
1695
- className: classNames8(styles_module_default2.nsSenderListTitle, "text-ellipsis"),
1768
+ className: classNames9(styles_module_default3.nsSenderListTitle, "text-ellipsis"),
1696
1769
  children: `${receiverState.active.name}\u5F00\u59CB\u5173\u6CE8${question.name}\u5185\u5BB9\uFF01`
1697
1770
  }
1698
1771
  ),
@@ -1708,6 +1781,7 @@ var SenderPromptsItems_default = () => {
1708
1781
  var ChatSender_default2 = forwardRef(
1709
1782
  ({ placeholder, extraBtn = false, referencesBtn = false, sendBtnProps, footerBelow = false, prompts = true }, ref) => {
1710
1783
  const chatStore = useChatStore();
1784
+ const configState = useSnapshot(chatStore.config);
1711
1785
  const receiverState = useSnapshot(chatStore.receiver);
1712
1786
  const conversationState = useSnapshot(chatStore.conversation);
1713
1787
  const chatMessage = useMemo(
@@ -1739,6 +1813,7 @@ var ChatSender_default2 = forwardRef(
1739
1813
  onCancel: chatStore.cancelReceive,
1740
1814
  onFocus: chatStore.config.hooks?.onSenderFocus,
1741
1815
  fileUpload: {
1816
+ request: configState.services.request?.fileUpload,
1742
1817
  config: receiverState.active.config?.fileUpload
1743
1818
  },
1744
1819
  sendBtnProps: isFunction(sendBtnProps) ? sendBtnProps() : {},
@@ -1781,8 +1856,8 @@ var ChatSender_default2 = forwardRef(
1781
1856
  open: !!chatMessage?.references?.content?.name,
1782
1857
  onOpenChange: () => chatStore.setReferences(),
1783
1858
  classNames: {
1784
- header: styles_module_default2.nsSenderReferenceHeaderTitle,
1785
- content: shouldRender(referencesBtn) ? "" : styles_module_default2.nsSenderReferenceHeaderContent
1859
+ header: styles_module_default3.nsSenderReferenceHeaderTitle,
1860
+ content: shouldRender(referencesBtn) ? "" : styles_module_default3.nsSenderReferenceHeaderContent
1786
1861
  },
1787
1862
  children: /* @__PURE__ */ jsx(
1788
1863
  RenderWrapper,
@@ -1810,7 +1885,7 @@ var ConversationListHeader_default = () => {
1810
1885
  return /* @__PURE__ */ jsxs("div", { className: "p-24", children: [
1811
1886
  /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 8, children: [
1812
1887
  /* @__PURE__ */ jsx(Avatar, { size: 36, src: receiverState.active.logo }),
1813
- /* @__PURE__ */ jsx("span", { className: styles_module_default2.nsChatUserName, children: receiverState.active.name })
1888
+ /* @__PURE__ */ jsx("span", { className: styles_module_default3.nsChatUserName, children: receiverState.active.name })
1814
1889
  ] }),
1815
1890
  /* @__PURE__ */ jsx(
1816
1891
  Button,
@@ -1819,7 +1894,7 @@ var ConversationListHeader_default = () => {
1819
1894
  type: "primary",
1820
1895
  shape: "round",
1821
1896
  onClick: () => chatStore.createConversation(),
1822
- className: classNames8("m-t-16"),
1897
+ className: classNames9("m-t-16"),
1823
1898
  icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
1824
1899
  children: "\u65B0\u5EFA\u4F1A\u8BDD"
1825
1900
  }
@@ -1827,7 +1902,7 @@ var ConversationListHeader_default = () => {
1827
1902
  ] });
1828
1903
  };
1829
1904
  var ConversationListPanel_default = ({ header }) => {
1830
- return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames8("height-full", "zero-chat-conversations", styles_module_default2.nsConversationListPanel), children: [
1905
+ return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames9("height-full", "zero-chat-conversations", styles_module_default3.nsConversationListPanel), children: [
1831
1906
  /* @__PURE__ */ jsx(RenderWrapper, { control: header, DefaultComponent: ConversationListHeader_default }),
1832
1907
  /* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(ConversationList_default, {}) })
1833
1908
  ] });
@@ -1843,9 +1918,12 @@ var styles_module_default4 = {
1843
1918
  nsChatBody: "styles_module_nsChatBody",
1844
1919
  nsBodyWidth: "styles_module_nsBodyWidth"
1845
1920
  };
1846
- var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, config }, ref) => {
1921
+ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, config, services }, ref) => {
1847
1922
  const chatStore = useMemo(() => createChatStore(), []);
1848
1923
  const senderRef = useRef();
1924
+ useDeepEffect(() => {
1925
+ chatStore.setServices(services);
1926
+ }, [services]);
1849
1927
  useDeepEffect(() => {
1850
1928
  if (config?.conversationId) {
1851
1929
  chatStore.switchConversation(config.conversationId);
@@ -1879,6 +1957,7 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
1879
1957
  setReferences: chatStore.setReferences,
1880
1958
  setMessage: chatStore.setContent,
1881
1959
  setFiles: chatStore.setFileList,
1960
+ setServices: chatStore.setServices,
1882
1961
  setParams: chatStore.setParams,
1883
1962
  senderFocus: (options) => {
1884
1963
  senderRef.current?.focus(options);
@@ -1901,7 +1980,19 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
1901
1980
  }
1902
1981
  }, [hasPreView]);
1903
1982
  useWebSocket({
1904
- url: getWebSocketUrl(`/api/lolr/conversation/ws/subscribe?NS-TOKEN=${getToken()}`, isLocalhost() ? "192.168.6.23" : ""),
1983
+ url: configState.services.websocketBaseUrls?.[0] && getWebSocketUrl(
1984
+ `${configState.services.websocketBaseUrls?.[0]}/lolr/conversation/ws/subscribe?NS-TOKEN=${getToken()}`,
1985
+ isLocalhost() ? "192.168.6.23" : ""
1986
+ ),
1987
+ onMessage: chatStore.acceptMessage,
1988
+ clientHeartbeat: false,
1989
+ reconnectInterval: 1e4
1990
+ });
1991
+ useWebSocket({
1992
+ url: configState.services.websocketBaseUrls?.[1] && getWebSocketUrl(
1993
+ `${configState.services.websocketBaseUrls?.[1]}/lolr/conversation/ws/subscribe?NS-TOKEN=${getToken()}`,
1994
+ isLocalhost() ? "192.168.6.23" : ""
1995
+ ),
1905
1996
  onMessage: chatStore.acceptMessage,
1906
1997
  clientHeartbeat: false,
1907
1998
  reconnectInterval: 1e4
@@ -1909,7 +2000,7 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
1909
2000
  useEffect(() => {
1910
2001
  configState.hooks?.onBeforeInit?.();
1911
2002
  }, []);
1912
- 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: [
2003
+ 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: classNames9(styles_module_default4.nsChatLayout, "zero-chat-layout", "height-full"), children: [
1913
2004
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
1914
2005
  /* @__PURE__ */ jsxs(Flex, { className: "full-scroll", children: [
1915
2006
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.leftPanel }),
@@ -1958,20 +2049,20 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
1958
2049
  }
1959
2050
  });
1960
2051
  },
1961
- onDownloadFile: (content, type) => fileCreate(content, configState.preview.file.fileName, type),
2052
+ onDownloadFile: (content, type) => configState.services.request.fileCreate(content, configState.preview.file.fileName, type),
1962
2053
  extraNav: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Tag, { bordered: false, color: "default", className: "cursor-pointer", onClick: () => chatStore.setPreview(), children: /* @__PURE__ */ jsx(CloseOutlined, {}) }) })
1963
2054
  }
1964
2055
  )
1965
2056
  ] }) }),
1966
- /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames8("height-full"), children: [
2057
+ /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames9("height-full"), children: [
1967
2058
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
1968
- /* @__PURE__ */ jsx(Flex, { vertical: true, className: classNames8("full-scroll"), children: /* @__PURE__ */ jsxs(
2059
+ /* @__PURE__ */ jsx(Flex, { vertical: true, className: classNames9("full-scroll"), children: /* @__PURE__ */ jsxs(
1969
2060
  Flex,
1970
2061
  {
1971
2062
  justify: "center",
1972
2063
  vertical: true,
1973
2064
  gap: 24,
1974
- className: classNames8("height-full", styles_module_default4.nsChatBody, "zero-chat-body", styles_module_default4.nsBodyWidth),
2065
+ className: classNames9("height-full", styles_module_default4.nsChatBody, "zero-chat-body", styles_module_default4.nsBodyWidth),
1975
2066
  children: [
1976
2067
  shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
1977
2068
  /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, children: [