bhd-components 0.10.38 → 0.10.40

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.
@@ -2965,6 +2965,11 @@ var handleRenderSyntaxBlock = function(markdownContent, flag) {
2965
2965
  return markdownContent;
2966
2966
  }
2967
2967
  };
2968
+ // 去掉think
2969
+ var replaceThinkAndYaml = function() {
2970
+ var text = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
2971
+ return text.replace(/```(\s)?yaml(?:.|\n)*?```/ig, "").replace(/<thinking>([\s\S]*?)<\/thinking>/g, "").replace(RegExp('<div\\s+class="think-block">.*?<\\/div>', "gs"), "").replace(/^[ \n]+/g, "");
2972
+ };
2968
2973
 
2969
2974
  var HistoryFun = function(props) {
2970
2975
  var type = props.type; props.roomId; var userData = props.userData, http = props.http, urllocation = props.urllocation, onClose = props.onClose, loadSpecifiedData = props.loadSpecifiedData;
@@ -3514,7 +3519,7 @@ var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
3514
3519
  }),
3515
3520
  /*#__PURE__*/ jsx("p", {
3516
3521
  className: modules_63b47c51$f.con,
3517
- children: contactsList.length > 0 && contactsList[0].lastMsg
3522
+ children: contactsList.length > 0 && replaceThinkAndYaml(contactsList[0].lastMsg)
3518
3523
  })
3519
3524
  ]
3520
3525
  })
@@ -3560,7 +3565,7 @@ var ContactsList = /*#__PURE__*/ forwardRef(function(props, ref) {
3560
3565
  }),
3561
3566
  /*#__PURE__*/ jsx("p", {
3562
3567
  className: modules_63b47c51$f.con,
3563
- children: item.lastMsg
3568
+ children: replaceThinkAndYaml(item.lastMsg)
3564
3569
  })
3565
3570
  ]
3566
3571
  })
@@ -8184,6 +8189,16 @@ var ScreenShot = /*#__PURE__*/ function() {
8184
8189
  return ScreenShot;
8185
8190
  }();
8186
8191
 
8192
+ var guidGenerator = function() {
8193
+ var d = new Date().getTime();
8194
+ var uuid = "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, function(c) {
8195
+ var r = (d + Math.random() * 16) % 16 | 0;
8196
+ d = Math.floor(d / 16);
8197
+ return (c == "x" ? r : r & 3 | 8).toString(16);
8198
+ });
8199
+ return uuid;
8200
+ };
8201
+
8187
8202
  var styles = modules_63b47c51$f;
8188
8203
  var TextArea$1 = BhdEnterInput.TextArea;
