@myun/gimi-chat 0.9.71 → 0.9.73
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/apis/useApi.js +2 -2
- package/dist/components/answer-item/component/tool-list/index.d.ts +2 -1
- package/dist/components/answer-item/component/tool-list/index.js +165 -17
- package/dist/components/answer-item/component/tool-list/index.module.css +47 -0
- package/dist/components/answer-item/index.js +83 -30
- package/dist/components/chat-input/index.js +77 -22
- package/dist/components/chat-input/index.module.css +9 -4
- package/dist/components/knowledge-trace/KnowledgeIconComponent.js +10 -15
- package/dist/hooks/useChatActions.js +37 -16
- package/dist/hooks/useChatStream.js +17 -15
- package/dist/hooks/useCommonChatAPI.js +22 -7
- package/dist/i18n/locales/en-US.d.ts +2 -1
- package/dist/i18n/locales/en-US.js +2 -1
- package/dist/i18n/locales/zh-CN.d.ts +2 -1
- package/dist/i18n/locales/zh-CN.js +2 -1
- package/dist/interfaces/chatMessage.d.ts +3 -0
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -103,6 +103,12 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
103
103
|
var inputRef = React.useRef(null);
|
|
104
104
|
var isTruncatingRef = React.useRef(false);
|
|
105
105
|
var uploadFileRef = React.useRef(null);
|
|
106
|
+
// 缓存 getThinkingEffective 的结果,避免重复请求
|
|
107
|
+
var thinkingCacheRef = React.useRef({
|
|
108
|
+
agentId: null,
|
|
109
|
+
promise: null,
|
|
110
|
+
result: null
|
|
111
|
+
});
|
|
106
112
|
var conversationIdRef = React.useRef(conversationId);
|
|
107
113
|
conversationIdRef.current = conversationId;
|
|
108
114
|
var agentObjRef = React.useRef(agentObj);
|
|
@@ -138,11 +144,11 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
138
144
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
139
145
|
hasContent = _React$useState4[0],
|
|
140
146
|
setHasContent = _React$useState4[1];
|
|
141
|
-
// thinking: 1
|
|
147
|
+
// thinking: 0 置灰禁用,1 可点击
|
|
142
148
|
var _React$useState5 = React.useState(false),
|
|
143
149
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
144
|
-
|
|
145
|
-
|
|
150
|
+
deepThinkDisabled = _React$useState6[0],
|
|
151
|
+
setDeepThinkDisabled = _React$useState6[1];
|
|
146
152
|
// thinkingEnable: 1 高亮(已开启),0 默认
|
|
147
153
|
var _React$useState7 = React.useState(false),
|
|
148
154
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
@@ -177,29 +183,73 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
177
183
|
useEffect(function () {
|
|
178
184
|
var agentId = agentObj === null || agentObj === void 0 ? void 0 : agentObj.agentId;
|
|
179
185
|
if (props.hiddenDeepThink || !agentId || !(apiService !== null && apiService !== void 0 && apiService.getThinkingEffective)) {
|
|
180
|
-
|
|
186
|
+
setDeepThinkDisabled(false);
|
|
181
187
|
setDeepThinkActive(false);
|
|
182
188
|
return;
|
|
183
189
|
}
|
|
190
|
+
|
|
191
|
+
// 如果缓存中有相同 agentId 的结果,直接使用
|
|
192
|
+
if (thinkingCacheRef.current.agentId === agentId && thinkingCacheRef.current.result) {
|
|
193
|
+
var result = thinkingCacheRef.current.result;
|
|
194
|
+
setDeepThinkDisabled(result.thinking !== 1);
|
|
195
|
+
setDeepThinkActive(result.thinkingEnable === 1);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// 如果有正在进行的请求,复用该 Promise
|
|
200
|
+
if (thinkingCacheRef.current.agentId === agentId && thinkingCacheRef.current.promise) {
|
|
201
|
+
thinkingCacheRef.current.promise.then(function (result) {
|
|
202
|
+
setDeepThinkDisabled(result.thinking !== 1);
|
|
203
|
+
setDeepThinkActive(result.thinkingEnable === 1);
|
|
204
|
+
}).catch(function (e) {
|
|
205
|
+
console.error('[deepThink] getThinkingEffective error:', e);
|
|
206
|
+
setDeepThinkDisabled(false);
|
|
207
|
+
setDeepThinkActive(false);
|
|
208
|
+
});
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// 创建新请求并缓存
|
|
184
213
|
var cancelled = false;
|
|
185
|
-
apiService.getThinkingEffective(agentId).then(function (res) {
|
|
186
|
-
if (cancelled) return;
|
|
214
|
+
var promise = apiService.getThinkingEffective(agentId).then(function (res) {
|
|
215
|
+
if (cancelled) return null;
|
|
187
216
|
var result = (res === null || res === void 0 ? void 0 : res.result) || {};
|
|
188
|
-
//
|
|
189
|
-
|
|
190
|
-
|
|
217
|
+
// 缓存结果
|
|
218
|
+
thinkingCacheRef.current = {
|
|
219
|
+
agentId: agentId,
|
|
220
|
+
promise: null,
|
|
221
|
+
result: result
|
|
222
|
+
};
|
|
223
|
+
setDeepThinkDisabled(result.thinking !== 1);
|
|
191
224
|
setDeepThinkActive(result.thinkingEnable === 1);
|
|
225
|
+
return result;
|
|
192
226
|
}).catch(function (e) {
|
|
193
227
|
if (!cancelled) {
|
|
194
228
|
console.error('[deepThink] getThinkingEffective error:', e);
|
|
195
|
-
|
|
229
|
+
setDeepThinkDisabled(false);
|
|
196
230
|
setDeepThinkActive(false);
|
|
231
|
+
// 清除失败的缓存
|
|
232
|
+
if (thinkingCacheRef.current.agentId === agentId) {
|
|
233
|
+
thinkingCacheRef.current = {
|
|
234
|
+
agentId: null,
|
|
235
|
+
promise: null,
|
|
236
|
+
result: null
|
|
237
|
+
};
|
|
238
|
+
}
|
|
197
239
|
}
|
|
240
|
+
throw e;
|
|
198
241
|
});
|
|
242
|
+
|
|
243
|
+
// 缓存正在进行的请求
|
|
244
|
+
thinkingCacheRef.current = {
|
|
245
|
+
agentId: agentId,
|
|
246
|
+
promise: promise,
|
|
247
|
+
result: null
|
|
248
|
+
};
|
|
199
249
|
return function () {
|
|
200
250
|
cancelled = true;
|
|
201
251
|
};
|
|
202
|
-
}, [agentObj === null || agentObj === void 0 ? void 0 : agentObj.agentId, apiService]);
|
|
252
|
+
}, [agentObj === null || agentObj === void 0 ? void 0 : agentObj.agentId, apiService, props.hiddenDeepThink]);
|
|
203
253
|
React.useEffect(function () {
|
|
204
254
|
if (!props.defaultPrompt) {
|
|
205
255
|
setHasContent(false);
|
|
@@ -665,6 +715,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
665
715
|
// 点击切换深度思考开关
|
|
666
716
|
var handleToggleDeepThink = React.useCallback(function () {
|
|
667
717
|
var _agentObjRef$current4;
|
|
718
|
+
if (deepThinkDisabled) return; // 置灰禁用时不可点击
|
|
668
719
|
var agentId = (_agentObjRef$current4 = agentObjRef.current) === null || _agentObjRef$current4 === void 0 ? void 0 : _agentObjRef$current4.agentId;
|
|
669
720
|
if (!agentId || !(apiService !== null && apiService !== void 0 && apiService.saveThinkingEnable)) return;
|
|
670
721
|
var nextActive = !deepThinkActive;
|
|
@@ -680,14 +731,14 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
680
731
|
setDeepThinkActive(!nextActive);
|
|
681
732
|
Toast.error(t('action.failed'));
|
|
682
733
|
});
|
|
683
|
-
}, [apiService, deepThinkActive, t]);
|
|
734
|
+
}, [apiService, deepThinkActive, deepThinkDisabled, t]);
|
|
684
735
|
var renderConfigureArea = React.useCallback(function () {
|
|
685
736
|
return /*#__PURE__*/React.createElement("div", {
|
|
686
737
|
className: styles.configureArea
|
|
687
|
-
}, UploadFileTool, !props.hiddenDeepThink &&
|
|
688
|
-
content: t('chatInput.
|
|
738
|
+
}, UploadFileTool, !props.hiddenDeepThink && (deepThinkDisabled ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
739
|
+
content: t('chatInput.deepThinkNotSupported')
|
|
689
740
|
}, /*#__PURE__*/React.createElement("div", {
|
|
690
|
-
className: classNames(styles.deepthink, _defineProperty({}, styles.active, deepThinkActive)),
|
|
741
|
+
className: classNames(styles.deepthink, _defineProperty(_defineProperty({}, styles.active, deepThinkActive), styles.disabled, deepThinkDisabled)),
|
|
691
742
|
onClick: handleToggleDeepThink
|
|
692
743
|
}, /*#__PURE__*/React.createElement(IconFontCom, {
|
|
693
744
|
type: "icon-moxing",
|
|
@@ -696,14 +747,18 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
696
747
|
style: {
|
|
697
748
|
marginBottom: 2
|
|
698
749
|
}
|
|
699
|
-
}, t('chatInput.deepThinkModeAuto'))
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
750
|
+
}, t('chatInput.deepThinkModeAuto')))) : /*#__PURE__*/React.createElement("div", {
|
|
751
|
+
className: classNames(styles.deepthink, _defineProperty(_defineProperty({}, styles.active, deepThinkActive), styles.disabled, deepThinkDisabled)),
|
|
752
|
+
onClick: handleToggleDeepThink
|
|
753
|
+
}, /*#__PURE__*/React.createElement(IconFontCom, {
|
|
754
|
+
type: "icon-moxing",
|
|
755
|
+
size: 14
|
|
756
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
757
|
+
style: {
|
|
758
|
+
marginBottom: 2
|
|
704
759
|
}
|
|
705
|
-
}))), AgentContainer);
|
|
706
|
-
}, [UploadFileTool, props.hiddenDeepThink,
|
|
760
|
+
}, t('chatInput.deepThinkModeAuto')))), AgentContainer);
|
|
761
|
+
}, [UploadFileTool, props.hiddenDeepThink, deepThinkActive, deepThinkDisabled, handleToggleDeepThink, AgentContainer]);
|
|
707
762
|
var stopSSe = function stopSSe() {
|
|
708
763
|
if (uploadFileRef.current) {
|
|
709
764
|
var _uploadFileRef$curren2;
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
display: flex;
|
|
22
22
|
align-items: center;
|
|
23
23
|
justify-content: center;
|
|
24
|
+
color: var(--theme-deepNeutral, #221813);
|
|
24
25
|
cursor: pointer;
|
|
25
26
|
margin-right: 4px;
|
|
26
27
|
}
|
|
@@ -31,14 +32,18 @@
|
|
|
31
32
|
color: var(--theme-primary, #4086ff);
|
|
32
33
|
background-color: var(--theme-primary-pale, #F0F8FF);
|
|
33
34
|
}
|
|
35
|
+
.deepthink.disabled {
|
|
36
|
+
opacity: 0.5;
|
|
37
|
+
cursor: not-allowed;
|
|
38
|
+
}
|
|
39
|
+
.deepthink.disabled :hover {
|
|
40
|
+
background-color: transparent;
|
|
41
|
+
}
|
|
34
42
|
.deepthink span {
|
|
35
43
|
margin-left: 4px;
|
|
36
|
-
font-
|
|
37
|
-
font-weight: 400;
|
|
44
|
+
font-weight: 500;
|
|
38
45
|
font-size: 14px;
|
|
39
46
|
line-height: 14px;
|
|
40
|
-
text-align: right;
|
|
41
|
-
font-style: normal;
|
|
42
47
|
}
|
|
43
48
|
.deepthink .imgs {
|
|
44
49
|
display: flex;
|
|
@@ -13,7 +13,7 @@ import { knowledgeConstants } from "../../constants";
|
|
|
13
13
|
import { useAppDispatch, useAppSelector } from "../../store/hooks";
|
|
14
14
|
import React, { useMemo, useState } from 'react';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
|
-
import { Popover } from '@douyinfe/semi-ui';
|
|
16
|
+
import { Popover, Toast } from '@douyinfe/semi-ui';
|
|
17
17
|
import useKnowledgeService from "../../hooks/useKnowledgeService";
|
|
18
18
|
import VideoList from "./videoList";
|
|
19
19
|
import ClassList from "./classList";
|
|
@@ -68,13 +68,13 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
|
|
|
68
68
|
if (!list || list.length === 0) return undefined;
|
|
69
69
|
return list[list.length - 1].id;
|
|
70
70
|
});
|
|
71
|
+
var platform = useAppSelector(function (state) {
|
|
72
|
+
return state.gimiMenu.platform;
|
|
73
|
+
});
|
|
71
74
|
var isMsgRecieving = useAppSelector(function (state) {
|
|
72
75
|
return state.gimiMenu.isMsgRecieving;
|
|
73
76
|
});
|
|
74
77
|
var isLastMessage = lastMessageId !== undefined && lastMessageId === messageId;
|
|
75
|
-
var platform = useAppSelector(function (state) {
|
|
76
|
-
return state.gimiMenu.platform;
|
|
77
|
-
});
|
|
78
78
|
var iconUrl = type === 'video' ? knowledgeConstants.VIDEO_ICON_KNOWLADGE_TRACE_ADDRESS : type === 'document' ? knowledgeConstants.DOCUMENT_ICON_ADDRESS : type === "information" ? knowledgeConstants.INFORMATION_ICON_ADRESS : knowledgeConstants.CLASS_ICON_ADDRESS;
|
|
79
79
|
var kowledgeTrace = {
|
|
80
80
|
type: type,
|
|
@@ -91,6 +91,10 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
|
|
|
91
91
|
isLoading = _useKnowledgeService.isLoading;
|
|
92
92
|
var handleCurrentTrace = React.useCallback(function (trace) {
|
|
93
93
|
if (trace.isDelete === 1 || trace.isDeleted === 1) return;
|
|
94
|
+
if (platform === 'qiwei') {
|
|
95
|
+
Toast.info(t('trace.traceNotOpen'));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
94
98
|
if (type === 'video' && curPlayer) {
|
|
95
99
|
curPlayer === null || curPlayer === void 0 || curPlayer.pause();
|
|
96
100
|
}
|
|
@@ -153,7 +157,7 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
|
|
|
153
157
|
}, [isMsgRecieving, isLastMessage, dispatch, messageId, resources, type]);
|
|
154
158
|
var typeLabel = type === 'video' ? t('knowledgeTrace.type.video') : type === 'product' ? t('knowledgeTrace.type.course') : type === 'information' ? t('knowledgeTrace.type.information') : t('knowledgeTrace.type.document');
|
|
155
159
|
var unit = type === 'information' ? t('trace.unit.article') : t('trace.unit.piece');
|
|
156
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
160
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popover, {
|
|
157
161
|
content: /*#__PURE__*/React.createElement(React.Fragment, null, hoverPanelContent),
|
|
158
162
|
visible: showPanel,
|
|
159
163
|
onVisibleChange: onVisibleChange,
|
|
@@ -168,16 +172,7 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
|
|
|
168
172
|
count: resources === null || resources === void 0 ? void 0 : resources.length,
|
|
169
173
|
unit: unit,
|
|
170
174
|
type: typeLabel
|
|
171
|
-
}))))
|
|
172
|
-
className: styles.icon_btn,
|
|
173
|
-
onClick: handleIconClick
|
|
174
|
-
}, /*#__PURE__*/React.createElement(KnowledgeIcon, {
|
|
175
|
-
url: iconUrl
|
|
176
|
-
}), /*#__PURE__*/React.createElement("span", null, t('trace.countByType', {
|
|
177
|
-
count: resources === null || resources === void 0 ? void 0 : resources.length,
|
|
178
|
-
unit: unit,
|
|
179
|
-
type: typeLabel
|
|
180
|
-
}))), /*#__PURE__*/React.createElement(TryWatch, {
|
|
175
|
+
})))), /*#__PURE__*/React.createElement(TryWatch, {
|
|
181
176
|
item: curTrace,
|
|
182
177
|
type: type,
|
|
183
178
|
visible: tryWatchVisible,
|
|
@@ -190,22 +190,43 @@ var useChatActions = function useChatActions(showCopyId, inputModelRef, handleSe
|
|
|
190
190
|
*/
|
|
191
191
|
var handleClickAskList = React.useMemo(function () {
|
|
192
192
|
return debounce(function (item, operation, key, value, inputModel) {
|
|
193
|
-
var
|
|
194
|
-
var messageList = messageListRef.current;
|
|
195
|
-
if ((_messageList8 = messageList[messageList.length - 1]) !== null && _messageList8 !== void 0 && _messageList8.selectValue) {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
193
|
+
var _lastMessage$toolList;
|
|
198
194
|
var _inputModel = inputModel || _defineProperty({}, "".concat(item.id, ".").concat(operation), key);
|
|
199
|
-
|
|
200
|
-
var
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
195
|
+
var currentMessageList = messageListRef.current;
|
|
196
|
+
var lastMessage = currentMessageList[currentMessageList.length - 1];
|
|
197
|
+
|
|
198
|
+
// if (messageList[messageList.length - 1]?.selectValue) {
|
|
199
|
+
// return;
|
|
200
|
+
// }
|
|
201
|
+
console.log(item);
|
|
202
|
+
|
|
203
|
+
// 根据 operation 类型获取答案内容
|
|
204
|
+
var answerContent = '';
|
|
205
|
+
if (operation === 'click') {
|
|
206
|
+
var _item$data;
|
|
207
|
+
// 点击选项:用 key 从 askShowInfo.options 中获取选项值
|
|
208
|
+
var options = (_item$data = item.data) === null || _item$data === void 0 || (_item$data = _item$data.results) === null || _item$data === void 0 || (_item$data = _item$data.askShowInfo) === null || _item$data === void 0 ? void 0 : _item$data.options;
|
|
209
|
+
answerContent = (options === null || options === void 0 ? void 0 : options[key]) || key;
|
|
210
|
+
} else if (operation === 'input') {
|
|
211
|
+
// 输入模式:直接使用 value
|
|
212
|
+
answerContent = value || '';
|
|
213
|
+
}
|
|
214
|
+
var updatedToolList = (_lastMessage$toolList = lastMessage.toolList) === null || _lastMessage$toolList === void 0 ? void 0 : _lastMessage$toolList.map(function (tool) {
|
|
215
|
+
return tool.id === item.id ? _objectSpread(_objectSpread({}, tool), {}, {
|
|
216
|
+
moduleType: "ask",
|
|
217
|
+
status: 'COMPLETED',
|
|
218
|
+
confirmStatus: "CONFIRMED",
|
|
219
|
+
content: answerContent
|
|
220
|
+
}) : tool;
|
|
204
221
|
});
|
|
222
|
+
var updatedMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, lastMessage), {}, {
|
|
223
|
+
toolList: updatedToolList
|
|
224
|
+
})]);
|
|
205
225
|
dispatch(setMessageList({
|
|
206
|
-
messageList:
|
|
226
|
+
messageList: updatedMessageList
|
|
207
227
|
}));
|
|
208
|
-
|
|
228
|
+
inputModelRef.current = _inputModel;
|
|
229
|
+
handleSend(value || '', undefined, true, undefined, true); // skipCreateNewMessage: true 复用当前消息
|
|
209
230
|
}, 100);
|
|
210
231
|
}, [handleSend, inputModelRef, dispatch]);
|
|
211
232
|
|
|
@@ -214,11 +235,11 @@ var useChatActions = function useChatActions(showCopyId, inputModelRef, handleSe
|
|
|
214
235
|
* 绕开 ask 的 selectValue 防重逻辑,直接组装 user_confirm inputModel 发送
|
|
215
236
|
*/
|
|
216
237
|
var handleClickConfirm = React.useCallback(function (item, confirmed) {
|
|
217
|
-
var _lastMessage$
|
|
238
|
+
var _lastMessage$toolList2, _item$data2, _item$data3;
|
|
218
239
|
// 1. 更新最后一条消息的 toolList,把这条 user_confirm 改成已确认/已拒绝
|
|
219
240
|
var currentMessageList = messageListRef.current;
|
|
220
241
|
var lastMessage = currentMessageList[currentMessageList.length - 1];
|
|
221
|
-
var updatedToolList = (_lastMessage$
|
|
242
|
+
var updatedToolList = (_lastMessage$toolList2 = lastMessage.toolList) === null || _lastMessage$toolList2 === void 0 ? void 0 : _lastMessage$toolList2.map(function (tool) {
|
|
222
243
|
return tool.id === item.id ? _objectSpread(_objectSpread({}, tool), {}, {
|
|
223
244
|
moduleType: "user_confirm",
|
|
224
245
|
status: 'COMPLETED',
|
|
@@ -235,9 +256,9 @@ var useChatActions = function useChatActions(showCopyId, inputModelRef, handleSe
|
|
|
235
256
|
// 2. 组装 inputModel 并发送
|
|
236
257
|
var inputModel = {
|
|
237
258
|
user_confirm: {
|
|
238
|
-
askingEventId: (_item$
|
|
259
|
+
askingEventId: (_item$data2 = item.data) === null || _item$data2 === void 0 ? void 0 : _item$data2.askingEventId,
|
|
239
260
|
confirmResults: [{
|
|
240
|
-
toolCallId: ((_item$
|
|
261
|
+
toolCallId: ((_item$data3 = item.data) === null || _item$data3 === void 0 || (_item$data3 = _item$data3.toolCalls) === null || _item$data3 === void 0 || (_item$data3 = _item$data3[0]) === null || _item$data3 === void 0 ? void 0 : _item$data3.id) || '',
|
|
241
262
|
confirmed: confirmed
|
|
242
263
|
}]
|
|
243
264
|
}
|
|
@@ -40,7 +40,7 @@ export var MODULE_TYPE_NAMES = {
|
|
|
40
40
|
'summary': '章节总结节点',
|
|
41
41
|
'loop': '循环节点',
|
|
42
42
|
'skill': '技能节点',
|
|
43
|
-
'skillBase': '
|
|
43
|
+
'skillBase': '技能',
|
|
44
44
|
'break': '终止循环节点',
|
|
45
45
|
'http': 'HTTP节点',
|
|
46
46
|
'esKnowledge': '知识库节点',
|
|
@@ -54,11 +54,6 @@ var NODE_STATUS_TEXTS = {
|
|
|
54
54
|
'RUNNING': '正在理解问题',
|
|
55
55
|
'COMPLETED': '已完成理解问题'
|
|
56
56
|
},
|
|
57
|
-
'llm': {
|
|
58
|
-
'STARTED': '开始分析问题',
|
|
59
|
-
'RUNNING': '正在分析问题',
|
|
60
|
-
'COMPLETED': '已完成分析'
|
|
61
|
-
},
|
|
62
57
|
'thinking': {
|
|
63
58
|
'STARTED': '开始分析问题',
|
|
64
59
|
'RUNNING': '正在分析问题',
|
|
@@ -75,9 +70,14 @@ var NODE_STATUS_TEXTS = {
|
|
|
75
70
|
'COMPLETED': '已调用知识库检索'
|
|
76
71
|
},
|
|
77
72
|
"mcp": {
|
|
78
|
-
'STARTED': '
|
|
79
|
-
'RUNNING': '
|
|
80
|
-
'COMPLETED': '
|
|
73
|
+
'STARTED': '开始调用技能',
|
|
74
|
+
'RUNNING': '正在调用技能',
|
|
75
|
+
'COMPLETED': '已调用技能'
|
|
76
|
+
},
|
|
77
|
+
"skillBase": {
|
|
78
|
+
'STARTED': '开始调用技能',
|
|
79
|
+
'RUNNING': '正在调用技能',
|
|
80
|
+
'COMPLETED': '已调用技能'
|
|
81
81
|
},
|
|
82
82
|
"http": {
|
|
83
83
|
'STARTED': '开始调用处理数据',
|
|
@@ -110,9 +110,14 @@ var NODE_STATUS_TEXTS = {
|
|
|
110
110
|
'COMPLETED': '已处理任务'
|
|
111
111
|
},
|
|
112
112
|
"text": {
|
|
113
|
-
'STARTED': '
|
|
114
|
-
'RUNNING': '
|
|
115
|
-
'COMPLETED': '
|
|
113
|
+
'STARTED': '开始调用处理数据',
|
|
114
|
+
'RUNNING': '正在调用处理数据',
|
|
115
|
+
'COMPLETED': '已调用处理数据'
|
|
116
|
+
},
|
|
117
|
+
"llm": {
|
|
118
|
+
'STARTED': '开始分析问题',
|
|
119
|
+
'RUNNING': '正在分析问题',
|
|
120
|
+
'COMPLETED': '已完成分析'
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
// 其他节点可继续添加自定义文案
|
|
@@ -300,13 +305,10 @@ export var useChatStream = function useChatStream(platform) {
|
|
|
300
305
|
if (_dataObj.moduleType === 'artifact' && _dataObj.status === 'COMPLETED') {
|
|
301
306
|
onArtifactStream === null || onArtifactStream === void 0 || onArtifactStream(_dataObj);
|
|
302
307
|
}
|
|
303
|
-
|
|
304
|
-
// 问答确认
|
|
305
308
|
if ((_dataObj.moduleType === 'ask' || _dataObj.moduleType === 'skill') && _dataObj.status === 'PENDING') {
|
|
306
309
|
onComplete === null || onComplete === void 0 || onComplete(_dataObj, _dataObj.moduleType);
|
|
307
310
|
return;
|
|
308
311
|
}
|
|
309
|
-
// 确认模式
|
|
310
312
|
if (_dataObj.moduleType === 'user_confirm' && _dataObj.status === 'ASKING') {
|
|
311
313
|
onComplete === null || onComplete === void 0 || onComplete(_dataObj, _dataObj.moduleType);
|
|
312
314
|
return;
|
|
@@ -355,22 +355,37 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
355
355
|
}));
|
|
356
356
|
}, [dispatch]);
|
|
357
357
|
var handleToolStreamRs = React.useCallback(function (dataObj) {
|
|
358
|
+
var _curToolList$curToolI;
|
|
358
359
|
// 只处理工作流模式下的 tool_result,其他情况暂不处理
|
|
359
360
|
if (dataObj.moduleType === 'tool_result' && dataObj.name !== 'executeWorkflow') return;
|
|
360
361
|
setStatus(2);
|
|
362
|
+
// 特殊逻辑,将开始节点处理成 agent 类型,保持只有一个 agent 节点
|
|
363
|
+
if (dataObj.moduleType === 'start') {
|
|
364
|
+
dataObj.moduleType = 'agent';
|
|
365
|
+
}
|
|
366
|
+
;
|
|
361
367
|
var messageList = messageListRef.current;
|
|
362
368
|
var lastMessage = messageList[messageList.length - 1];
|
|
363
369
|
var curToolList = _toConsumableArray((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.toolList) || []);
|
|
364
370
|
var curToolIndex = curToolList.findIndex(function (item) {
|
|
365
371
|
return (item === null || item === void 0 ? void 0 : item.id) === dataObj.id;
|
|
366
372
|
});
|
|
367
|
-
|
|
373
|
+
// 记录当前思考内容
|
|
374
|
+
var curContent = ((_curToolList$curToolI = curToolList[curToolIndex]) === null || _curToolList$curToolI === void 0 ? void 0 : _curToolList$curToolI.content) || '';
|
|
375
|
+
if (dataObj.moduleType === 'thinking') {
|
|
376
|
+
curContent = curContent + (dataObj.reasoningContent || '');
|
|
377
|
+
} else if (dataObj.moduleType === 'llm') {
|
|
378
|
+
var _dataObj$outputs;
|
|
379
|
+
curContent = curContent + ((dataObj === null || dataObj === void 0 || (_dataObj$outputs = dataObj.outputs) === null || _dataObj$outputs === void 0 || (_dataObj$outputs = _dataObj$outputs.result) === null || _dataObj$outputs === void 0 ? void 0 : _dataObj$outputs.reasoning_content) || '');
|
|
380
|
+
} else {
|
|
381
|
+
curContent = curContent + (dataObj.content || '');
|
|
382
|
+
}
|
|
368
383
|
// 为新节点类型根据 status 生成 toolName
|
|
369
384
|
var isNewNodeType = !['tool_invocation', 'tool_result', "agent"].includes(dataObj.moduleType);
|
|
370
385
|
var toolName = isNewNodeType ? getToolNameByStatus(dataObj.moduleType, dataObj.status) : dataObj.toolName;
|
|
371
386
|
if (curToolIndex >= 0) {
|
|
372
387
|
curToolList[curToolIndex] = _objectSpread(_objectSpread({}, curToolList[curToolIndex]), {}, {
|
|
373
|
-
content:
|
|
388
|
+
content: curContent,
|
|
374
389
|
// tool_invocation 更新 toolName 和 status,新节点类型也更新
|
|
375
390
|
toolName: dataObj.moduleType === 'tool_invocation' ? dataObj.toolName || '' : isNewNodeType ? toolName : curToolList[curToolIndex].toolName,
|
|
376
391
|
status: dataObj.moduleType === 'tool_invocation' || isNewNodeType ? dataObj.status : curToolList[curToolIndex].status
|
|
@@ -379,9 +394,9 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
379
394
|
// 新增工具时,为新节点类型补充 toolName
|
|
380
395
|
// agent 类类型,保持只有一个 agent
|
|
381
396
|
// tool_result只是工具的结果,不能新增
|
|
382
|
-
if (dataObj.moduleType
|
|
397
|
+
if (['agent'].includes(dataObj.moduleType) && curToolList.length > 0 || dataObj.moduleType === 'tool_result') return;
|
|
383
398
|
curToolList = curToolList.filter(function (tool) {
|
|
384
|
-
return tool.moduleType
|
|
399
|
+
return !['agent'].includes(tool.moduleType);
|
|
385
400
|
});
|
|
386
401
|
curToolList = [].concat(_toConsumableArray(curToolList), [_objectSpread(_objectSpread({}, dataObj), {}, {
|
|
387
402
|
toolName: toolName || dataObj.toolName
|
|
@@ -566,7 +581,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
566
581
|
currentMessageList = messageListRef.current;
|
|
567
582
|
lastToolList = _toConsumableArray(currentMessageList[currentMessageList.length - 1].toolList || []);
|
|
568
583
|
newMessageList = [];
|
|
569
|
-
if (type === 'user_confirm') {
|
|
584
|
+
if (type === 'user_confirm' || type === 'ask') {
|
|
570
585
|
newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, {
|
|
571
586
|
moduleType: type,
|
|
572
587
|
moduleInfo: Response,
|
|
@@ -583,11 +598,11 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
583
598
|
toolList: [].concat(_toConsumableArray(lastToolList), [{
|
|
584
599
|
moduleType: type,
|
|
585
600
|
content: '',
|
|
586
|
-
data: Response,
|
|
601
|
+
data: type === 'ask' ? Response.data : Response,
|
|
587
602
|
status: "RUNNING",
|
|
588
603
|
toolName: t('chatApi.waitingForConfirmation'),
|
|
589
604
|
confirmStatus: "PENDING",
|
|
590
|
-
id: "".concat(new Date().getTime())
|
|
605
|
+
id: Response.id || "".concat(new Date().getTime())
|
|
591
606
|
}])
|
|
592
607
|
})]);
|
|
593
608
|
} else {
|
|
@@ -18,7 +18,7 @@ declare const enUS: {
|
|
|
18
18
|
'chatInput.flowUnsupported': string;
|
|
19
19
|
'chatInput.uploadFile': string;
|
|
20
20
|
'chatInput.newConversation': string;
|
|
21
|
-
'chatInput.
|
|
21
|
+
'chatInput.deepThinkNotSupported': string;
|
|
22
22
|
'chatInput.deepThinkModeAuto': string;
|
|
23
23
|
'chatInput.fetchingVoice': string;
|
|
24
24
|
'chatInput.voiceCallUnsupported': string;
|
|
@@ -62,6 +62,7 @@ declare const enUS: {
|
|
|
62
62
|
'trace.tryFullTipsNoEntitlement': string;
|
|
63
63
|
'trace.tryFull': string;
|
|
64
64
|
'trace.iconAlt': string;
|
|
65
|
+
'trace.traceNotOpen': string;
|
|
65
66
|
'trace.countByType': string;
|
|
66
67
|
'file.totalInConversation': string;
|
|
67
68
|
'file.download': string;
|
|
@@ -18,7 +18,7 @@ var enUS = {
|
|
|
18
18
|
'chatInput.flowUnsupported': 'This button is not supported in the current flow. Please wait for the current flow to finish or follow the instructions on the chat card.',
|
|
19
19
|
'chatInput.uploadFile': 'Supports Word, Excel,and Images.\nUp to 10 files (max 10MB each)',
|
|
20
20
|
'chatInput.newConversation': 'New conversation',
|
|
21
|
-
'chatInput.
|
|
21
|
+
'chatInput.deepThinkNotSupported': 'Deep thinking is not supported for this agent',
|
|
22
22
|
'chatInput.deepThinkModeAuto': 'Deep Thinking',
|
|
23
23
|
'chatInput.fetchingVoice': 'Capturing Voice Input...',
|
|
24
24
|
'chatInput.voiceCallUnsupported': 'Voice call is not supported in the current flow',
|
|
@@ -62,6 +62,7 @@ var enUS = {
|
|
|
62
62
|
'trace.tryFullTipsNoEntitlement': 'No viewing rights. Please upgrade to Class A or reach out to your admin/instructor.',
|
|
63
63
|
'trace.tryFull': 'View',
|
|
64
64
|
'trace.iconAlt': 'Knowledge source icon',
|
|
65
|
+
'trace.traceNotOpen': 'Please open in a browser',
|
|
65
66
|
'trace.countByType': '{{count}} {{type}}',
|
|
66
67
|
'file.totalInConversation': '{{count}} documents in this conversation',
|
|
67
68
|
'file.download': 'Download',
|
|
@@ -18,7 +18,7 @@ declare const zhCN: {
|
|
|
18
18
|
'chatInput.flowUnsupported': string;
|
|
19
19
|
'chatInput.uploadFile': string;
|
|
20
20
|
'chatInput.newConversation': string;
|
|
21
|
-
'chatInput.
|
|
21
|
+
'chatInput.deepThinkNotSupported': string;
|
|
22
22
|
'chatInput.deepThinkModeAuto': string;
|
|
23
23
|
'chatInput.fetchingVoice': string;
|
|
24
24
|
'chatInput.voiceCallUnsupported': string;
|
|
@@ -62,6 +62,7 @@ declare const zhCN: {
|
|
|
62
62
|
'trace.tryFullTipsNoEntitlement': string;
|
|
63
63
|
'trace.tryFull': string;
|
|
64
64
|
'trace.iconAlt': string;
|
|
65
|
+
'trace.traceNotOpen': string;
|
|
65
66
|
'trace.countByType': string;
|
|
66
67
|
'trace.unit.piece': string;
|
|
67
68
|
'trace.unit.article': string;
|
|
@@ -18,7 +18,7 @@ var zhCN = {
|
|
|
18
18
|
'chatInput.flowUnsupported': '当前流程不支持该按钮的使用,请等待正在进行的流程结束或按对话卡片指示继续流程',
|
|
19
19
|
'chatInput.uploadFile': '支持Word、Excel、图片\n最多10个文件(单个不超过10M)',
|
|
20
20
|
'chatInput.newConversation': '新对话',
|
|
21
|
-
'chatInput.
|
|
21
|
+
'chatInput.deepThinkNotSupported': '当前智能体不支持深度思考',
|
|
22
22
|
'chatInput.deepThinkModeAuto': '深度思考',
|
|
23
23
|
'chatInput.fetchingVoice': '正在获取语音内容...',
|
|
24
24
|
'chatInput.voiceCallUnsupported': '当前流程不支持语音通话',
|
|
@@ -62,6 +62,7 @@ var zhCN = {
|
|
|
62
62
|
'trace.tryFullTipsNoEntitlement': '您的账号暂无查看权益,查看完整内容需升级A类权益账号,可联系企业管理员或课程顾问进行沟通调整。',
|
|
63
63
|
'trace.tryFull': '查看',
|
|
64
64
|
'trace.iconAlt': '知识库溯源图标',
|
|
65
|
+
'trace.traceNotOpen': '请用浏览器打开',
|
|
65
66
|
'trace.countByType': '{{count}}{{unit}}{{type}}',
|
|
66
67
|
'trace.unit.piece': '个',
|
|
67
68
|
'trace.unit.article': '篇',
|
|
@@ -13,6 +13,8 @@ export interface ToolItem {
|
|
|
13
13
|
id?: string;
|
|
14
14
|
/** 工具调用内容 */
|
|
15
15
|
content?: string;
|
|
16
|
+
/** 工具调用推理内容 */
|
|
17
|
+
reasoningContent?: string;
|
|
16
18
|
/** 工具调用数据 */
|
|
17
19
|
data?: any;
|
|
18
20
|
/** 确认状态
|
|
@@ -22,6 +24,7 @@ export interface ToolItem {
|
|
|
22
24
|
* PARTIAL:部分同意;
|
|
23
25
|
*/
|
|
24
26
|
confirmStatus?: "PENDING" | "CONFIRMED" | "REJECTED" | "PARTIAL";
|
|
27
|
+
workflowAskResult?: any;
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
30
|
* 聊天消息主接口
|