bhd-components 0.10.37 → 0.10.38

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.
@@ -242,7 +242,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
242
242
  apiRef.contentApi.addMsg({
243
243
  id: msgId,
244
244
  createTime: createTime,
245
- content: "正在输入...",
245
+ content: "正在思考...",
246
246
  location: "left",
247
247
  reference: recordObj.reference || null,
248
248
  source: null,
@@ -252,7 +252,7 @@ const Footer = /*#__PURE__*/ forwardRef((props, ref)=>{
252
252
  apiRef.contentApi.addMsg({
253
253
  id: msgId,
254
254
  createTime: createTime,
255
- content: "正在输入...",
255
+ content: "正在思考...",
256
256
  location: "left",
257
257
  reference: null,
258
258
  source: null,
@@ -608,8 +608,17 @@ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
608
608
  } else {
609
609
  // 没有跨天 判断是否相隔超过10分钟
610
610
  if (timeObj.timestamp - beforeTimeObj.timestamp > 10 * 60 * 1000) {
611
- // 超过10分钟 显示 时分
612
- time = `${timeObj.hours}:${timeObj.minutes}`;
611
+ // 超过10分钟 显示
612
+ let now = new Date();
613
+ // 当天的日期
614
+ let nowTimeStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
615
+ if (nowTimeStr === `${timeObj.year}-${timeObj.month}-${timeObj.day}`) {
616
+ // 是当天 显示 时分
617
+ time = `${timeObj.hours}:${timeObj.minutes}`;
618
+ } else {
619
+ // 不是当天 显示 年月日 时分
620
+ time = `${timeObj.year}-${timeObj.month}-${timeObj.day} ${timeObj.hours}:${timeObj.minutes}`;
621
+ }
613
622
  }
614
623
  }
615
624
  }
@@ -463,6 +463,9 @@
463
463
  padding: 8px;
464
464
  border-radius: 2px;
465
465
  background: #e7e7e7;
466
+ img {
467
+ width: 100%;
468
+ }
466
469
  p {
467
470
  color: @color-text-Secondary-Tr;
468
471
  font-size: 12px;
@@ -54,6 +54,12 @@ function escapeHtml(str) {
54
54
  }
55
55
  return str;
56
56
  }
57
+ const pattern = /!\[.*?\]\((.*?)\)/;
58
+ const exactRegex = /class\s*=\s*["']think-block["']/;
59
+ // 去掉think
60
+ const replaceThinkAndYaml = (text = "")=>{
61
+ return text.replace(/```(\s)?yaml(?:.|\n)*?```/ig, "").replace(/<thinking>([\s\S]*?)<\/thinking>/g, "").replace(RegExp('<div\\s+class="think-block">.*?<\\/div>', "gs"), '');
62
+ };
57
63
  mermaid.initialize({
58
64
  startOnLoad: false,
59
65
  theme: 'default',
@@ -136,6 +142,7 @@ const CustomerService = (props)=>{
136
142
  const getLisyFlagRef = useRef(0);
137
143
  const [showMemaid, setShowMemaid] = useState(false); //是否显示mermaid弹窗
138
144
  const [memaidContent, setMemaidContent] = useState(""); //mermaid内容
145
+ const shouqiTimer = useRef(null);
139
146
  const remarkable = new Remarkable({
140
147
  html: true,
141
148
  highlight: function(str, lang) {
@@ -222,6 +229,7 @@ const CustomerService = (props)=>{
222
229
  // //获取热门推荐
223
230
  // videoPageQuestiionsList(1);
224
231
  // }
232
+ console.log('initShowType', initShowType);
225
233
  setShowType(initShowType);
226
234
  }, [
227
235
  initShowType
@@ -1261,6 +1269,7 @@ const CustomerService = (props)=>{
1261
1269
  //先请求问题列表
1262
1270
  videoPageQuestiionsList(3);
1263
1271
  }
1272
+ let hasYamlStarted = false;
1264
1273
  //使用fetchEventSource接收数据
1265
1274
  const eventSource = fetchEventSource(`${urllocation}/chat-service/public/v1.0/chat-with-ai/messages`, {
1266
1275
  method: "POST",
@@ -1357,7 +1366,12 @@ const CustomerService = (props)=>{
1357
1366
  //识别的内容
1358
1367
  // console.log("eventSource msg: ", event.data);
1359
1368
  let msg = JSON.parse(event.data);
1360
- if (msg.message) {}
1369
+ if (msg.message) {
1370
+ if (!hasYamlStarted && msg.message && /```\s*yaml/.test(content)) {
1371
+ hasYamlStarted = true;
1372
+ }
1373
+ msg.message = msg.message.replace(/<thinking>/g, '<div class="think-block">').replace(/<\/thinking>/g, '</div>\n');
1374
+ }
1361
1375
  finishedRef.current = false;
1362
1376
  setFinished(false);
1363
1377
  msgStreamingCountRef.current = msgStreamingCountRef.current + 1;
@@ -1374,6 +1388,20 @@ const CustomerService = (props)=>{
1374
1388
  videoPageQuestiionsList(2);
1375
1389
  }
1376
1390
  testLabQuestion(JSON.parse(data).message, content, "");
1391
+ if (shouqiTimer.current) {
1392
+ clearTimeout(shouqiTimer.current);
1393
+ }
1394
+ shouqiTimer.current = setTimeout(()=>{
1395
+ if ($(".think-block").last().css("display") === 'block') {
1396
+ clearTimeout(shouqiTimer.current);
1397
+ $(".think-block").last().parent().find(".think-block").css({
1398
+ display: "none"
1399
+ });
1400
+ $(".think-block").last().parent().parent().find("i").css({
1401
+ transform: "rotate(180deg)"
1402
+ });
1403
+ }
1404
+ }, 1000);
1377
1405
  } else {}
1378
1406
  },
1379
1407
  onclose () {
@@ -1391,7 +1419,8 @@ const CustomerService = (props)=>{
1391
1419
  // console.log(aiSendQuestions().abort(),'slkdsdsdsd')
1392
1420
  if (pageNumHistory > 1) return;
1393
1421
  let obj = msg;
1394
- let id = msg.messageId;
1422
+ let tempId = "ai thought process";
1423
+ let id = tempId; // 原:let id = msg.messageId; 备注:解决思考过程返回的messageId和下边回复的内容值不同问题,新:改成临时固定相同id,finished完成时替换为实际返回的messageId值
1395
1424
  setHistoryMessageList((prevHistoryMessageList)=>{
1396
1425
  let list1 = prevHistoryMessageList;
1397
1426
  //删除临时数据
@@ -1458,6 +1487,17 @@ const CustomerService = (props)=>{
1458
1487
  console.log("isPosition", isPosition.current);
1459
1488
  scrollToBottom();
1460
1489
  if (msg.finished) {
1490
+ setHistoryMessageList((prevHistoryMessageList)=>{
1491
+ return prevHistoryMessageList.map((item)=>{
1492
+ if (item.id === tempId) {
1493
+ return _object_spread_props(_object_spread({}, item), {
1494
+ id: msg.messageId
1495
+ });
1496
+ } else {
1497
+ return item;
1498
+ }
1499
+ });
1500
+ });
1461
1501
  console.log('返回完成', msg, msgStreamingCountRef.current);
1462
1502
  //发送结束
1463
1503
  finishedRef.current = true;
@@ -1562,6 +1602,12 @@ const CustomerService = (props)=>{
1562
1602
  // getHistoryMessage(page-1,5,'1',dataList);
1563
1603
  // return;
1564
1604
  // }
1605
+ dataList = dataList.map((ele, index)=>{
1606
+ if (ele.message.includes("<thinking>") && !ele.message.includes("</thinking>")) {
1607
+ ele.message = ele.message + "</thinking>";
1608
+ }
1609
+ return ele;
1610
+ });
1565
1611
  setPageCount(Math.ceil(total / maxPageSize));
1566
1612
  setFirstItemIndex(total - maxPageSize * (page - 1));
1567
1613
  let newHistoryMessageList = [];
@@ -2366,6 +2412,9 @@ const CustomerService = (props)=>{
2366
2412
  message = removeMermaidBlockComments(message);
2367
2413
  }
2368
2414
  message = handleRenderSyntaxBlock(message, finishedRef.current || i != historyMessageList.length - 1);
2415
+ message = message.replace(/<thinking>([\s\S]*?)<\/thinking>/g, '<div class="think-block">$1</div>\n');
2416
+ message = message.replace(/```(\s)?yaml(?:.|\n)*?```/ig, "");
2417
+ message = message.replace(/```\s*yaml[\s\S]*/, '');
2369
2418
  if (lastId == item.id && keyWordProblem != "") {
2370
2419
  //点击历史记录时,找到关键字,防止关键字和标签名重复
2371
2420
  // let key_sign = 'sign_'+new Date().getTime();+'sign';
@@ -2447,6 +2496,8 @@ const CustomerService = (props)=>{
2447
2496
  /*#__PURE__*/ _jsx("i", {
2448
2497
  className: "yinyong_quote1",
2449
2498
  onClick: ()=>{
2499
+ // 问题的引用
2500
+ item.message = replaceThinkAndYaml(item.message);
2450
2501
  setCitationContent({
2451
2502
  content: item.message,
2452
2503
  id: item.id,
@@ -2516,14 +2567,14 @@ const CustomerService = (props)=>{
2516
2567
  item.quotedMessage && /*#__PURE__*/ _jsxs("div", {
2517
2568
  className: styles.citation_content,
2518
2569
  children: [
2519
- getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
2570
+ getByteLen(replaceThinkAndYaml(item.quotedMessage)) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
2520
2571
  overlayClassName: styles.popover_main_content,
2521
- title: item.quotedMessage,
2572
+ title: replaceThinkAndYaml(item.quotedMessage),
2522
2573
  placement: "leftTop",
2523
2574
  children: /*#__PURE__*/ _jsxs("p", {
2524
2575
  className: styles.text_exceed,
2525
2576
  children: [
2526
- item.quotedMessage,
2577
+ replaceThinkAndYaml(item.quotedMessage),
2527
2578
  /*#__PURE__*/ _jsx(RightOutlined, {})
2528
2579
  ]
2529
2580
  })
@@ -2677,6 +2728,35 @@ const CustomerService = (props)=>{
2677
2728
  /*#__PURE__*/ _jsxs("div", {
2678
2729
  className: styles.content,
2679
2730
  children: [
2731
+ !exactRegex.test(message) ? null : /*#__PURE__*/ _jsxs("div", {
2732
+ id: "click_" + i,
2733
+ onClick: ()=>{
2734
+ if ($(`#click_${i} + p .think-block`).css("display") === 'inline-block' || $(`#click_${i} + p .think-block`).css("display") === 'block') {
2735
+ $(`#click_${i} + p .think-block`).css({
2736
+ display: "none"
2737
+ });
2738
+ $(`#click_${i} i`).css({
2739
+ transform: "rotate(180deg)"
2740
+ });
2741
+ } else {
2742
+ $(`#click_${i} + p .think-block`).css({
2743
+ display: "block"
2744
+ });
2745
+ $(`#click_${i} i`).css({
2746
+ transform: "rotate(0deg)"
2747
+ });
2748
+ }
2749
+ },
2750
+ className: styles.content_put,
2751
+ children: [
2752
+ /*#__PURE__*/ _jsx("span", {
2753
+ children: "思考过程"
2754
+ }),
2755
+ /*#__PURE__*/ _jsx("i", {
2756
+ className: "iconfont iconfangxiang-xiaxiao"
2757
+ })
2758
+ ]
2759
+ }),
2680
2760
  item.message != "AI助手繁忙,请稍后再提问或" && /*#__PURE__*/ _jsx("p", {
2681
2761
  dangerouslySetInnerHTML: {
2682
2762
  __html: message
@@ -2755,14 +2835,14 @@ const CustomerService = (props)=>{
2755
2835
  item.quotedMessage && /*#__PURE__*/ _jsxs("div", {
2756
2836
  className: styles.citation_content,
2757
2837
  children: [
2758
- getByteLen(item.quotedMessage) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
2838
+ getByteLen(replaceThinkAndYaml(item.quotedMessage)) > 120 ? /*#__PURE__*/ _jsx(Tooltip, {
2759
2839
  overlayClassName: styles.popover_main_content,
2760
- title: item.quotedMessage,
2840
+ title: replaceThinkAndYaml(item.quotedMessage),
2761
2841
  placement: "rightTop",
2762
2842
  children: /*#__PURE__*/ _jsxs("p", {
2763
2843
  className: styles.text_exceed,
2764
2844
  children: [
2765
- item.quotedMessage,
2845
+ replaceThinkAndYaml(item.quotedMessage),
2766
2846
  /*#__PURE__*/ _jsx(RightOutlined, {})
2767
2847
  ]
2768
2848
  })
@@ -2988,6 +3068,8 @@ const CustomerService = (props)=>{
2988
3068
  /*#__PURE__*/ _jsx("i", {
2989
3069
  className: "yinyong_quote1",
2990
3070
  onClick: ()=>{
3071
+ // 答案的引用
3072
+ item.message = replaceThinkAndYaml(item.message);
2991
3073
  setCitationContent({
2992
3074
  content: item.message,
2993
3075
  imageUrl: item.extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value,
@@ -3184,6 +3266,7 @@ const CustomerService = (props)=>{
3184
3266
  /*#__PURE__*/ _jsx("i", {
3185
3267
  className: "yinyong_quote1",
3186
3268
  onClick: ()=>{
3269
+ item.message = replaceThinkAndYaml(item.message);
3187
3270
  setCitationContent({
3188
3271
  content: item.message,
3189
3272
  imageUrl: item.extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value,
@@ -369,6 +369,42 @@
369
369
  .content_child {
370
370
  padding: 0;
371
371
  line-height: 1;
372
+ img {
373
+ width: 100%;
374
+ }
375
+ :global {
376
+ .think-block {
377
+ padding: 12px;
378
+ border-left: 1px solid rgba(0, 0, 0, 0.15);
379
+ background: rgba(0, 0, 0, 0.04);
380
+ // display: inline-block;
381
+ margin-bottom: 8px;
382
+ width: 100%;
383
+ font-weight: 400;
384
+ font-size: 12px;
385
+ line-height: 1.5;
386
+ color: rgba(0, 0, 0, 0.45);
387
+ * {
388
+ color: rgba(0, 0, 0, 0.45);
389
+ font-weight: 400;
390
+ font-size: 12px;
391
+ line-height: 150%;
392
+ }
393
+ &:not(:first-of-type, :last-of-type){
394
+ padding-top:0;
395
+ padding-bottom: 0;
396
+ }
397
+ &:first-of-type{
398
+ padding-top: 12px !important;
399
+ }
400
+ &:last-of-type{
401
+ padding-bottom: 12px !important;
402
+ }
403
+ &+.think-block{
404
+ margin-top: -8px;
405
+ }
406
+ }
407
+ }
372
408
 
373
409
  p{
374
410
  word-break: break-all;
@@ -441,7 +477,7 @@
441
477
  // > ul + *, > ol + * {
442
478
  // margin-top:16px;
443
479
  // }
444
- > *:not(pre){
480
+ > *:not(pre):not(:global(.think-block)){
445
481
  word-break: break-all;
446
482
  padding-top: 8px;
447
483
  padding-bottom: 8px;
@@ -2279,4 +2315,24 @@ strong {
2279
2315
  padding: 10px;
2280
2316
  }
2281
2317
 
2318
+ }
2319
+
2320
+ .content_put {
2321
+ display: flex;
2322
+ padding: 4px 16px;
2323
+ margin-bottom: 8px;
2324
+ border-radius: 100px;
2325
+ background: rgba(0, 0, 0, 0.04);
2326
+ width: max-content;
2327
+ align-items: center;
2328
+ cursor: pointer;
2329
+ span {
2330
+ color: rgba(0, 0, 0, 0.65);
2331
+ font-size: 12px;
2332
+ font-weight: 400;
2333
+ line-height: 150%;
2334
+ }
2335
+ i {
2336
+ margin-left: 8px;
2337
+ }
2282
2338
  }
@@ -365,6 +365,43 @@
365
365
  .content_child {
366
366
  padding: 0;
367
367
  line-height: 1;
368
+ img {
369
+ width: 100%;
370
+ }
371
+ :global {
372
+ .think-block {
373
+ padding: 12px;
374
+ padding-top: 12px !important;
375
+ border-left: 1px solid rgba(0, 0, 0, 0.15);
376
+ background: rgba(0, 0, 0, 0.04);
377
+ // display: inline-block;
378
+ margin-bottom: 8px;
379
+ width: 100%;
380
+ font-weight: 400;
381
+ font-size: 12px;
382
+ line-height: 1.5;
383
+ color: rgba(0, 0, 0, 0.45);
384
+ * {
385
+ color: rgba(0, 0, 0, 0.45);
386
+ font-weight: 400;
387
+ font-size: 12px;
388
+ line-height: 150%;
389
+ }
390
+ &:not(:first-of-type, :last-of-type){
391
+ padding-top:0;
392
+ padding-bottom: 0;
393
+ }
394
+ &:first-of-type{
395
+ padding-top: 12px !important;
396
+ }
397
+ &:last-of-type{
398
+ padding-bottom: 12px !important;
399
+ }
400
+ &+.think-block{
401
+ margin-top: -8px;
402
+ }
403
+ }
404
+ }
368
405
  p{
369
406
  word-break: break-all;
370
407
  white-space: break-spaces;
@@ -436,7 +473,7 @@
436
473
  // > ul + *, > ol + * {
437
474
  // margin-top:16px;
438
475
  // }
439
- > *:not(pre){
476
+ > *:not(pre):not(:global(.think-block)){
440
477
  word-break: break-all;
441
478
  padding-top: 8px;
442
479
  padding-bottom: 8px;
@@ -2217,3 +2254,23 @@
2217
2254
  strong {
2218
2255
  font-weight: bold !important;
2219
2256
  }
2257
+
2258
+ .content_put {
2259
+ display: flex;
2260
+ padding: 4px 16px;
2261
+ margin-bottom: 8px;
2262
+ border-radius: 100px;
2263
+ background: rgba(0, 0, 0, 0.04);
2264
+ width: max-content;
2265
+ align-items: center;
2266
+ cursor: pointer;
2267
+ span {
2268
+ color: rgba(0, 0, 0, 0.65);
2269
+ font-size: 12px;
2270
+ font-weight: 400;
2271
+ line-height: 150%;
2272
+ }
2273
+ i {
2274
+ margin-left: 8px;
2275
+ }
2276
+ }
@@ -254,7 +254,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
254
254
  apiRef.contentApi.addMsg({
255
255
  id: msgId,
256
256
  createTime: createTime,
257
- content: "正在输入...",
257
+ content: "正在思考...",
258
258
  location: "left",
259
259
  reference: recordObj.reference || null,
260
260
  source: null,
@@ -264,7 +264,7 @@ var Footer = /*#__PURE__*/ forwardRef(function(props, ref) {
264
264
  apiRef.contentApi.addMsg({
265
265
  id: msgId,
266
266
  createTime: createTime,
267
- content: "正在输入...",
267
+ content: "正在思考...",
268
268
  location: "left",
269
269
  reference: null,
270
270
  source: null,
@@ -587,8 +587,17 @@ var VirtuosoList = /*#__PURE__*/ forwardRef(function(props, ref) {
587
587
  } else {
588
588
  // 没有跨天 判断是否相隔超过10分钟
589
589
  if (timeObj.timestamp - beforeTimeObj.timestamp > 10 * 60 * 1000) {
590
- // 超过10分钟 显示 时分
591
- time = "".concat(timeObj.hours, ":").concat(timeObj.minutes);
590
+ // 超过10分钟 显示
591
+ var now = new Date();
592
+ // 当天的日期
593
+ var nowTimeStr = "".concat(now.getFullYear(), "-").concat(String(now.getMonth() + 1).padStart(2, "0"), "-").concat(String(now.getDate()).padStart(2, "0"));
594
+ if (nowTimeStr === "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day)) {
595
+ // 是当天 显示 时分
596
+ time = "".concat(timeObj.hours, ":").concat(timeObj.minutes);
597
+ } else {
598
+ // 不是当天 显示 年月日 时分
599
+ time = "".concat(timeObj.year, "-").concat(timeObj.month, "-").concat(timeObj.day, " ").concat(timeObj.hours, ":").concat(timeObj.minutes);
600
+ }
592
601
  }
593
602
  }
594
603
  }
@@ -463,6 +463,9 @@
463
463
  padding: 8px;
464
464
  border-radius: 2px;
465
465
  background: #e7e7e7;
466
+ img {
467
+ width: 100%;
468
+ }
466
469
  p {
467
470
  color: @color-text-Secondary-Tr;
468
471
  font-size: 12px;