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.
- package/dist/index.esm.es5.development.js +55 -64
- package/dist/index.esm.es5.production.js +1 -1
- package/dist/vendor.esm.es5.development.js +316 -316
- package/dist/vendor.esm.es5.production.js +1 -1
- package/es2017/customerService/contactsList.js +3 -3
- package/es2017/customerService/function.d.ts +2 -1
- package/es2017/customerService/function.js +5 -1
- package/es2017/customerService/index.js +37 -50
- package/esm/customerService/contactsList.js +3 -3
- package/esm/customerService/function.d.ts +2 -1
- package/esm/customerService/function.js +6 -1
- package/esm/customerService/index.js +39 -51
- package/package.json +1 -1
|
@@ -35,10 +35,11 @@ var TextArea = Input.TextArea;
|
|
|
35
35
|
// import './html2canvas.test.js';
|
|
36
36
|
import knowledge_icon from "./images/knowledge_icon.png";
|
|
37
37
|
// import { useMediaRecorder } from "./useMediaRecorder"; //录音使用文件
|
|
38
|
-
import { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, urlToBase64, toHashString, removeMermaidBlockComments, handleRenderSyntaxBlock } from "./function"; //一些方法
|
|
38
|
+
import { readMessage, getByteLen, serverUrl, copyText, getDataTime, getQuery, resetStyles, findParent, delegate, urlToBase64, toHashString, removeMermaidBlockComments, handleRenderSyntaxBlock, replaceThinkAndYaml } from "./function"; //一些方法
|
|
39
39
|
// import html2canvas from "html2canvas";
|
|
40
40
|
// const screenShot = require('./screenShotPlugin.esm')
|
|
41
41
|
import ScreenShot from "./js-screen-shot/main";
|
|
42
|
+
import { guidGenerator } from "../utils/number";
|
|
42
43
|
/*
|
|
43
44
|
自定义remarkable的text解析规则
|
|
44
45
|
*/ var HTML_ESCAPE_TEST_RE = /[&<>"]/;
|
|
@@ -60,11 +61,6 @@ function escapeHtml(str) {
|
|
|
60
61
|
}
|
|
61
62
|
var pattern = /!\[.*?\]\((.*?)\)/;
|
|
62
63
|
var exactRegex = /class\s*=\s*["']think-block["']/;
|
|
63
|
-
// 去掉think
|
|
64
|
-
var replaceThinkAndYaml = function() {
|
|
65
|
-
var text = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
66
|
-
return text.replace(/```(\s)?yaml(?:.|\n)*?```/ig, "").replace(/<thinking>([\s\S]*?)<\/thinking>/g, "").replace(RegExp('<div\\s+class="think-block">.*?<\\/div>', "gs"), "");
|
|
67
|
-
};
|
|
68
64
|
mermaid.initialize({
|
|
69
65
|
startOnLoad: false,
|
|
70
66
|
theme: "default",
|
|
@@ -1405,6 +1401,7 @@ var CustomerService = function(props) {
|
|
|
1405
1401
|
videoPageQuestiionsList(3);
|
|
1406
1402
|
}
|
|
1407
1403
|
var hasYamlStarted = false;
|
|
1404
|
+
var tempMessageId = guidGenerator();
|
|
1408
1405
|
//使用fetchEventSource接收数据
|
|
1409
1406
|
var eventSource = fetchEventSource("".concat(urllocation, "/chat-service/public/v1.0/chat-with-ai/messages"), {
|
|
1410
1407
|
method: "POST",
|
|
@@ -1514,10 +1511,12 @@ var CustomerService = function(props) {
|
|
|
1514
1511
|
//识别的内容
|
|
1515
1512
|
// console.log("eventSource msg: ", event.data);
|
|
1516
1513
|
var msg = JSON.parse(event.data);
|
|
1514
|
+
console.log("tempMessageId", tempMessageId);
|
|
1515
|
+
msg.tempMessageId = tempMessageId;
|
|
1517
1516
|
if (msg.message) {
|
|
1518
|
-
if (!hasYamlStarted && msg.message && /```\s*yaml/.test(content)) {
|
|
1519
|
-
|
|
1520
|
-
}
|
|
1517
|
+
// if (!hasYamlStarted && msg.message && /```\s*yaml/.test(content)) {
|
|
1518
|
+
// hasYamlStarted = true;
|
|
1519
|
+
// }
|
|
1521
1520
|
msg.message = msg.message.replace(/<thinking>/g, '<div class="think-block">').replace(/<\/thinking>/g, "</div>\n");
|
|
1522
1521
|
}
|
|
1523
1522
|
finishedRef.current = false;
|
|
@@ -1569,8 +1568,7 @@ var CustomerService = function(props) {
|
|
|
1569
1568
|
// console.log(aiSendQuestions().abort(),'slkdsdsdsd')
|
|
1570
1569
|
if (pageNumHistory > 1) return;
|
|
1571
1570
|
var obj = msg;
|
|
1572
|
-
var
|
|
1573
|
-
var id = tempId; // 原:let id = msg.messageId; 备注:解决思考过程返回的messageId和下边回复的内容值不同问题,新:改成临时固定相同id,finished完成时替换为实际返回的messageId值
|
|
1571
|
+
var id = msg.tempMessageId;
|
|
1574
1572
|
setHistoryMessageList(function(prevHistoryMessageList) {
|
|
1575
1573
|
var list1 = prevHistoryMessageList;
|
|
1576
1574
|
//删除临时数据
|
|
@@ -1595,6 +1593,7 @@ var CustomerService = function(props) {
|
|
|
1595
1593
|
recevier: mid,
|
|
1596
1594
|
message: message,
|
|
1597
1595
|
id: id,
|
|
1596
|
+
messageId: msg.messageId,
|
|
1598
1597
|
upvoted: false,
|
|
1599
1598
|
downvoted: false,
|
|
1600
1599
|
createdAt: getDataTime(-1),
|
|
@@ -1625,6 +1624,7 @@ var CustomerService = function(props) {
|
|
|
1625
1624
|
if (item.id == id) {
|
|
1626
1625
|
return _object_spread_props(_object_spread({}, item), {
|
|
1627
1626
|
message: message,
|
|
1627
|
+
messageId: msg.messageId,
|
|
1628
1628
|
extraInfo: extraInfo == null ? item.extraInfo : JSON.stringify(extraInfo)
|
|
1629
1629
|
});
|
|
1630
1630
|
} else {
|
|
@@ -1637,17 +1637,6 @@ var CustomerService = function(props) {
|
|
|
1637
1637
|
console.log("isPosition", isPosition.current);
|
|
1638
1638
|
scrollToBottom();
|
|
1639
1639
|
if (msg.finished) {
|
|
1640
|
-
setHistoryMessageList(function(prevHistoryMessageList) {
|
|
1641
|
-
return prevHistoryMessageList.map(function(item) {
|
|
1642
|
-
if (item.id === tempId) {
|
|
1643
|
-
return _object_spread_props(_object_spread({}, item), {
|
|
1644
|
-
id: msg.messageId
|
|
1645
|
-
});
|
|
1646
|
-
} else {
|
|
1647
|
-
return item;
|
|
1648
|
-
}
|
|
1649
|
-
});
|
|
1650
|
-
});
|
|
1651
1640
|
console.log("返回完成", msg, msgStreamingCountRef.current);
|
|
1652
1641
|
//发送结束
|
|
1653
1642
|
finishedRef.current = true;
|
|
@@ -1759,7 +1748,9 @@ var CustomerService = function(props) {
|
|
|
1759
1748
|
if (ele.message.includes("<thinking>") && !ele.message.includes("</thinking>")) {
|
|
1760
1749
|
ele.message = ele.message + "</thinking>";
|
|
1761
1750
|
}
|
|
1762
|
-
return ele
|
|
1751
|
+
return _object_spread_props(_object_spread({}, ele), {
|
|
1752
|
+
messageId: ele.id
|
|
1753
|
+
});
|
|
1763
1754
|
});
|
|
1764
1755
|
setPageCount(Math.ceil(total / maxPageSize));
|
|
1765
1756
|
setFirstItemIndex(total - maxPageSize * (page - 1));
|
|
@@ -1869,7 +1860,11 @@ var CustomerService = function(props) {
|
|
|
1869
1860
|
}).then(function(res) {
|
|
1870
1861
|
var newHistoryMessageList = [];
|
|
1871
1862
|
if (res.data.messages.length > 0) {
|
|
1872
|
-
var dataList = res.data.messages.reverse()
|
|
1863
|
+
var dataList = res.data.messages.reverse().map(function(x) {
|
|
1864
|
+
return _object_spread_props(_object_spread({}, x), {
|
|
1865
|
+
messageId: x.id
|
|
1866
|
+
});
|
|
1867
|
+
});
|
|
1873
1868
|
var originList = 0;
|
|
1874
1869
|
var newList = 0;
|
|
1875
1870
|
setHistoryMessageList(function(historyMessageList) {
|
|
@@ -1952,7 +1947,7 @@ var CustomerService = function(props) {
|
|
|
1952
1947
|
} catch (error) {}
|
|
1953
1948
|
};
|
|
1954
1949
|
//点赞消息
|
|
1955
|
-
var likeMessage = function(
|
|
1950
|
+
var likeMessage = function(messageId, state, id) {
|
|
1956
1951
|
var url = "";
|
|
1957
1952
|
//点赞状态
|
|
1958
1953
|
if (!state) {
|
|
@@ -1961,7 +1956,7 @@ var CustomerService = function(props) {
|
|
|
1961
1956
|
url = "".concat(urllocation, "/chat-service/public/v1.0/history-messages:cancelUpvote");
|
|
1962
1957
|
}
|
|
1963
1958
|
http.post(url, {
|
|
1964
|
-
messageId:
|
|
1959
|
+
messageId: messageId
|
|
1965
1960
|
}).then(function(res) {
|
|
1966
1961
|
setHistoryMessageList(function(historyMessageList) {
|
|
1967
1962
|
var list = historyMessageList;
|
|
@@ -1976,7 +1971,7 @@ var CustomerService = function(props) {
|
|
|
1976
1971
|
});
|
|
1977
1972
|
};
|
|
1978
1973
|
//踩
|
|
1979
|
-
var disagreeMessage = function(
|
|
1974
|
+
var disagreeMessage = function(messageId, state, id) {
|
|
1980
1975
|
var url = "";
|
|
1981
1976
|
//点赞状态
|
|
1982
1977
|
if (!state) {
|
|
@@ -1985,7 +1980,7 @@ var CustomerService = function(props) {
|
|
|
1985
1980
|
url = "".concat(urllocation, "/chat-service/public/v1.0/history-messages:cancelDownvote");
|
|
1986
1981
|
}
|
|
1987
1982
|
http.post(url, {
|
|
1988
|
-
messageId:
|
|
1983
|
+
messageId: messageId
|
|
1989
1984
|
}).then(function(res) {
|
|
1990
1985
|
setHistoryMessageList(function(historyMessageList) {
|
|
1991
1986
|
var list = historyMessageList;
|
|
@@ -2645,9 +2640,8 @@ var CustomerService = function(props) {
|
|
|
2645
2640
|
className: "yinyong_quote1",
|
|
2646
2641
|
onClick: function() {
|
|
2647
2642
|
// 问题的引用
|
|
2648
|
-
item.message = replaceThinkAndYaml(item.message);
|
|
2649
2643
|
setCitationContent({
|
|
2650
|
-
content: item.message,
|
|
2644
|
+
content: replaceThinkAndYaml(item.message),
|
|
2651
2645
|
id: item.id,
|
|
2652
2646
|
imageUrl: !item.quotedMessage && item.extraInfo && JSON.parse(item.extraInfo).length > 0 && JSON.parse(item.extraInfo)[0].key == "imageUrl" ? JSON.parse(item.extraInfo)[0].value : ""
|
|
2653
2647
|
});
|
|
@@ -2664,7 +2658,7 @@ var CustomerService = function(props) {
|
|
|
2664
2658
|
}) : /*#__PURE__*/ _jsx("i", {
|
|
2665
2659
|
className: "fuzhi21",
|
|
2666
2660
|
onClick: function() {
|
|
2667
|
-
var bol = copyText(item.message);
|
|
2661
|
+
var bol = copyText(replaceThinkAndYaml(item.message));
|
|
2668
2662
|
if (bol) {
|
|
2669
2663
|
var obj = copyTextOBJ;
|
|
2670
2664
|
obj = obj.filter(function(list) {
|
|
@@ -3081,11 +3075,7 @@ var CustomerService = function(props) {
|
|
|
3081
3075
|
style: {
|
|
3082
3076
|
height: "100%"
|
|
3083
3077
|
},
|
|
3084
|
-
initialTopMostItemIndex
|
|
3085
|
-
index: "LAST",
|
|
3086
|
-
align: "end",
|
|
3087
|
-
offset: showType === 3 ? 58 : showType === 4 ? 144 : 58
|
|
3088
|
-
},
|
|
3078
|
+
// initialTopMostItemIndex={!finished&&isPositionState?undefined:{ index: "LAST", align: "end",offset:showType===3?58:showType===4?144:58 }}
|
|
3089
3079
|
initialItemCount: 10,
|
|
3090
3080
|
itemsRendered: function() {
|
|
3091
3081
|
renderMermaid();
|
|
@@ -3241,9 +3231,8 @@ var CustomerService = function(props) {
|
|
|
3241
3231
|
className: "yinyong_quote1",
|
|
3242
3232
|
onClick: function() {
|
|
3243
3233
|
// 答案的引用
|
|
3244
|
-
item.message = replaceThinkAndYaml(item.message);
|
|
3245
3234
|
setCitationContent({
|
|
3246
|
-
content: item.message,
|
|
3235
|
+
content: replaceThinkAndYaml(item.message),
|
|
3247
3236
|
imageUrl: item.extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value,
|
|
3248
3237
|
id: item.id
|
|
3249
3238
|
});
|
|
@@ -3260,7 +3249,7 @@ var CustomerService = function(props) {
|
|
|
3260
3249
|
}) : /*#__PURE__*/ _jsx("i", {
|
|
3261
3250
|
className: "fuzhi21",
|
|
3262
3251
|
onClick: function() {
|
|
3263
|
-
var bol = copyText(item.message);
|
|
3252
|
+
var bol = copyText(replaceThinkAndYaml(item.message));
|
|
3264
3253
|
if (bol) {
|
|
3265
3254
|
var obj = copyTextOBJ;
|
|
3266
3255
|
obj = obj.filter(function(list) {
|
|
@@ -3286,7 +3275,7 @@ var CustomerService = function(props) {
|
|
|
3286
3275
|
/*#__PURE__*/ _jsx("i", {
|
|
3287
3276
|
className: "Frame427319094 ".concat(item.upvoted ? styles.active : ""),
|
|
3288
3277
|
onClick: function() {
|
|
3289
|
-
likeMessage(item.
|
|
3278
|
+
likeMessage(item.messageId, item.upvoted, item.id);
|
|
3290
3279
|
//老师的聊天窗口中不需要点赞和踩消息
|
|
3291
3280
|
if (!isAiChatWindow) return;
|
|
3292
3281
|
//只有最后一条回答,支持发送点赞或踩
|
|
@@ -3294,7 +3283,7 @@ var CustomerService = function(props) {
|
|
|
3294
3283
|
if (!item.extraInfo && item.sender == "AI") {
|
|
3295
3284
|
aiSendQuestions(1, {
|
|
3296
3285
|
roomId: roomId,
|
|
3297
|
-
message: "
|
|
3286
|
+
message: "\x03\x03\x03你给出的答案我非常满意,赞!\x03\x03\x03",
|
|
3298
3287
|
quotedMessage: "",
|
|
3299
3288
|
regenerate: false,
|
|
3300
3289
|
generateUpvoteOrDownvoteMessage: true
|
|
@@ -3309,7 +3298,7 @@ var CustomerService = function(props) {
|
|
|
3309
3298
|
/*#__PURE__*/ _jsx("i", {
|
|
3310
3299
|
className: "Frame427319095 ".concat(item.downvoted ? styles.active : ""),
|
|
3311
3300
|
onClick: function() {
|
|
3312
|
-
disagreeMessage(item.
|
|
3301
|
+
disagreeMessage(item.messageId, item.downvoted, item.id);
|
|
3313
3302
|
//老师的聊天窗口中不需要点赞和踩消息
|
|
3314
3303
|
if (!isAiChatWindow) return;
|
|
3315
3304
|
//只有最后一条回答,支持发送点赞或踩
|
|
@@ -3317,7 +3306,7 @@ var CustomerService = function(props) {
|
|
|
3317
3306
|
if (!item.extraInfo && item.sender == "AI") {
|
|
3318
3307
|
aiSendQuestions(1, {
|
|
3319
3308
|
roomId: roomId,
|
|
3320
|
-
message: "
|
|
3309
|
+
message: "\x03\x03\x03你给出的答案很糟糕,我不满意,踩!\x03\x03\x03",
|
|
3321
3310
|
quotedMessage: "",
|
|
3322
3311
|
regenerate: false,
|
|
3323
3312
|
generateUpvoteOrDownvoteMessage: true
|
|
@@ -3450,11 +3439,10 @@ var CustomerService = function(props) {
|
|
|
3450
3439
|
/*#__PURE__*/ _jsx("i", {
|
|
3451
3440
|
className: "yinyong_quote1",
|
|
3452
3441
|
onClick: function() {
|
|
3453
|
-
item.message = replaceThinkAndYaml(item.message);
|
|
3454
3442
|
setCitationContent({
|
|
3455
|
-
content: item.message,
|
|
3443
|
+
content: replaceThinkAndYaml(item.message),
|
|
3456
3444
|
imageUrl: item.extraInfo && JSON.parse(extraInfo).length > 0 && JSON.parse(extraInfo)[0].key == "imageUrl" && JSON.parse(extraInfo)[0].value,
|
|
3457
|
-
id: item.
|
|
3445
|
+
id: item.messageId
|
|
3458
3446
|
});
|
|
3459
3447
|
resettingBottomHei();
|
|
3460
3448
|
onEvent(serverName + serverUrl(), "click_智能问答_引用", "提交");
|
|
@@ -3469,7 +3457,7 @@ var CustomerService = function(props) {
|
|
|
3469
3457
|
}) : /*#__PURE__*/ _jsx("i", {
|
|
3470
3458
|
className: "fuzhi21",
|
|
3471
3459
|
onClick: function() {
|
|
3472
|
-
var bol = copyText(item.message);
|
|
3460
|
+
var bol = copyText(replaceThinkAndYaml(item.message));
|
|
3473
3461
|
if (bol) {
|
|
3474
3462
|
var obj = copyTextOBJ;
|
|
3475
3463
|
obj = obj.filter(function(list) {
|
|
@@ -3495,7 +3483,7 @@ var CustomerService = function(props) {
|
|
|
3495
3483
|
/*#__PURE__*/ _jsx("i", {
|
|
3496
3484
|
className: "Frame427319094 ".concat(item.upvoted ? styles.active : ""),
|
|
3497
3485
|
onClick: function() {
|
|
3498
|
-
likeMessage(item.
|
|
3486
|
+
likeMessage(item.messageId, item.upvoted, item.id);
|
|
3499
3487
|
//老师的聊天窗口中不需要点赞和踩消息
|
|
3500
3488
|
if (!isAiChatWindow) return;
|
|
3501
3489
|
//只有最后一条回答,支持发送点赞或踩
|
|
@@ -3504,7 +3492,7 @@ var CustomerService = function(props) {
|
|
|
3504
3492
|
if (!item.extraInfo && item.sender == "AI") {
|
|
3505
3493
|
aiSendQuestions(1, {
|
|
3506
3494
|
roomId: roomId,
|
|
3507
|
-
message: "
|
|
3495
|
+
message: "\x03\x03\x03你给出的答案我非常满意,赞!\x03\x03\x03",
|
|
3508
3496
|
quotedMessage: "",
|
|
3509
3497
|
regenerate: false,
|
|
3510
3498
|
generateUpvoteOrDownvoteMessage: true
|
|
@@ -3520,7 +3508,7 @@ var CustomerService = function(props) {
|
|
|
3520
3508
|
/*#__PURE__*/ _jsx("i", {
|
|
3521
3509
|
className: "Frame427319095 ".concat(item.downvoted ? styles.active : ""),
|
|
3522
3510
|
onClick: function() {
|
|
3523
|
-
disagreeMessage(item.
|
|
3511
|
+
disagreeMessage(item.messageId, item.downvoted, item.id);
|
|
3524
3512
|
//老师的聊天窗口中不需要点赞和踩消息
|
|
3525
3513
|
if (!isAiChatWindow) return;
|
|
3526
3514
|
//只有最后一条回答,支持发送点赞或踩
|
|
@@ -3531,7 +3519,7 @@ var CustomerService = function(props) {
|
|
|
3531
3519
|
//AI回答
|
|
3532
3520
|
aiSendQuestions(1, {
|
|
3533
3521
|
roomId: roomId,
|
|
3534
|
-
message: "
|
|
3522
|
+
message: "\x03\x03\x03你给出的答案很糟糕,我不满意,踩!\x03\x03\x03",
|
|
3535
3523
|
quotedMessage: "",
|
|
3536
3524
|
regenerate: false,
|
|
3537
3525
|
generateUpvoteOrDownvoteMessage: true
|