@myun/gimi-chat 0.2.8 → 0.3.0
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/client/core/index.css +0 -3
- package/dist/components/chat-input/index.js +11 -1
- package/dist/components/preset-agent-content/index.d.ts +1 -1
- package/dist/components/preset-agent-content/index.js +2 -2
- package/dist/components/quoted-content/index.js +3 -1
- package/dist/components/quoted-content/index.module.css +18 -3
- package/dist/components/templates/CommonChat.js +4 -8
- package/dist/hooks/useCommonChatAPI.js +3 -2
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
display: flex;
|
|
9
9
|
flex-direction: column;
|
|
10
10
|
}
|
|
11
|
-
.chat-sdk-container .chat-sdk-container-main .chat-sdk-container-main-content {
|
|
12
|
-
padding: 20px;
|
|
13
|
-
}
|
|
14
11
|
.chat-sdk-container .chat-sdk-container-main .chat-sdk-container-main-content.new-conversation {
|
|
15
12
|
height: 160px;
|
|
16
13
|
}
|
|
@@ -400,6 +400,15 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
400
400
|
}));
|
|
401
401
|
(_props$onHistoryReloa = props.onHistoryReload) === null || _props$onHistoryReloa === void 0 || _props$onHistoryReloa.call(props);
|
|
402
402
|
};
|
|
403
|
+
var handleInterrupt = function handleInterrupt() {
|
|
404
|
+
var _props$onInterrupt;
|
|
405
|
+
var latestMessage = messageList[messageList.length - 1];
|
|
406
|
+
// 如果模型没有返回或正处于工作流调用阶段,不允许打断
|
|
407
|
+
if (latestMessage.role === 1 && (!latestMessage.content && !latestMessage.reasoningContent || latestMessage.mcp)) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
(_props$onInterrupt = props.onInterrupt) === null || _props$onInterrupt === void 0 || _props$onInterrupt.call(props);
|
|
411
|
+
};
|
|
403
412
|
var defaultContent = transformToInputSlots(props.defaultPrompt || '', props.titleSlot || '');
|
|
404
413
|
var uniqueKey = "".concat(props.placeholder, "-").concat(defaultContent);
|
|
405
414
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -414,6 +423,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
414
423
|
// 为了当 props 变化时,重新渲染 AIChatInput
|
|
415
424
|
,
|
|
416
425
|
key: uniqueKey,
|
|
426
|
+
disabled: props.disabled,
|
|
417
427
|
className: styles.chatInput,
|
|
418
428
|
placeholder: props.placeholder || '',
|
|
419
429
|
references: [{
|
|
@@ -431,7 +441,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
431
441
|
// 自定义引用区域
|
|
432
442
|
,
|
|
433
443
|
renderReference: renderReference,
|
|
434
|
-
onStopGenerate:
|
|
444
|
+
onStopGenerate: handleInterrupt
|
|
435
445
|
// 上传文件配置开始
|
|
436
446
|
,
|
|
437
447
|
showUploadButton: false,
|
|
@@ -3,7 +3,7 @@ import styles from "./index.module.css";
|
|
|
3
3
|
var PresetAgentContent = function PresetAgentContent(_ref) {
|
|
4
4
|
var prologue = _ref.prologue,
|
|
5
5
|
questionList = _ref.questionList,
|
|
6
|
-
|
|
6
|
+
onQuickSend = _ref.onQuickSend,
|
|
7
7
|
layout = _ref.layout;
|
|
8
8
|
var rowListStyle = {
|
|
9
9
|
flexDirection: 'row',
|
|
@@ -27,7 +27,7 @@ var PresetAgentContent = function PresetAgentContent(_ref) {
|
|
|
27
27
|
className: styles.quickInputItem,
|
|
28
28
|
key: index,
|
|
29
29
|
onClick: function onClick() {
|
|
30
|
-
return
|
|
30
|
+
return onQuickSend(item.question);
|
|
31
31
|
}
|
|
32
32
|
}, item.question);
|
|
33
33
|
})));
|
|
@@ -81,7 +81,9 @@ var QuotedContent = function QuotedContent() {
|
|
|
81
81
|
alt: "\u8D44\u6599\u5F15\u7528\u56FE\u7247",
|
|
82
82
|
className: styles.img,
|
|
83
83
|
src: activeKey === 'video' ? knowledgeConstants.VIDEO_ICON_ADDRESS : knowledgeConstants.CLASS_ICON_BIG_ADDRESS
|
|
84
|
-
}),
|
|
84
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
85
|
+
className: styles.text
|
|
86
|
+
}, text));
|
|
85
87
|
}
|
|
86
88
|
}];
|
|
87
89
|
var handleClose = useCallback(function () {
|
|
@@ -46,20 +46,35 @@
|
|
|
46
46
|
overflow: auto;
|
|
47
47
|
height: 200px;
|
|
48
48
|
}
|
|
49
|
-
.tabContent .table
|
|
50
|
-
|
|
49
|
+
.tabContent .table {
|
|
50
|
+
table-layout: fixed;
|
|
51
|
+
}
|
|
52
|
+
.tabContent .table :global(.semi-table-row-cell) span {
|
|
53
|
+
width: 270px;
|
|
51
54
|
}
|
|
52
|
-
.tabContent .table :global(.
|
|
55
|
+
.tabContent .table :global(.semi-table-row-cell) {
|
|
56
|
+
font-size: 12px;
|
|
53
57
|
border: none !important;
|
|
58
|
+
white-space: nowrap;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
text-overflow: ellipsis;
|
|
54
61
|
}
|
|
55
62
|
.tabContent .table .listItem {
|
|
56
63
|
display: flex;
|
|
57
64
|
align-items: center;
|
|
58
65
|
cursor: pointer;
|
|
66
|
+
width: 100%;
|
|
59
67
|
}
|
|
60
68
|
.tabContent .table .listItem .img {
|
|
61
69
|
width: 16px;
|
|
62
70
|
margin-right: 5px;
|
|
71
|
+
flex-shrink: 0;
|
|
72
|
+
}
|
|
73
|
+
.tabContent .table .listItem .text {
|
|
74
|
+
flex: 1;
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
text-overflow: ellipsis;
|
|
77
|
+
white-space: nowrap;
|
|
63
78
|
}
|
|
64
79
|
|
|
65
80
|
.tabContent::-webkit-scrollbar {
|
|
@@ -140,13 +140,9 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
140
140
|
hasMore.current = true;
|
|
141
141
|
getContentMessageList(1, 10);
|
|
142
142
|
};
|
|
143
|
-
var setInputValue = React.useCallback(function (content) {
|
|
144
|
-
var _chatInputRef$current;
|
|
145
|
-
(_chatInputRef$current = chatInputRef.current) === null || _chatInputRef$current === void 0 || _chatInputRef$current.setValue(content);
|
|
146
|
-
}, []);
|
|
147
143
|
var handleInputSend = React.useCallback(function (val, agent, isSystemAuto) {
|
|
148
|
-
var _chatInputRef$
|
|
149
|
-
(_chatInputRef$
|
|
144
|
+
var _chatInputRef$current;
|
|
145
|
+
(_chatInputRef$current = chatInputRef.current) === null || _chatInputRef$current === void 0 || _chatInputRef$current.setValue('');
|
|
150
146
|
var conversationId = store.getState().gimiMenu.conversationId;
|
|
151
147
|
if (!conversationId) {
|
|
152
148
|
startConversationAndChat(val);
|
|
@@ -174,7 +170,7 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
174
170
|
}, showPrologue && messageList.length === 0 && !isMoreLoading && quickQuestionListPosition === 'top' && /*#__PURE__*/React.createElement(PresetAgentContent, {
|
|
175
171
|
prologue: (agentObj === null || agentObj === void 0 ? void 0 : agentObj.prologue) || '',
|
|
176
172
|
questionList: (agentObj === null || agentObj === void 0 ? void 0 : agentObj.questionList) || [],
|
|
177
|
-
|
|
173
|
+
onQuickSend: handleInputSend,
|
|
178
174
|
layout: 'vertical'
|
|
179
175
|
}), isMoreLoading ? /*#__PURE__*/React.createElement("div", {
|
|
180
176
|
style: {
|
|
@@ -223,7 +219,7 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
223
219
|
}, chatInputConfig)), showPrologue && messageList.length === 0 && !isMoreLoading && quickQuestionListPosition === 'bottom' && /*#__PURE__*/React.createElement(PresetAgentContent, {
|
|
224
220
|
prologue: '',
|
|
225
221
|
questionList: (agentObj === null || agentObj === void 0 ? void 0 : agentObj.questionList) || [],
|
|
226
|
-
|
|
222
|
+
onQuickSend: handleInputSend,
|
|
227
223
|
layout: 'horizontal'
|
|
228
224
|
})), /*#__PURE__*/React.createElement(KonwledgeTrace, _extends({}, props.sidebarConfig, {
|
|
229
225
|
chatList: messageList || defaultMessages,
|
|
@@ -130,7 +130,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
|
|
|
130
130
|
var agentObjRef = useRef(agentObj || null);
|
|
131
131
|
var isMsgRecievingRef = useRef(isMsgRecieving);
|
|
132
132
|
var fileListRef = useRef(fileList || []);
|
|
133
|
-
var conversationIdRef = useRef(conversationId
|
|
133
|
+
var conversationIdRef = useRef(conversationId);
|
|
134
134
|
var bussinessParamsRef = useRef(bussinessParams || {});
|
|
135
135
|
var quoteProductListRef = useRef(quoteProductList || []);
|
|
136
136
|
var quoteTeachModelListRef = useRef(quoteTeachModelList || []);
|
|
@@ -322,6 +322,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
|
|
|
322
322
|
stopStreamOut({
|
|
323
323
|
messageId: "".concat(messageList[messageList.length - 1].chatId)
|
|
324
324
|
});
|
|
325
|
+
setIgnoreOnMessage(true);
|
|
325
326
|
removeLastEventId("".concat(messageList[messageList.length - 1].chatId));
|
|
326
327
|
if (valueRef.current) {
|
|
327
328
|
setStatus(1);
|
|
@@ -331,7 +332,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
|
|
|
331
332
|
setMsgLoading(false);
|
|
332
333
|
step.current = 0; // 重置步骤状态
|
|
333
334
|
onSendEnd === null || onSendEnd === void 0 || onSendEnd(messageList[messageList.length - 1]);
|
|
334
|
-
case
|
|
335
|
+
case 18:
|
|
335
336
|
case "end":
|
|
336
337
|
return _context3.stop();
|
|
337
338
|
}
|