@myun/gimi-chat 0.9.49 → 0.9.51
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/components/answer-item/index.js +9 -6
- package/dist/components/answer-item/index.module.css +5 -0
- package/dist/components/chat-input/extension/skill/index.less +2 -1
- package/dist/components/chat-input/extension/skill/suggestion.d.ts +1 -0
- package/dist/components/chat-input/extension/skill/suggestion.js +17 -11
- package/dist/components/chat-input/index.js +12 -5
- package/dist/hooks/useCommonChatAPI.js +4 -2
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -238,13 +238,16 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
238
238
|
data = JSON.parse(item.eventData || '{}');
|
|
239
239
|
} catch (error) {}
|
|
240
240
|
if ([].concat(_toConsumableArray(TOOL_MODULE_TYPES), ["user_confirm", "stream"]).includes(item.moduleType) && !["execute", "notifyWorkflowStart"].includes((_data = data) === null || _data === void 0 ? void 0 : _data.name)) {
|
|
241
|
-
var _data2;
|
|
241
|
+
var _data2, _data3;
|
|
242
|
+
// 只处理工作流模式下的 tool_result,其他情况暂不处理
|
|
243
|
+
if (data.moduleType === 'tool_result' && ((_data2 = data) === null || _data2 === void 0 ? void 0 : _data2.name) !== 'executeWorkflow') return;
|
|
244
|
+
|
|
242
245
|
// 为新节点类型根据 status 生成 toolName
|
|
243
246
|
var isNewNodeType = !['tool_invocation', 'tool_result', "user_confirm"].includes(item.moduleType);
|
|
244
|
-
var toolName = isNewNodeType ? getToolNameByStatus(item.moduleType, 'COMPLETED') : (
|
|
247
|
+
var toolName = isNewNodeType ? getToolNameByStatus(item.moduleType, 'COMPLETED') : (_data3 = data) === null || _data3 === void 0 ? void 0 : _data3.toolName;
|
|
245
248
|
var index = toolList.findIndex(function (v) {
|
|
246
|
-
var
|
|
247
|
-
return v.id === ((
|
|
249
|
+
var _data4;
|
|
250
|
+
return v.id === ((_data4 = data) === null || _data4 === void 0 ? void 0 : _data4.id);
|
|
248
251
|
});
|
|
249
252
|
if (index < 0) {
|
|
250
253
|
toolList.push(_objectSpread(_objectSpread({}, data), {}, {
|
|
@@ -345,7 +348,7 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
345
348
|
artifacts: item.artifacts
|
|
346
349
|
}), showOperation && /*#__PURE__*/React.createElement("div", {
|
|
347
350
|
className: styles.opera
|
|
348
|
-
}, (showOpera === null || showOpera === void 0 ? void 0 : showOpera(item.id)) && !item.loading && /*#__PURE__*/React.createElement("div", {
|
|
351
|
+
}, (showOpera === null || showOpera === void 0 ? void 0 : showOpera(item.id)) && !item.loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
349
352
|
className: styles.opera_item
|
|
350
353
|
}, enableCopy && /*#__PURE__*/React.createElement(CopyButton, {
|
|
351
354
|
item: item,
|
|
@@ -366,7 +369,7 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
366
369
|
onRegenerateClick: onRegenerateClick
|
|
367
370
|
})), /*#__PURE__*/React.createElement("div", {
|
|
368
371
|
className: styles.totalTokensWrap
|
|
369
|
-
}, item !== null && item !== void 0 && item.durationMs ? formatDurationMs(item.durationMs) : '', " ", platform === 'preview' && item.totalTokens ? " | ".concat(item.totalTokens, " Tokens") : '')), (item.relatedResourceList || []).length > 0 && (showCommend === null || showCommend === void 0 ? void 0 : showCommend(item.id)) && /*#__PURE__*/React.createElement("div", {
|
|
372
|
+
}, item !== null && item !== void 0 && item.durationMs ? formatDurationMs(item.durationMs) : '', " ", platform === 'preview' && item.totalTokens ? " | ".concat(item.totalTokens, " Tokens") : ''))), (item.relatedResourceList || []).length > 0 && (showCommend === null || showCommend === void 0 ? void 0 : showCommend(item.id)) && /*#__PURE__*/React.createElement("div", {
|
|
370
373
|
className: styles.quickInputList
|
|
371
374
|
}, (item.relatedResourceList || []).map(function (item, index) {
|
|
372
375
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -292,6 +292,11 @@
|
|
|
292
292
|
:global(.markdown_container) {
|
|
293
293
|
max-width: 800px;
|
|
294
294
|
}
|
|
295
|
+
:global(.markdown_container) img {
|
|
296
|
+
max-width: 200px;
|
|
297
|
+
max-height: 200px;
|
|
298
|
+
border-radius: 16px;
|
|
299
|
+
}
|
|
295
300
|
@media (min-width: 1920px) {
|
|
296
301
|
:global(.markdown_container) {
|
|
297
302
|
max-width: 1000px;
|
|
@@ -7,6 +7,7 @@ export interface SkillCommandProps {
|
|
|
7
7
|
declare let skillContext: {
|
|
8
8
|
getAgentId?: () => number | undefined;
|
|
9
9
|
getApiService?: () => IUseApi | null;
|
|
10
|
+
getSkillDisplay?: () => number | undefined;
|
|
10
11
|
};
|
|
11
12
|
export declare const setSkillContext: (ctx: Partial<typeof skillContext>) => void;
|
|
12
13
|
export declare const suggestion: any;
|
|
@@ -20,6 +20,7 @@ var PANEL_GAP = 0;
|
|
|
20
20
|
// 若下方空间不足则翻转到输入框上方显示。
|
|
21
21
|
var positionPanel = function positionPanel(editor, element) {
|
|
22
22
|
var _editor$view;
|
|
23
|
+
if (!element) return null;
|
|
23
24
|
var triggerEl = editor === null || editor === void 0 || (_editor$view = editor.view) === null || _editor$view === void 0 || (_editor$view = _editor$view.dom) === null || _editor$view === void 0 ? void 0 : _editor$view.closest('.semi-aiChatInput');
|
|
24
25
|
if (!triggerEl) return null;
|
|
25
26
|
var rect = triggerEl.getBoundingClientRect();
|
|
@@ -101,11 +102,16 @@ export var suggestion = {
|
|
|
101
102
|
var reposition = null;
|
|
102
103
|
return {
|
|
103
104
|
onStart: function onStart(props) {
|
|
105
|
+
var _skillContext$getSkil, _skillContext;
|
|
104
106
|
console.log('[skill] onStart triggered, query=', props.query);
|
|
107
|
+
// 当前智能体未开启技能(skillDisplay !== 1)时不弹出技能选择面板
|
|
108
|
+
if (((_skillContext$getSkil = (_skillContext = skillContext).getSkillDisplay) === null || _skillContext$getSkil === void 0 ? void 0 : _skillContext$getSkil.call(_skillContext)) !== 1) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
105
111
|
try {
|
|
106
|
-
var _skillContext$getAgen,
|
|
107
|
-
var agentId = (_skillContext$getAgen = (
|
|
108
|
-
var apiService = (_skillContext$getApiS = (_skillContext$getApiS2 = (
|
|
112
|
+
var _skillContext$getAgen, _skillContext2, _skillContext$getApiS, _skillContext$getApiS2, _skillContext3;
|
|
113
|
+
var agentId = (_skillContext$getAgen = (_skillContext2 = skillContext).getAgentId) === null || _skillContext$getAgen === void 0 ? void 0 : _skillContext$getAgen.call(_skillContext2);
|
|
114
|
+
var apiService = (_skillContext$getApiS = (_skillContext$getApiS2 = (_skillContext3 = skillContext).getApiService) === null || _skillContext$getApiS2 === void 0 ? void 0 : _skillContext$getApiS2.call(_skillContext3)) !== null && _skillContext$getApiS !== void 0 ? _skillContext$getApiS : null;
|
|
109
115
|
component = new ReactRenderer(MentionList, {
|
|
110
116
|
props: _objectSpread(_objectSpread({}, props), {}, {
|
|
111
117
|
agentId: agentId,
|
|
@@ -132,29 +138,29 @@ export var suggestion = {
|
|
|
132
138
|
}
|
|
133
139
|
},
|
|
134
140
|
onUpdate: function onUpdate(props) {
|
|
135
|
-
|
|
136
|
-
|
|
141
|
+
if (!component) return;
|
|
142
|
+
component.updateProps(props);
|
|
137
143
|
// query 变化导致面板高度变化,重新判断上下翻转
|
|
138
|
-
positionPanel(props.editor,
|
|
144
|
+
positionPanel(props.editor, component.element);
|
|
139
145
|
},
|
|
140
146
|
onKeyDown: function onKeyDown(props) {
|
|
141
|
-
var
|
|
147
|
+
var _component, _component$onKeyDown;
|
|
142
148
|
function onExit() {
|
|
143
149
|
component.destroy();
|
|
144
150
|
}
|
|
145
|
-
return (
|
|
151
|
+
return (_component = component) === null || _component === void 0 || (_component = _component.ref) === null || _component === void 0 || (_component$onKeyDown = _component.onKeyDown) === null || _component$onKeyDown === void 0 ? void 0 : _component$onKeyDown.call(_component, _objectSpread(_objectSpread({}, props), {}, {
|
|
146
152
|
exitCb: onExit
|
|
147
153
|
}));
|
|
148
154
|
},
|
|
149
155
|
onExit: function onExit() {
|
|
150
|
-
var
|
|
156
|
+
var _component2, _component3;
|
|
151
157
|
if (reposition) {
|
|
152
158
|
window.removeEventListener('resize', reposition);
|
|
153
159
|
window.removeEventListener('scroll', reposition, true);
|
|
154
160
|
reposition = null;
|
|
155
161
|
}
|
|
156
|
-
(
|
|
157
|
-
(
|
|
162
|
+
(_component2 = component) === null || _component2 === void 0 || (_component2 = _component2.element) === null || _component2 === void 0 || _component2.remove();
|
|
163
|
+
(_component3 = component) === null || _component3 === void 0 || _component3.destroy();
|
|
158
164
|
},
|
|
159
165
|
focusEditor: function focusEditor(props) {
|
|
160
166
|
props.editor.commands.focus();
|
|
@@ -45,12 +45,14 @@ import VoiceBars from "../voice-bars";
|
|
|
45
45
|
import classNames from 'classnames';
|
|
46
46
|
var extractText = function extractText() {
|
|
47
47
|
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
48
|
+
var skipSkill = arguments.length > 1 ? arguments[1] : undefined;
|
|
48
49
|
return content.map(function (item) {
|
|
49
50
|
if (item.type === 'text' && typeof item.text === 'string') {
|
|
50
51
|
return item.text;
|
|
51
52
|
}
|
|
52
53
|
// skill 节点序列化为 <skilltool> 标记发送,取值来自 content 中 transformer 展开后的 item
|
|
53
|
-
|
|
54
|
+
|
|
55
|
+
if (item.type === 'skill' && !skipSkill) {
|
|
54
56
|
var _skill$toolId, _skill$toolType, _skill$imageUrl, _skill$toolName;
|
|
55
57
|
var skill = item;
|
|
56
58
|
return "<skilltool>".concat(JSON.stringify({
|
|
@@ -61,7 +63,7 @@ var extractText = function extractText() {
|
|
|
61
63
|
}), "</skilltool>");
|
|
62
64
|
}
|
|
63
65
|
if (item.content && Array.isArray(item.content)) {
|
|
64
|
-
return extractText(item.content);
|
|
66
|
+
return extractText(item.content, skipSkill);
|
|
65
67
|
}
|
|
66
68
|
return '';
|
|
67
69
|
}).join('');
|
|
@@ -149,6 +151,10 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
149
151
|
},
|
|
150
152
|
getApiService: function getApiService() {
|
|
151
153
|
return apiService !== null && apiService !== void 0 ? apiService : null;
|
|
154
|
+
},
|
|
155
|
+
getSkillDisplay: function getSkillDisplay() {
|
|
156
|
+
var _agentObjRef$current2;
|
|
157
|
+
return (_agentObjRef$current2 = agentObjRef.current) === null || _agentObjRef$current2 === void 0 ? void 0 : _agentObjRef$current2.skillDisplay;
|
|
152
158
|
}
|
|
153
159
|
});
|
|
154
160
|
}, [apiService]);
|
|
@@ -183,8 +189,9 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
183
189
|
});
|
|
184
190
|
var onContentChange = React.useCallback(function (content) {
|
|
185
191
|
var _props$onValueChange;
|
|
192
|
+
var skipSkillVal = extractText(content, true);
|
|
186
193
|
var value = extractText(content);
|
|
187
|
-
if (
|
|
194
|
+
if (skipSkillVal.length > 10000) {
|
|
188
195
|
var _inputRef$current4;
|
|
189
196
|
Toast.warning(t('chatInput.maxLength'));
|
|
190
197
|
value = value.slice(0, 10000);
|
|
@@ -234,7 +241,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
234
241
|
var el = inputWrapRef.current;
|
|
235
242
|
if (!el) return;
|
|
236
243
|
var handlePaste = function handlePaste(e) {
|
|
237
|
-
var _e$clipboardData, _agentObjRef$
|
|
244
|
+
var _e$clipboardData, _agentObjRef$current3, _fileList$length, _uploadFileRef$curren;
|
|
238
245
|
var items = Array.from(((_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.items) || []);
|
|
239
246
|
var imageItem = items.find(function (item) {
|
|
240
247
|
return item.kind === 'file' && item.type.startsWith('image/');
|
|
@@ -246,7 +253,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
246
253
|
e.preventDefault();
|
|
247
254
|
|
|
248
255
|
// 前置校验:上传功能是否开启
|
|
249
|
-
if (!props.enableFileUpload || ((_agentObjRef$
|
|
256
|
+
if (!props.enableFileUpload || ((_agentObjRef$current3 = agentObjRef.current) === null || _agentObjRef$current3 === void 0 ? void 0 : _agentObjRef$current3.openUploadFile) === 0) return;
|
|
250
257
|
if (props.disabled || isAskProcess) return;
|
|
251
258
|
if (((_fileList$length = fileList === null || fileList === void 0 ? void 0 : fileList.length) !== null && _fileList$length !== void 0 ? _fileList$length : 0) >= 10) {
|
|
252
259
|
Toast.info(t('chatInput.uploadLimitTen'));
|
|
@@ -351,6 +351,8 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
351
351
|
}));
|
|
352
352
|
}, [dispatch]);
|
|
353
353
|
var handleToolStreamRs = React.useCallback(function (dataObj) {
|
|
354
|
+
// 只处理工作流模式下的 tool_result,其他情况暂不处理
|
|
355
|
+
if (dataObj.moduleType === 'tool_result' && dataObj.name !== 'executeWorkflow') return;
|
|
354
356
|
setStatus(2);
|
|
355
357
|
var messageList = messageListRef.current;
|
|
356
358
|
var lastMessage = messageList[messageList.length - 1];
|
|
@@ -591,8 +593,8 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
591
593
|
toolName: "已完成",
|
|
592
594
|
collapse: true,
|
|
593
595
|
loaded: true
|
|
594
|
-
}), "toolList", _toConsumableArray(lastToolList.
|
|
595
|
-
return v.moduleType !== "agent";
|
|
596
|
+
}), "toolList", _toConsumableArray(lastToolList.filter(function (v) {
|
|
597
|
+
return v.moduleType !== "agent" && v.moduleType !== 'end';
|
|
596
598
|
}))))]);
|
|
597
599
|
}
|
|
598
600
|
dispatch(setMessageList({
|