@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.cjs.js CHANGED
@@ -5,16 +5,16 @@ var antd = require('antd');
5
5
  var dayjs = require('dayjs');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var react = require('react');
8
+ var valtio = require('valtio');
8
9
  var icons = require('@ant-design/icons');
9
10
  var x = require('@ant-design/x');
10
- var classNames7 = require('classnames');
11
- var valtio = require('valtio');
11
+ var classNames8 = require('classnames');
12
12
  var InfiniteScroll = require('react-infinite-scroll-component');
13
13
 
14
14
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
15
 
16
16
  var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
17
- var classNames7__default = /*#__PURE__*/_interopDefault(classNames7);
17
+ var classNames8__default = /*#__PURE__*/_interopDefault(classNames8);
18
18
  var InfiniteScroll__default = /*#__PURE__*/_interopDefault(InfiniteScroll);
19
19
 
20
20
  var __defProp = Object.defineProperty;
@@ -26,19 +26,6 @@ var __export = (target, all) => {
26
26
  for (var name in all)
27
27
  __defProp(target, name, { get: all[name], enumerable: true });
28
28
  };
29
- var docQuery, fileCreate;
30
- var init_file = __esm({
31
- "src/services/file.ts"() {
32
- docQuery = (paramsStr) => {
33
- return common.request.get(`/uc/doc?${paramsStr}`);
34
- };
35
- fileCreate = async (fileContent, fileName, targetFormat = "docx") => {
36
- const blob = await common.request.post(`/uc/doc/convert`, { fileContent, fileName, targetFormat }, { responseType: "blob" });
37
- const url = URL.createObjectURL(blob);
38
- common.downloadFile(url, fileName);
39
- };
40
- }
41
- });
42
29
  function transform(source, fieldMap) {
43
30
  const result = {};
44
31
  for (const [targetKey, mapping] of Object.entries(fieldMap)) {
@@ -154,14 +141,16 @@ var init_FileView = __esm({
154
141
  var DocDrawer_default;
155
142
  var init_DocDrawer = __esm({
156
143
  "src/ui/common/markdownAlert/components/DocDrawer.tsx"() {
157
- init_file();
144
+ init_Context();
158
145
  DocDrawer_default = ({ title, open, onClose, fileUrl }) => {
146
+ const chatStore = useChatStore();
147
+ const configState = valtio.useSnapshot(chatStore.config);
159
148
  const [content, setContent] = react.useState("");
160
149
  const [loading, setLoading] = react.useState(false);
161
150
  const getContent = async () => {
162
151
  try {
163
152
  setLoading(true);
164
- const res = await docQuery(fileUrl);
153
+ const res = await configState.services.request.docQuery(fileUrl);
165
154
  setContent(res.data?.content);
166
155
  } finally {
167
156
  setLoading(false);
@@ -308,52 +297,95 @@ var init_QuoteList = __esm({
308
297
  }
309
298
  });
310
299
 
311
- // src/ui/layouts/index.tsx
312
- init_file();
313
-
314
300
  // src/stores/index.ts
315
301
  init_utils();
316
- var conversationsQuery = (params) => {
317
- return common.request.get("/lolr/conversation", params);
318
- };
319
- var conversationCreate = (params) => {
320
- return common.request.post("/lolr/conversation", params);
321
- };
322
- var conversationDelete = (conversationId) => {
323
- return common.request.delete("/agent/conversation", { conversationId });
324
- };
325
- var conversationRecentQuery = (params) => {
326
- return common.request.get("/lolr/conversation/recent", params);
327
- };
328
- var conversationMessagesQuery = (params) => {
329
- return common.request.get("/lolr/conversation/message", params);
330
- };
331
- var feedbackUpdate = (params) => {
332
- return common.request.put("/lolr/conversation/message/feedback", params);
333
- };
334
- var messageSuggestedQuery = (msgId, maxCount = 3) => {
335
- return common.request.get("/lolr/conversation/suggest", { msgId, maxCount });
336
- };
337
- var conversationMemberQuery = (conversationId) => {
338
- return common.request.get("/lolr/conversation/member", { conversationId });
339
- };
340
- var conversationMessageSend = (params) => {
341
- return common.request.post("/lolr/conversation/send", params);
342
- };
343
- var conversationStop = (conversationId) => {
344
- return common.request.post("/lolr/conversation/stop", { conversationId });
345
- };
346
- var agentInfoQuery = (agentId) => {
347
- return common.request.get("/lolr/agent/detail", { agentId });
348
- };
349
- var agentCharacterQuery = (agentId) => {
350
- return common.request.get("/lolr/character", { agentId });
351
- };
352
- var agentCharacterSelect = (agentId, characterId) => {
353
- return common.request.post("/lolr/character/user", { agentId, characterId });
302
+
303
+ // src/services/index.ts
304
+ var createChatService = (request) => {
305
+ const conversationsQuery = (params) => {
306
+ return request.get("/lolr/conversation", params);
307
+ };
308
+ const conversationCreate = (params) => {
309
+ return request.post("/lolr/conversation", params);
310
+ };
311
+ const conversationDelete = (conversationId) => {
312
+ return request.delete("/lolr/conversation", { conversationId });
313
+ };
314
+ const conversationRecentUpdate = (params) => {
315
+ return request.put("/lolr/conversation/recent", params);
316
+ };
317
+ const conversationRecentQuery = (params) => {
318
+ return request.get("/lolr/conversation/recent", params);
319
+ };
320
+ const conversationMessagesQuery = (params) => {
321
+ return request.get("/lolr/conversation/message", params);
322
+ };
323
+ const conversationMessageRead = (conversationId) => {
324
+ return request.put("/lolr/conversation/message/read", { conversationId });
325
+ };
326
+ const feedbackUpdate = (params) => {
327
+ return request.put("/lolr/conversation/message/feedback", params);
328
+ };
329
+ const messageSuggestedQuery = (msgId, maxCount = 3) => {
330
+ return request.get("/lolr/conversation/suggest", { msgId, maxCount });
331
+ };
332
+ const conversationMemberQuery = (conversationId) => {
333
+ return request.get("/lolr/conversation/member", { conversationId });
334
+ };
335
+ const conversationStateUpdate = (conversationId, state) => {
336
+ return request.put("/lolr/conversation/state", { conversationId, state });
337
+ };
338
+ const conversationMessageSend = (params) => {
339
+ return request.post("/lolr/conversation/send", params);
340
+ };
341
+ const conversationStop = (conversationId) => {
342
+ return request.post("/lolr/conversation/stop", { conversationId });
343
+ };
344
+ const agentInfoQuery = (agentId) => {
345
+ return request.get("/lolr/agent/detail", { agentId });
346
+ };
347
+ const agentCharacterQuery = (agentId) => {
348
+ return request.get("/lolr/character", { agentId });
349
+ };
350
+ const agentCharacterSelect = (agentId, characterId) => {
351
+ return request.post("/lolr/character/user", { agentId, characterId });
352
+ };
353
+ const fileUpload = (formData) => {
354
+ return request.post("/lolr/storage/upload", formData, { timeout: 5 * 60 * 1e3 });
355
+ };
356
+ return {
357
+ conversationsQuery,
358
+ conversationCreate,
359
+ conversationDelete,
360
+ conversationRecentUpdate,
361
+ conversationRecentQuery,
362
+ conversationMessagesQuery,
363
+ conversationMessageRead,
364
+ feedbackUpdate,
365
+ messageSuggestedQuery,
366
+ conversationMemberQuery,
367
+ conversationStateUpdate,
368
+ conversationMessageSend,
369
+ conversationStop,
370
+ agentInfoQuery,
371
+ agentCharacterQuery,
372
+ agentCharacterSelect,
373
+ fileUpload
374
+ };
354
375
  };
355
- var fileUpload = (formData) => {
356
- return common.request.post("/lolr/storage/upload", formData, { timeout: 5 * 60 * 1e3 });
376
+ var createFileService = (request) => {
377
+ const docQuery = (paramsStr) => {
378
+ return request.get(`/uc/doc?${paramsStr}`);
379
+ };
380
+ const fileCreate = async (fileContent, fileName, targetFormat = "docx") => {
381
+ const blob = await request.post(`/uc/doc/convert`, { fileContent, fileName, targetFormat }, { responseType: "blob" });
382
+ const url = URL.createObjectURL(blob);
383
+ common.downloadFile(url, fileName);
384
+ };
385
+ return {
386
+ docQuery,
387
+ fileCreate
388
+ };
357
389
  };
358
390
 
359
391
  // src/stores/index.ts
@@ -397,6 +429,9 @@ var defaultExpertLayout = {
397
429
  };
398
430
  function createChatStore() {
399
431
  const config = valtio.proxy({
432
+ services: {
433
+ websocketBaseUrls: []
434
+ },
400
435
  hooks: {},
401
436
  layout: {},
402
437
  preview: {
@@ -409,6 +444,14 @@ function createChatStore() {
409
444
  userInfo: {},
410
445
  params: {}
411
446
  });
447
+ const setServices = ({ baseUrl = "/api" } = {}) => {
448
+ config.services.baseUrl = baseUrl;
449
+ if (!config.services.websocketBaseUrls?.includes(baseUrl)) {
450
+ config.services.websocketBaseUrls = [...config.services.websocketBaseUrls, baseUrl];
451
+ }
452
+ const request = common.createRequest(baseUrl);
453
+ config.services.request = { ...createChatService(request), ...createFileService(request) };
454
+ };
412
455
  const setPreview = (file = {}, isEdit = false) => {
413
456
  if (common.shouldRender(config.layout.preview)) {
414
457
  config.preview = {
@@ -434,7 +477,7 @@ function createChatStore() {
434
477
  config.hooks = hooks;
435
478
  };
436
479
  const setUserInfo = (userInfo) => {
437
- config.userInfo = transform(userInfo || common.getCurrentUser(), {
480
+ config.userInfo = transform(userInfo || common.getCurrentUser() || {}, {
438
481
  id: (userInfo2) => {
439
482
  return String(userInfo2["id"]);
440
483
  },
@@ -464,7 +507,7 @@ function createChatStore() {
464
507
  }
465
508
  try {
466
509
  receiver.loading = true;
467
- const { data } = await agentInfoQuery(agentId);
510
+ const { data } = await config.services.request.agentInfoQuery(agentId);
468
511
  receiver.active = transform(data, {
469
512
  name: "agentName",
470
513
  logo: "logo",
@@ -515,7 +558,7 @@ function createChatStore() {
515
558
  const getCharacters = async (agentId) => {
516
559
  try {
517
560
  character.loading = true;
518
- const { data } = await agentCharacterQuery(agentId);
561
+ const { data } = await config.services.request.agentCharacterQuery(agentId);
519
562
  if (receiver.active.id !== agentId) return;
520
563
  character.list = data;
521
564
  const active = data.find((item) => item.selected);
@@ -536,7 +579,7 @@ function createChatStore() {
536
579
  if (!c.id) return;
537
580
  try {
538
581
  character.switchLoading = true;
539
- await agentCharacterSelect(receiver.active.id, c.id);
582
+ await config.services.request.agentCharacterSelect(receiver.active.id, c.id);
540
583
  character.active = { ...c };
541
584
  closeCharacterList();
542
585
  } finally {
@@ -559,7 +602,7 @@ function createChatStore() {
559
602
  const getConversations = async (targetId, targetType) => {
560
603
  try {
561
604
  conversations.loading = true;
562
- const { data } = await conversationsQuery({
605
+ const { data } = await config.services.request.conversationsQuery({
563
606
  targetId,
564
607
  targetType,
565
608
  businessId: config.params.businessId,
@@ -586,7 +629,7 @@ function createChatStore() {
586
629
  const canProceed = await config.hooks?.onBeforeDelConversation?.(conversationId);
587
630
  if (canProceed === false) return;
588
631
  conversations.delLoading = true;
589
- await conversationDelete(conversationId);
632
+ await config.services.request.conversationDelete(conversationId);
590
633
  antd.message.success("\u5220\u9664\u6210\u529F");
591
634
  conversations.list.items = conversations.list.items.filter((item) => item.key !== conversationId);
592
635
  delete conversation.messages[conversationId];
@@ -637,7 +680,7 @@ function createChatStore() {
637
680
  if (!messages?.length) return;
638
681
  let lastMessage = messages[messages.length - 1];
639
682
  if (!lastMessage || lastMessage.sender.type !== 3 || lastMessage.id !== messageId) return;
640
- const { data } = await messageSuggestedQuery(messageId);
683
+ const { data } = await config.services.request.messageSuggestedQuery(messageId);
641
684
  lastMessage = messages[messages.length - 1];
642
685
  if (lastMessage.id !== messageId) return;
643
686
  conversation.messages[conversationId].questionList = data;
@@ -645,7 +688,7 @@ function createChatStore() {
645
688
  const feedback = async (conversationId, messageId, msgFeedback, index) => {
646
689
  try {
647
690
  conversation.feedback.loading = true;
648
- await feedbackUpdate({ conversationId, id: messageId, msgFeedback });
691
+ await config.services.request.feedbackUpdate({ conversationId, id: messageId, msgFeedback });
649
692
  antd.message.success("\u611F\u8C22\u60A8\u7684\u53CD\u9988");
650
693
  conversation.messages[conversationId].message[index].msgFeedback = msgFeedback;
651
694
  } finally {
@@ -666,7 +709,7 @@ function createChatStore() {
666
709
  };
667
710
  const resolveConversationId = async (receiverId, strategy = 2) => {
668
711
  if (strategy === 1) {
669
- const { data } = await conversationRecentQuery({
712
+ const { data } = await config.services.request.conversationRecentQuery({
670
713
  receiverId,
671
714
  receiverType: 3,
672
715
  businessId: config.params.businessId,
@@ -674,7 +717,7 @@ function createChatStore() {
674
717
  });
675
718
  return data;
676
719
  } else {
677
- const { data } = await conversationCreate({
720
+ const { data } = await config.services.request.conversationCreate({
678
721
  receiverId,
679
722
  receiverType: 3,
680
723
  businessId: config.params.businessId,
@@ -689,7 +732,7 @@ function createChatStore() {
689
732
  };
690
733
  const initConversation = async (conversationId) => {
691
734
  try {
692
- const { data } = await conversationMemberQuery(conversationId);
735
+ const { data } = await config.services.request.conversationMemberQuery(conversationId);
693
736
  conversation.active = { id: conversationId, member: {} };
694
737
  data.forEach((member) => {
695
738
  if (member.memberType === 3) {
@@ -749,7 +792,7 @@ function createChatStore() {
749
792
  setInitMessage(conversationId);
750
793
  }
751
794
  if (conversation.messages[conversationId].message.length === 0) {
752
- const { data } = await conversationMessagesQuery({
795
+ const { data } = await config.services.request.conversationMessagesQuery({
753
796
  pageNo: 1,
754
797
  pageSize: 1e3,
755
798
  conversationId
@@ -809,7 +852,7 @@ function createChatStore() {
809
852
  setHeaderOpen(false);
810
853
  }
811
854
  try {
812
- await conversationMessageSend(sendParams);
855
+ await config.services.request.conversationMessageSend(sendParams);
813
856
  config.hooks?.onAfterSend?.();
814
857
  } finally {
815
858
  conversation.messages[conversationId].loading = false;
@@ -817,7 +860,7 @@ function createChatStore() {
817
860
  };
818
861
  const cancelReceive = async () => {
819
862
  console.log("\u53D6\u6D88\u63A5\u6536");
820
- await conversationStop(conversation.active.id);
863
+ await config.services.request.conversationStop(conversation.active.id);
821
864
  };
822
865
  const updateConversationTitle = (conversationId, title) => {
823
866
  const idx = conversations.list.items.findIndex((item) => item.id === conversationId);
@@ -887,6 +930,7 @@ function createChatStore() {
887
930
  };
888
931
  return {
889
932
  config,
933
+ setServices,
890
934
  setPreview,
891
935
  setLayout,
892
936
  setHooks,
@@ -970,9 +1014,8 @@ init_Context();
970
1014
  // src/ui/common/styles.module.less
971
1015
  var styles_module_default2 = {
972
1016
  loadingMessage: "styles_module_loadingMessage",
973
- conversationListPanel: "styles_module_conversationListPanel",
1017
+ nsConversationListPanel: "styles_module_nsConversationListPanel",
974
1018
  nsConversations: "styles_module_nsConversations",
975
- nsBodyWidth: "styles_module_nsBodyWidth",
976
1019
  nsBubbleList: "styles_module_nsBubbleList",
977
1020
  nsChatHeader: "styles_module_nsChatHeader",
978
1021
  nsChatTitle: "styles_module_nsChatTitle",
@@ -980,19 +1023,19 @@ var styles_module_default2 = {
980
1023
  chatWelcomeWrap: "styles_module_chatWelcomeWrap",
981
1024
  chatWelcome: "styles_module_chatWelcome",
982
1025
  chatWelcomePrompts: "styles_module_chatWelcomePrompts",
983
- senderListTitle: "styles_module_senderListTitle",
984
- senderList: "styles_module_senderList",
985
- senderListItem: "styles_module_senderListItem",
986
- senderListFooter: "styles_module_senderListFooter",
1026
+ nsSenderListTitle: "styles_module_nsSenderListTitle",
1027
+ nsSenderList: "styles_module_nsSenderList",
1028
+ nsSenderListItem: "styles_module_nsSenderListItem",
1029
+ nsSenderListFooter: "styles_module_nsSenderListFooter",
987
1030
  nsChatUserName: "styles_module_nsChatUserName",
988
1031
  nsSenderReferenceHeaderTitle: "styles_module_nsSenderReferenceHeaderTitle",
989
1032
  nsSenderReferenceHeaderContent: "styles_module_nsSenderReferenceHeaderContent",
990
- avatarListContainer: "styles_module_avatarListContainer",
991
- avatarList: "styles_module_avatarList",
992
- avatarListItem: "styles_module_avatarListItem",
993
- avatarListItemIcon: "styles_module_avatarListItemIcon",
994
- avatarListItemIconActive: "styles_module_avatarListItemIconActive",
995
- avatarListItemName: "styles_module_avatarListItemName"
1033
+ nsAvatarListContainer: "styles_module_nsAvatarListContainer",
1034
+ nsAvatarList: "styles_module_nsAvatarList",
1035
+ nsAvatarListItem: "styles_module_nsAvatarListItem",
1036
+ nsAvatarListItemIcon: "styles_module_nsAvatarListItemIcon",
1037
+ nsAvatarListItemIconActive: "styles_module_nsAvatarListItemIconActive",
1038
+ nsAvatarListItemName: "styles_module_nsAvatarListItemName"
996
1039
  };
997
1040
  function extractThinkContent(content) {
998
1041
  let main = content;
@@ -1031,7 +1074,7 @@ var MessageAIRender_default = ({ message: message3, placement }) => {
1031
1074
  x.Bubble,
1032
1075
  {
1033
1076
  placement,
1034
- className: classNames7__default.default({ [styles_module_default2.loadingMessage]: message3.type && message3.type !== "TEXT_MESSAGE_END" }),
1077
+ className: classNames8__default.default({ [styles_module_default2.loadingMessage]: message3.type && message3.type !== "TEXT_MESSAGE_END" }),
1035
1078
  content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1036
1079
  thinkContents.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1037
1080
  antd.Collapse,
@@ -1104,7 +1147,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1104
1147
  /* @__PURE__ */ jsxRuntime.jsx(
1105
1148
  x.Welcome,
1106
1149
  {
1107
- className: classNames7__default.default(styles_module_default2.chatWelcome, "p-t-32"),
1150
+ className: classNames8__default.default(styles_module_default2.chatWelcome, "p-t-32"),
1108
1151
  variant: "borderless",
1109
1152
  icon: /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { shape: "square", size: 58, src: receiverState.active.logo }),
1110
1153
  title: `\u4F60\u597D\uFF0C\u6211\u662F${receiverState.active.name || ""}`,
@@ -1122,7 +1165,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1122
1165
  label: "\u{1F914} \u63A8\u8350\u95EE\u9898:",
1123
1166
  children: receiverState.active.config.recommendQuestions.map(({ question }) => ({
1124
1167
  key: question,
1125
- description: /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => chatStore.sendMessage(question), className: classNames7__default.default(styles_module_default2.chatWelcomePrompts, "text-ellipsis"), children: question })
1168
+ description: /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => chatStore.sendMessage(question), className: classNames8__default.default(styles_module_default2.chatWelcomePrompts, "text-ellipsis"), children: question })
1126
1169
  }))
1127
1170
  }
1128
1171
  ]
@@ -1255,7 +1298,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1255
1298
  autoScroll: false,
1256
1299
  ref: listRef,
1257
1300
  items: bubbleListItems,
1258
- className: classNames7__default.default(styles_module_default2.nsBubbleList, "height-full", "scroll-fade-in"),
1301
+ className: classNames8__default.default(styles_module_default2.nsBubbleList, "height-full", "scroll-fade-in", "zero-chat-bubbles"),
1259
1302
  onScroll: handleScroll
1260
1303
  },
1261
1304
  conversationState.active.id
@@ -1286,18 +1329,18 @@ var CharacterList_default = () => {
1286
1329
  okText: "\u5207\u6362\u6027\u683C",
1287
1330
  onOk: () => chatStore.switchCharacter(activeCharacter),
1288
1331
  confirmLoading: characterState.switchLoading,
1289
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.avatarListContainer, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { wrap: true, gutter: [16, 32], className: styles_module_default2.avatarList, children: characterState.list.map((item) => /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, align: "center", className: styles_module_default2.avatarListItem, onClick: () => setActiveCharacter(item), children: [
1332
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.nsAvatarListContainer, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { wrap: true, gutter: [16, 32], className: styles_module_default2.nsAvatarList, children: characterState.list.map((item) => /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, align: "center", className: styles_module_default2.nsAvatarListItem, onClick: () => setActiveCharacter(item), children: [
1290
1333
  /* @__PURE__ */ jsxRuntime.jsx(
1291
1334
  antd.Avatar,
1292
1335
  {
1293
- className: classNames7__default.default(styles_module_default2.avatarListItemIcon, "cursor-pointer", {
1294
- [styles_module_default2.avatarListItemIconActive]: activeCharacter.id === item.id
1336
+ className: classNames8__default.default(styles_module_default2.nsAvatarListItemIcon, "cursor-pointer", {
1337
+ [styles_module_default2.nsAvatarListItemIconActive]: activeCharacter.id === item.id
1295
1338
  }),
1296
1339
  size: 50,
1297
1340
  src: /* @__PURE__ */ jsxRuntime.jsx("img", { src: item.logo, alt: "\u5934\u50CF" })
1298
1341
  }
1299
1342
  ),
1300
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.avatarListItemName, children: item.characterName })
1343
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.nsAvatarListItemName, children: item.characterName })
1301
1344
  ] }) }, item.id)) }) })
1302
1345
  }
1303
1346
  );
@@ -1385,7 +1428,7 @@ var ChatHeader_default = ({
1385
1428
  const chatStore = useChatStore();
1386
1429
  const receiverState = valtio.useSnapshot(chatStore.receiver);
1387
1430
  const configState = valtio.useSnapshot(chatStore.config);
1388
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", className: styles_module_default2.nsChatHeader, children: [
1431
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", className: classNames8__default.default(styles_module_default2.nsChatHeader, "zero-chat-header"), children: [
1389
1432
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 4, align: "center", children: [
1390
1433
  /* @__PURE__ */ jsxRuntime.jsx(
1391
1434
  common.RenderWrapper,
@@ -1438,9 +1481,10 @@ var ChatHeader_default = ({
1438
1481
 
1439
1482
  // src/components/styles.module.less
1440
1483
  var styles_module_default3 = {
1441
- nsAttachments: "styles_module_nsAttachments"
1484
+ chatAttachments: "styles_module_chatAttachments",
1485
+ chatSender: "styles_module_chatSender"
1442
1486
  };
1443
- var Attachments_default = react.forwardRef(({ fileUploadConfig = [], fileList = [], onChange, extraParams }, ref) => {
1487
+ var Attachments_default = react.forwardRef(({ fileUpload, fileUploadConfig = [], fileList = [], onChange, extraParams }, ref) => {
1444
1488
  const { message: message3 } = antd.App.useApp();
1445
1489
  const fileListRef = react.useRef([]);
1446
1490
  const [attachedFiles, setAttachedFiles, getAttachedFiles] = common.useRefState([]);
@@ -1573,7 +1617,7 @@ var Attachments_default = react.forwardRef(({ fileUploadConfig = [], fileList =
1573
1617
  return /* @__PURE__ */ jsxRuntime.jsx(
1574
1618
  x.Attachments,
1575
1619
  {
1576
- className: styles_module_default3.nsAttachments,
1620
+ className: styles_module_default3.chatAttachments,
1577
1621
  accept: acceptStr,
1578
1622
  multiple: true,
1579
1623
  customRequest: onCustomRequest,
@@ -1605,11 +1649,11 @@ var ChatSender_default = react.forwardRef(
1605
1649
  extraFooter,
1606
1650
  extraFooterBelow,
1607
1651
  sendBtnProps,
1608
- fileUpload: fileUpload2
1652
+ fileUpload
1609
1653
  }, ref) => {
1610
1654
  const senderRef = react.useRef(null);
1611
1655
  const { inputValue, setInputValue } = common.useSyncInput(content || "", onContentChange);
1612
- const attachmentsNode = (fileUpload2?.config?.length ?? 0 > 0) && /* @__PURE__ */ jsxRuntime.jsx(antd.Badge, { dot: !!fileList?.length && !headerOpen, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PaperClipOutlined, {}), onClick: () => onHeaderOpenChange(!headerOpen) }) });
1656
+ const attachmentsNode = (fileUpload?.config?.length ?? 0 > 0) && /* @__PURE__ */ jsxRuntime.jsx(antd.Badge, { dot: !!fileList?.length && !headerOpen, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PaperClipOutlined, {}), onClick: () => onHeaderOpenChange(!headerOpen) }) });
1613
1657
  const attachmentsRef = react.useRef();
1614
1658
  const senderHeader = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1615
1659
  /* @__PURE__ */ jsxRuntime.jsx(x.Sender.Header, { title: "\u9009\u62E9\u6587\u4EF6", open: headerOpen, onOpenChange: onHeaderOpenChange, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -1617,9 +1661,10 @@ var ChatSender_default = react.forwardRef(
1617
1661
  {
1618
1662
  ref: attachmentsRef,
1619
1663
  fileList,
1664
+ fileUpload: fileUpload.request,
1620
1665
  onChange: onFileListChange,
1621
- fileUploadConfig: fileUpload2.config,
1622
- extraParams: fileUpload2.params
1666
+ fileUploadConfig: fileUpload.config,
1667
+ extraParams: fileUpload.params
1623
1668
  }
1624
1669
  ) }),
1625
1670
  extraHeader
@@ -1641,6 +1686,7 @@ var ChatSender_default = react.forwardRef(
1641
1686
  return /* @__PURE__ */ jsxRuntime.jsx(x.Suggestion, { items: [], onSelect: (itemVal) => setInputValue(`[${itemVal}]:`), children: ({}) => /* @__PURE__ */ jsxRuntime.jsx(
1642
1687
  x.Sender,
1643
1688
  {
1689
+ className: styles_module_default3.chatSender,
1644
1690
  ref: senderRef,
1645
1691
  value: inputValue,
1646
1692
  header: senderHeader,
@@ -1689,16 +1735,16 @@ var SenderPromptsItems_default = () => {
1689
1735
  {
1690
1736
  itemLayout: "horizontal",
1691
1737
  split: false,
1692
- className: styles_module_default2.senderList,
1738
+ className: styles_module_default2.nsSenderList,
1693
1739
  dataSource: question.items,
1694
- renderItem: (item) => /* @__PURE__ */ jsxRuntime.jsx(antd.List.Item, { onClick: () => chatStore.sendMessage(item.question), className: styles_module_default2.senderListItem, children: item.question }),
1695
- footer: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "end", className: styles_module_default2.senderListFooter, children: "(\u60A8\u53EF\u70B9\u51FB\u4EE5\u4E0A\u95EE\u9898\u5F00\u542FAI\u4F53\u9A8C)" })
1740
+ renderItem: (item) => /* @__PURE__ */ jsxRuntime.jsx(antd.List.Item, { onClick: () => chatStore.sendMessage(item.question), className: styles_module_default2.nsSenderListItem, children: item.question }),
1741
+ footer: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "end", className: styles_module_default2.nsSenderListFooter, children: "(\u60A8\u53EF\u70B9\u51FB\u4EE5\u4E0A\u95EE\u9898\u5F00\u542FAI\u4F53\u9A8C)" })
1696
1742
  }
1697
1743
  ),
1698
1744
  title: /* @__PURE__ */ jsxRuntime.jsx(
1699
1745
  "div",
1700
1746
  {
1701
- className: classNames7__default.default(styles_module_default2.senderListTitle, "text-ellipsis"),
1747
+ className: classNames8__default.default(styles_module_default2.nsSenderListTitle, "text-ellipsis"),
1702
1748
  children: `${receiverState.active.name}\u5F00\u59CB\u5173\u6CE8${question.name}\u5185\u5BB9\uFF01`
1703
1749
  }
1704
1750
  ),
@@ -1712,8 +1758,9 @@ var SenderPromptsItems_default = () => {
1712
1758
  return component;
1713
1759
  };
1714
1760
  var ChatSender_default2 = react.forwardRef(
1715
- ({ placeholder, extraBtn = false, referencesBtn = false, sendBtnProps = {}, footerBelow = false, prompts = true }, ref) => {
1761
+ ({ placeholder, extraBtn = false, referencesBtn = false, sendBtnProps, footerBelow = false, prompts = true }, ref) => {
1716
1762
  const chatStore = useChatStore();
1763
+ const configState = valtio.useSnapshot(chatStore.config);
1717
1764
  const receiverState = valtio.useSnapshot(chatStore.receiver);
1718
1765
  const conversationState = valtio.useSnapshot(chatStore.conversation);
1719
1766
  const chatMessage = react.useMemo(
@@ -1727,7 +1774,7 @@ var ChatSender_default2 = react.forwardRef(
1727
1774
  chatStore.sendMessage();
1728
1775
  }, 10);
1729
1776
  };
1730
- return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 8, children: [
1777
+ return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 8, className: "zero-chat-sender", children: [
1731
1778
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: prompts, DefaultComponent: SenderPromptsItems_default }),
1732
1779
  /* @__PURE__ */ jsxRuntime.jsx(
1733
1780
  ChatSender_default,
@@ -1745,9 +1792,10 @@ var ChatSender_default2 = react.forwardRef(
1745
1792
  onCancel: chatStore.cancelReceive,
1746
1793
  onFocus: chatStore.config.hooks?.onSenderFocus,
1747
1794
  fileUpload: {
1795
+ request: configState.services.request?.fileUpload,
1748
1796
  config: receiverState.active.config?.fileUpload
1749
1797
  },
1750
- sendBtnProps,
1798
+ sendBtnProps: common.isFunction(sendBtnProps) ? sendBtnProps() : {},
1751
1799
  extraFooterBelow: /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: footerBelow }),
1752
1800
  extraFooter: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1753
1801
  receiverState.active.feature?.deepThink && /* @__PURE__ */ jsxRuntime.jsx(
@@ -1825,7 +1873,7 @@ var ConversationListHeader_default = () => {
1825
1873
  type: "primary",
1826
1874
  shape: "round",
1827
1875
  onClick: () => chatStore.createConversation(),
1828
- className: classNames7__default.default("m-t-16"),
1876
+ className: classNames8__default.default("m-t-16"),
1829
1877
  icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}),
1830
1878
  children: "\u65B0\u5EFA\u4F1A\u8BDD"
1831
1879
  }
@@ -1833,7 +1881,7 @@ var ConversationListHeader_default = () => {
1833
1881
  ] });
1834
1882
  };
1835
1883
  var ConversationListPanel_default = ({ header }) => {
1836
- return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames7__default.default("height-full", styles_module_default2.conversationListPanel), children: [
1884
+ return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames8__default.default("height-full", "zero-chat-conversations", styles_module_default2.nsConversationListPanel), children: [
1837
1885
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: header, DefaultComponent: ConversationListHeader_default }),
1838
1886
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(ConversationList_default, {}) })
1839
1887
  ] });
@@ -1845,11 +1893,16 @@ var styles_module_default4 = {
1845
1893
  nsPreviewHeaderTitle: "styles_module_nsPreviewHeaderTitle",
1846
1894
  nsChatSenderHeader: "styles_module_nsChatSenderHeader",
1847
1895
  nsDisclaimerNotice: "styles_module_nsDisclaimerNotice",
1848
- nsChatLayout: "styles_module_nsChatLayout"
1896
+ nsChatLayout: "styles_module_nsChatLayout",
1897
+ nsChatBody: "styles_module_nsChatBody",
1898
+ nsBodyWidth: "styles_module_nsBodyWidth"
1849
1899
  };
1850
- var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout, config }, ref) => {
1900
+ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout, config, services }, ref) => {
1851
1901
  const chatStore = react.useMemo(() => createChatStore(), []);
1852
1902
  const senderRef = react.useRef();
1903
+ common.useDeepEffect(() => {
1904
+ chatStore.setServices(services);
1905
+ }, [services]);
1853
1906
  common.useDeepEffect(() => {
1854
1907
  if (config?.conversationId) {
1855
1908
  chatStore.switchConversation(config.conversationId);
@@ -1883,6 +1936,7 @@ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout
1883
1936
  setReferences: chatStore.setReferences,
1884
1937
  setMessage: chatStore.setContent,
1885
1938
  setFiles: chatStore.setFileList,
1939
+ setServices: chatStore.setServices,
1886
1940
  setParams: chatStore.setParams,
1887
1941
  senderFocus: (options) => {
1888
1942
  senderRef.current?.focus(options);
@@ -1905,7 +1959,19 @@ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout
1905
1959
  }
1906
1960
  }, [hasPreView]);
1907
1961
  common.useWebSocket({
1908
- url: common.getWebSocketUrl(`/api/lolr/conversation/ws/subscribe?NS-TOKEN=${common.getToken()}`, common.isLocalhost() ? "192.168.6.23" : ""),
1962
+ url: configState.services.websocketBaseUrls?.[0] && common.getWebSocketUrl(
1963
+ `${configState.services.websocketBaseUrls?.[0]}/lolr/conversation/ws/subscribe?NS-TOKEN=${common.getToken()}`,
1964
+ common.isLocalhost() ? "192.168.6.23" : ""
1965
+ ),
1966
+ onMessage: chatStore.acceptMessage,
1967
+ clientHeartbeat: false,
1968
+ reconnectInterval: 1e4
1969
+ });
1970
+ common.useWebSocket({
1971
+ url: configState.services.websocketBaseUrls?.[1] && common.getWebSocketUrl(
1972
+ `${configState.services.websocketBaseUrls?.[1]}/lolr/conversation/ws/subscribe?NS-TOKEN=${common.getToken()}`,
1973
+ common.isLocalhost() ? "192.168.6.23" : ""
1974
+ ),
1909
1975
  onMessage: chatStore.acceptMessage,
1910
1976
  clientHeartbeat: false,
1911
1977
  reconnectInterval: 1e4
@@ -1913,7 +1979,7 @@ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout
1913
1979
  react.useEffect(() => {
1914
1980
  configState.hooks?.onBeforeInit?.();
1915
1981
  }, []);
1916
- return /* @__PURE__ */ jsxRuntime.jsx(x.XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: receiverState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames7__default.default(styles_module_default4.nsChatLayout, "height-full"), children: [
1982
+ return /* @__PURE__ */ jsxRuntime.jsx(x.XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: receiverState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames8__default.default(styles_module_default4.nsChatLayout, "zero-chat-layout", "height-full"), children: [
1917
1983
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
1918
1984
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { className: "full-scroll", children: [
1919
1985
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.leftPanel }),
@@ -1962,37 +2028,46 @@ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout
1962
2028
  }
1963
2029
  });
1964
2030
  },
1965
- onDownloadFile: (content, type) => fileCreate(content, configState.preview.file.fileName, type),
2031
+ onDownloadFile: (content, type) => configState.services.request.fileCreate(content, configState.preview.file.fileName, type),
1966
2032
  extraNav: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { bordered: false, color: "default", className: "cursor-pointer", onClick: () => chatStore.setPreview(), children: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseOutlined, {}) }) })
1967
2033
  }
1968
2034
  )
1969
2035
  ] }) }),
1970
- /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames7__default.default("height-full"), children: [
2036
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames8__default.default("height-full"), children: [
1971
2037
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
1972
- /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, className: classNames7__default.default("full-scroll"), children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "center", vertical: true, gap: 24, className: classNames7__default.default("height-full p-t-8 p-b-8", styles_module_default2.nsBodyWidth), children: [
1973
- common.shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
1974
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 8, children: [
1975
- /* @__PURE__ */ jsxRuntime.jsx(
1976
- common.RenderWrapper,
1977
- {
1978
- control: configState.layout.senderHeader,
1979
- DefaultComponent: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default4.nsChatSenderHeader, children: [
1980
- "\u6211\u662F ",
1981
- receiverState.active.name
1982
- ] })
1983
- }
1984
- ),
1985
- /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { ref: senderRef, control: configState.layout.sender, DefaultComponent: ChatSender_default2 }),
1986
- /* @__PURE__ */ jsxRuntime.jsx(
1987
- common.RenderWrapper,
1988
- {
1989
- control: configState.layout.disclaimerNotice,
1990
- DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default4.nsDisclaimerNotice, children: "\u5185\u5BB9\u7531AI\u751F\u6210\uFF0C\u4EC5\u4F9B\u53C2\u8003\uFF0C\u8BF7\u4ED4\u7EC6\u7504\u522B" })
1991
- }
1992
- )
1993
- ] }),
1994
- /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.senderFooter })
1995
- ] }) })
2038
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, className: classNames8__default.default("full-scroll"), children: /* @__PURE__ */ jsxRuntime.jsxs(
2039
+ antd.Flex,
2040
+ {
2041
+ justify: "center",
2042
+ vertical: true,
2043
+ gap: 24,
2044
+ className: classNames8__default.default("height-full", styles_module_default4.nsChatBody, "zero-chat-body", styles_module_default4.nsBodyWidth),
2045
+ children: [
2046
+ common.shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
2047
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 8, children: [
2048
+ /* @__PURE__ */ jsxRuntime.jsx(
2049
+ common.RenderWrapper,
2050
+ {
2051
+ control: configState.layout.senderHeader,
2052
+ DefaultComponent: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default4.nsChatSenderHeader, children: [
2053
+ "\u6211\u662F ",
2054
+ receiverState.active.name
2055
+ ] })
2056
+ }
2057
+ ),
2058
+ /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { ref: senderRef, control: configState.layout.sender, DefaultComponent: ChatSender_default2 }),
2059
+ /* @__PURE__ */ jsxRuntime.jsx(
2060
+ common.RenderWrapper,
2061
+ {
2062
+ control: configState.layout.disclaimerNotice,
2063
+ DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default4.nsDisclaimerNotice, children: "\u5185\u5BB9\u7531AI\u751F\u6210\uFF0C\u4EC5\u4F9B\u53C2\u8003\uFF0C\u8BF7\u4ED4\u7EC6\u7504\u522B" })
2064
+ }
2065
+ )
2066
+ ] }),
2067
+ /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.senderFooter })
2068
+ ]
2069
+ }
2070
+ ) })
1996
2071
  ] }) })
1997
2072
  ] })
1998
2073
  ] })