8189
8204
  /*
@@ -8206,11 +8221,6 @@ function escapeHtml(str) {
8206
8221
  return str;
8207
8222
  }
8208
8223
  var exactRegex = /class\s*=\s*["']think-block["']/;
8209
- // 去掉think
8210
- var replaceThinkAndYaml = function() {
8211
- var text = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
8212
- return text.replace(/```(\s)?yaml(?:.|\n)*?```/ig, "").replace(/<thinking>([\s\S]*?)<\/thinking>/g, "").replace(RegExp('<div\\s+class="think-block">.*?<\\/div>', "gs"), "");
8213
- };
8214
8224
  r.initialize({
8215
8225
  startOnLoad: false,
8216
8226
  theme: "default",
@@ -8277,7 +8287,7 @@ var CustomerService = function(props) {
8277
8287
  var ctrl = useRef(); //停止生成ai回答时使用
8278
8288
  var childRef = useRef(null); //获取子组件方法
8279
8289
  useRef(0);
8280
- var _useState33 = _sliced_to_array(useState(true), 2), isPositionState = _useState33[0], setIsPositionState = _useState33[1];
8290
+ var _useState33 = _sliced_to_array(useState(true), 2); _useState33[0]; var setIsPositionState = _useState33[1];
8281
8291
  var isPosition = useRef(true);
8282
8292
  var recommendeQuestionID = useRef([]); //推荐问题id
8283
8293
  var videoHotQuestionsList = useRef([]); //视频热门问题
@@ -9550,7 +9560,7 @@ var CustomerService = function(props) {
9550
9560
  //先请求问题列表
9551
9561
  videoPageQuestiionsList(3);
9552
9562
  }
9553
- var hasYamlStarted = false;
9563
+ var tempMessageId = guidGenerator();
9554
9564
  //使用fetchEventSource接收数据
9555
9565
  fetchEventSource("".concat(urllocation, "/chat-service/public/v1.0/chat-with-ai/messages"), {
9556
9566
  method: "POST",
@@ -9658,10 +9668,12 @@ var CustomerService = function(props) {
9658
9668
  //识别的内容
9659
9669
  // console.log("eventSource msg: ", event.data);
9660
9670
  var msg = JSON.parse(event.data);
9671
+ console.log("tempMessageId", tempMessageId);
9672
+ msg.tempMessageId = tempMessageId;
9661
9673
  if (msg.message) {
9662
- if (!hasYamlStarted && msg.message && /```\s*yaml/.test(content)) {
9663
- hasYamlStarted = true;
9664
- }
9674
+ // if (!hasYamlStarted && msg.message && /```\s*yaml/.test(content)) {
9675
+ // hasYamlStarted = true;
9676
+ // }
9665
9677
  msg.message = msg.message.replace(/<thinking>/g, '<div class="think-block">').replace(/<\/thinking>/g, "</div>\n");
9666
9678
  }
9667
9679
  finishedRef.current = false;
@@ -9713,8 +9725,7 @@ var CustomerService = function(props) {
9713
9725
  // console.log(aiSendQuestions().abort(),'slkdsdsdsd')
9714
9726
  if (pageNumHistory > 1) return;
9715
9727
  var obj = msg;
9716
- var tempId = "ai thought process";
9717
- var id = tempId; // 原:let id = msg.messageId; 备注:解决思考过程返回的messageId和下边回复的内容值不同问题,新:改成临时固定相同id,finished完成时替换为实际返回的messageId值
9728
+ var id = msg.tempMessageId;
9718
9729
  setHistoryMessageList(function(prevHistoryMessageList) {
9719
9730
  var list1 = prevHistoryMessageList;
9720
9731
  //删除临时数据
@@ -9739,6 +9750,7 @@ var CustomerService = function(props) {
9739
9750
  recevier: mid,
9740
9751
  message: message,
9741
9752
  id: id,
9753
+ messageId: msg.messageId,
9742
9754
  upvoted: false,
9743
9755
  downvoted: false,
9744
9756
  createdAt: getDataTime(-1),
@@ -9769,6 +9781,7 @@ var CustomerService = function(props) {
9769
9781
  if (item.id == id) {
9770
9782
  return _object_spread_props(_object_spread({}, item), {
9771
9783
  message: message,
9784
+ messageId: msg.messageId,
9772
9785
  extraInfo: extraInfo == null ? item.extraInfo : JSON.stringify(extraInfo)
9773
9786
  });
9774
9787
  } else {
@@ -9781,17 +9794,6 @@ var CustomerService = function(props) {
9781
9794
  console.log("isPosition", isPosition.current);
9782
9795
  scrollToBottom();
9783
9796
  if (msg.finished) {
9784
- setHistoryMessageList(function(prevHistoryMessageList) {
9785
- return prevHistoryMessageList.map(function(item) {
9786
- if (item.id === tempId) {
9787
- return _object_spread_props(_object_spread({}, item), {
9788
- id: msg.messageId
9789
- });
9790
- } else {
9791
- return item;
9792
- }
9793
- });
9794
- });
9795
9797
  console.log("返回完成", msg, msgStreamingCountRef.current);
9796
9798
  //发送结束
9797
9799
  finishedRef.current = true;
@@ -9903,7 +9905,9 @@ var CustomerService = function(props) {
9903
9905
  if (ele.message.includes("<thinking>") && !ele.message.includes("</thinking>")) {
9904
9906
  ele.message = ele.message + "</thinking>";
9905
9907
  }
9906
- return ele;
9908
+ return _object_spread_props(_object_spread({}, ele), {
9909
+ messageId: ele.id
9910
+ });
9907
9911
  });
9908
9912
  setPageCount(Math.ceil(total / maxPageSize));
9909
9913
  setFirstItemIndex(total - maxPageSize * (page - 1));
@@ -10013,7 +10017,11 @@ var CustomerService = function(props) {
10013
10017
  }).then(function(res) {
10014
10018
  var newHistoryMessageList = [];
10015
10019
  if (res.data.messages.length > 0) {
10016
- var dataList = res.data.messages.reverse();
10020
+ var dataList = res.data.messages.reverse().map(function(x) {
10021
+ return _object_spread_props(_object_spread({}, x), {
10022
+ messageId: x.id
10023
+ });
10024
+ });
10017
10025
  var originList = 0;
10018
10026
  var newList = 0;
10019
10027
  setHistoryMessageList(function(historyMessageList) {
@@ -10096,7 +10104,7 @@ var CustomerService = function(props) {
10096
10104
  } catch (error) {}
10097
10105
  };
10098
10106
  //点赞消息
10099
- var likeMessage = function(id, state) {
10107
+ var likeMessage = function(messageId, state, id) {
10100
10108
  var url = "";
10101
10109
  //点赞状态
10102
10110
  if (!state) {
@@ -10105,7 +10113,7 @@ var CustomerService = function(props) {
10105
10113
  url = "".concat(urllocation, "/chat-service/public/v1.0/history-messages:cancelUpvote");
10106
10114
  }
10107
10115
  http.post(url, {
10108
- messageId: id
10116
+ messageId: messageId
10109
10117
  }).then(function(res) {
10110
10118
  setHistoryMessageList(function(historyMessageList) {
10111
10119
  var list = historyMessageList;
@@ -10120,7 +10128,7 @@ var CustomerService = function(props) {
10120
10128
  });
10121
10129
  };
10122
10130
  //踩
10123
- var disagreeMessage = function(id, state) {
10131
+ var disagreeMessage = function(messageId, state, id) {
10124
10132
  var url = "";
10125
10133
  //点赞状态
10126
10134
  if (!state) {
@@ -10129,7 +10137,7 @@ var CustomerService = function(props) {
10129
10137
  url = "".concat(urllocation, "/chat-service/public/v1.0/history-messages:cancelDownvote");
10130
10138
  }
10131
10139
  http.post(url, {
10132
- messageId: id
10140
+ messageId: messageId
10133
10141
  }).then(function(res) {
10134
10142
  setHistoryMessageList(function(historyMessageList) {
10135
10143
  var list = historyMessageList;
@@ -10789,9 +10797,8 @@ var CustomerService = function(props) {
10789
10797
  className: "yinyong_quote1",
10790
10798
  onClick: function() {
10791
10799
  // 问题的引用
10792
- item.message = replaceThinkAndYaml(item.message);
10793
10800
  setCitationContent({
10794
- content: item.message,
10801
+ content: replaceThinkAndYaml(item.message),
10795
10802
  id: item.id,
10796
10803
  imageUrl: !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" ? JSON.parse(item.extraInfo)[0].value : ""
10797
10804
  });
@@ -10808,7 +10815,7 @@ var CustomerService = function(props) {
10808
10815
  }) : /*#__PURE__*/ jsx("i", {
10809
10816
  className: "fuzhi21",
10810
10817
  onClick: function() {
10811
- copyText(item.message);
10818
+ copyText(replaceThinkAndYaml(item.message));
10812
10819
  {
10813
10820
  var obj = copyTextOBJ;
10814
10821
  obj = obj.filter(function(list) {
@@ -11221,11 +11228,7 @@ var CustomerService = function(props) {
11221
11228
  style: {
11222
11229
  height: "100%"
11223
11230
  },
11224
- initialTopMostItemIndex: !finished && isPositionState ? undefined : {
11225
- index: "LAST",
11226
- align: "end",
11227
- offset: showType === 3 ? 58 : showType === 4 ? 144 : 58
11228
- },
11231
+ // initialTopMostItemIndex={!finished&&isPositionState?undefined:{ index: "LAST", align: "end",offset:showType===3?58:showType===4?144:58 }}
11229
11232
  initialItemCount: 10,
11230
11233
  itemsRendered: function() {
11231
11234
  renderMermaid();
@@ -11381,9 +11384,8 @@ var CustomerService = function(props) {
11381
11384
  className: "yinyong_quote1",
11382
11385
  onClick: function() {
11383
11386
  // 答案的引用
11384
- item.message = replaceThinkAndYaml(item.message);
11385
11387
  setCitationContent({
11386
- content: item.message,
11388
+ content: replaceThinkAndYaml(item.message),
11387
11389
  imageUrl: item.extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value,
11388
11390
  id: item.id
11389
11391
  });
@@ -11400,7 +11402,7 @@ var CustomerService = function(props) {
11400
11402
  }) : /*#__PURE__*/ jsx("i", {
11401
11403
  className: "fuzhi21",
11402
11404
  onClick: function() {
11403
- copyText(item.message);
11405
+ copyText(replaceThinkAndYaml(item.message));
11404
11406
  {
11405
11407
  var obj = copyTextOBJ;
11406
11408
  obj = obj.filter(function(list) {
@@ -11426,7 +11428,7 @@ var CustomerService = function(props) {
11426
11428
  /*#__PURE__*/ jsx("i", {
11427
11429
  className: "Frame427319094 ".concat(item.upvoted ? styles.active : ""),
11428
11430
  onClick: function() {
11429
- likeMessage(item.id, item.upvoted);
11431
+ likeMessage(item.messageId, item.upvoted, item.id);
11430
11432
  //老师的聊天窗口中不需要点赞和踩消息
11431
11433
  if (!isAiChatWindow) return;
11432
11434
  //只有最后一条回答,支持发送点赞或踩
@@ -11434,7 +11436,7 @@ var CustomerService = function(props) {
11434
11436
  if (!item.extraInfo && item.sender == "AI") {
11435
11437
  aiSendQuestions(1, {
11436
11438
  roomId: roomId,
11437
- message: "你给出的答案我非常满意,赞!",
11439
+ message: "\x03\x03\x03你给出的答案我非常满意,赞!\x03\x03\x03",
11438
11440
  quotedMessage: "",
11439
11441
  regenerate: false,
11440
11442
  generateUpvoteOrDownvoteMessage: true
@@ -11449,7 +11451,7 @@ var CustomerService = function(props) {
11449
11451
  /*#__PURE__*/ jsx("i", {
11450
11452
  className: "Frame427319095 ".concat(item.downvoted ? styles.active : ""),
11451
11453
  onClick: function() {
11452
- disagreeMessage(item.id, item.downvoted);
11454
+ disagreeMessage(item.messageId, item.downvoted, item.id);
11453
11455
  //老师的聊天窗口中不需要点赞和踩消息
11454
11456
  if (!isAiChatWindow) return;
11455
11457
  //只有最后一条回答,支持发送点赞或踩
@@ -11457,7 +11459,7 @@ var CustomerService = function(props) {
11457
11459
  if (!item.extraInfo && item.sender == "AI") {
11458
11460
  aiSendQuestions(1, {
11459
11461
  roomId: roomId,
11460
- message: "你给出的答案很糟糕,我不满意,踩!",
11462
+ message: "\x03\x03\x03你给出的答案很糟糕,我不满意,踩!\x03\x03\x03",
11461
11463
  quotedMessage: "",
11462
11464
  regenerate: false,
11463
11465
  generateUpvoteOrDownvoteMessage: true
@@ -11588,11 +11590,10 @@ var CustomerService = function(props) {
11588
11590
  /*#__PURE__*/ jsx("i", {
11589
11591
  className: "yinyong_quote1",
11590
11592
  onClick: function() {
11591
- item.message = replaceThinkAndYaml(item.message);
11592
11593
  setCitationContent({
11593
- content: item.message,
11594
+ content: replaceThinkAndYaml(item.message),
11594
11595
  imageUrl: item.extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value,
11595
- id: item.id
11596
+ id: item.messageId
11596
11597
  });
11597
11598
  resettingBottomHei();
11598
11599
  onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
@@ -11607,7 +11608,7 @@ var CustomerService = function(props) {
11607
11608
  }) : /*#__PURE__*/ jsx("i", {
11608
11609
  className: "fuzhi21",
11609
11610
  onClick: function() {
11610
- copyText(item.message);
11611
+ copyText(replaceThinkAndYaml(item.message));
11611
11612
  {
11612
11613
  var obj = copyTextOBJ;
11613
11614
  obj = obj.filter(function(list) {
@@ -11633,7 +11634,7 @@ var CustomerService = function(props) {
11633
11634
  /*#__PURE__*/ jsx("i", {
11634
11635
  className: "Frame427319094 ".concat(item.upvoted ? styles.active : ""),
11635
11636
  onClick: function() {
11636
- likeMessage(item.id, item.upvoted);
11637
+ likeMessage(item.messageId, item.upvoted, item.id);
11637
11638
  //老师的聊天窗口中不需要点赞和踩消息
11638
11639
  if (!isAiChatWindow) return;
11639
11640
  //只有最后一条回答,支持发送点赞或踩
@@ -11642,7 +11643,7 @@ var CustomerService = function(props) {
11642
11643
  if (!item.extraInfo && item.sender == "AI") {
11643
11644
  aiSendQuestions(1, {
11644
11645
  roomId: roomId,
11645
- message: "你给出的答案我非常满意,赞!",
11646
+ message: "\x03\x03\x03你给出的答案我非常满意,赞!\x03\x03\x03",
11646
11647
  quotedMessage: "",
11647
11648
  regenerate: false,
11648
11649
  generateUpvoteOrDownvoteMessage: true
@@ -11658,7 +11659,7 @@ var CustomerService = function(props) {
11658
11659
  /*#__PURE__*/ jsx("i", {
11659
11660
  className: "Frame427319095 ".concat(item.downvoted ? styles.active : ""),
11660
11661
  onClick: function() {
11661
- disagreeMessage(item.id, item.downvoted);
11662
+ disagreeMessage(item.messageId, item.downvoted, item.id);
11662
11663
  //老师的聊天窗口中不需要点赞和踩消息
11663
11664
  if (!isAiChatWindow) return;
11664
11665
  //只有最后一条回答,支持发送点赞或踩
@@ -11669,7 +11670,7 @@ var CustomerService = function(props) {
11669
11670
  //AI回答
11670
11671
  aiSendQuestions(1, {
11671
11672
  roomId: roomId,
11672
- message: "你给出的答案很糟糕,我不满意,踩!",
11673
+ message: "\x03\x03\x03你给出的答案很糟糕,我不满意,踩!\x03\x03\x03",
11673
11674
  quotedMessage: "",
11674
11675
  regenerate: false,
11675
11676
  generateUpvoteOrDownvoteMessage: true
@@ -15644,16 +15645,6 @@ var UploadFileBtn = SendBtn;
15644
15645
 
15645
15646
  var modules_63b47c51$1 = {"footer-fileList-wrapper":"index_module_footerFileListWrapper__e818c28d","footer-fileList-list":"index_module_footerFileListList__e818c28d","footer-fileList-listItem":"index_module_footerFileListListItem__e818c28d","footer-fileList-listItem-icon":"index_module_footerFileListListItemIcon__e818c28d","footer-fileList-listItem-text":"index_module_footerFileListListItemText__e818c28d","footer-fileList-listItem-status":"index_module_footerFileListListItemStatus__e818c28d","footer-fileList-listItem-delete":"index_module_footerFileListListItemDelete__e818c28d","footer-fileList-pre":"index_module_footerFileListPre__e818c28d","footer-fileList-next":"index_module_footerFileListNext__e818c28d"};
15646
15647
 
15647
- var guidGenerator = function() {
15648
- var d = new Date().getTime();
15649
- var uuid = "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, function(c) {
15650
- var r = (d + Math.random() * 16) % 16 | 0;
15651
- d = Math.floor(d / 16);
15652
- return (c == "x" ? r : r & 3 | 8).toString(16);
15653
- });
15654
- return uuid;
15655
- };
15656
-
15657
15648
  // 通过文件名 获取文件后缀
15658
15649
  var getSuffix = function(fileName) {
15659
15650
  return fileName.split(".").pop().toLowerCase();