@myun/gimi-chat 0.9.55 → 0.9.57
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/component/tool-list/index.js +4 -1
- package/dist/components/answer-item/component/tool-list/index.module.css +5 -0
- package/dist/components/answer-item/index.js +1 -1
- package/dist/components/chat-input/extension/skill/MentionList.js +2 -1
- package/dist/components/chat-input/index.js +33 -6
- package/dist/umd/index.min.js +1 -1
- package/dist/utils/tools.d.ts +1 -0
- package/dist/utils/tools.js +1 -0
- package/package.json +1 -1
|
@@ -43,7 +43,10 @@ var ToolItemCom = function ToolItemCom(_ref) {
|
|
|
43
43
|
onClick: function onClick() {
|
|
44
44
|
return item.content && setShowContent(!showContent);
|
|
45
45
|
}
|
|
46
|
-
}, /*#__PURE__*/React.createElement("
|
|
46
|
+
}, item.status === "COMPLETED" && /*#__PURE__*/React.createElement("img", {
|
|
47
|
+
className: styles.toolIcon,
|
|
48
|
+
src: "https://simg01.gaodunwangxiao.com/uploadfiles/tmp/upload/202608/28/43776_20260828150320.png"
|
|
49
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
47
50
|
className: classNames(styles.toolName, _defineProperty({}, styles.running, item.status === "RUNNING" || item.status === "STARTED"))
|
|
48
51
|
}, item.toolName), item.status === "COMPLETED" && item.content && /*#__PURE__*/React.createElement(IconFont, {
|
|
49
52
|
className: classNames(styles.icon, _defineProperty({}, styles.hasContent, showContent)),
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
.toolItem .toolItemLabel:hover .toolName {
|
|
13
13
|
color: var(--theme-neutral, #626262);
|
|
14
14
|
}
|
|
15
|
+
.toolItem .toolItemLabel .toolIcon {
|
|
16
|
+
width: 12px;
|
|
17
|
+
height: 12px;
|
|
18
|
+
margin-right: 4px;
|
|
19
|
+
}
|
|
15
20
|
.toolItem .toolItemLabel .toolName {
|
|
16
21
|
color: var(--theme-mediumNeutral, #B3B2B2);
|
|
17
22
|
font-size: 13px;
|
|
@@ -258,7 +258,7 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
258
258
|
content: data.content || '',
|
|
259
259
|
toolName: item.moduleType === 'stream' && item.status === 'TERMINATED' ? '技能调用已停止' : toolName,
|
|
260
260
|
confirmStatus: item.confirmStatus,
|
|
261
|
-
id: item.id || +new Date(),
|
|
261
|
+
id: data.id || item.id || +new Date(),
|
|
262
262
|
moduleType: item.moduleType
|
|
263
263
|
});
|
|
264
264
|
} else {
|
|
@@ -9,6 +9,7 @@ import { Toast } from '@douyinfe/semi-ui';
|
|
|
9
9
|
import AiLoading from "../../../../components/ai-loading";
|
|
10
10
|
import "./index.less";
|
|
11
11
|
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import { maxInputLength } from "../../../../utils/tools";
|
|
12
13
|
var MentionList = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
13
14
|
var command = _ref.command,
|
|
14
15
|
query = _ref.query,
|
|
@@ -108,7 +109,7 @@ var MentionList = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
108
109
|
toolName: (_item$toolName = item.toolName) !== null && _item$toolName !== void 0 ? _item$toolName : ''
|
|
109
110
|
}), "</skilltool>");
|
|
110
111
|
var currentLen = getCurrentTextLength();
|
|
111
|
-
if (currentLen + serialized.length >
|
|
112
|
+
if (currentLen + serialized.length > maxInputLength) {
|
|
112
113
|
Toast.warning(t('common.skillExceedLimit'));
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
@@ -43,6 +43,7 @@ import { ReferencesEdit } from "../reference-content";
|
|
|
43
43
|
import IconFontCom from "../iconfont-com";
|
|
44
44
|
import VoiceBars from "../voice-bars";
|
|
45
45
|
import classNames from 'classnames';
|
|
46
|
+
import { maxInputLength } from "../../utils/tools";
|
|
46
47
|
var extractText = function extractText() {
|
|
47
48
|
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
48
49
|
var skipSkill = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -192,10 +193,10 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
192
193
|
var onContentChange = React.useCallback(function (content) {
|
|
193
194
|
var _props$onValueChange;
|
|
194
195
|
var value = extractText(content);
|
|
195
|
-
if (value.length >
|
|
196
|
+
if (value.length > maxInputLength) {
|
|
196
197
|
var _inputRef$current4;
|
|
197
198
|
Toast.warning(t('chatInput.maxLength'));
|
|
198
|
-
value = value.slice(0,
|
|
199
|
+
value = value.slice(0, maxInputLength);
|
|
199
200
|
(_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 || _inputRef$current4.setContent(value);
|
|
200
201
|
}
|
|
201
202
|
setHasContent(value.trim().length > 0);
|
|
@@ -242,11 +243,37 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
242
243
|
var el = inputWrapRef.current;
|
|
243
244
|
if (!el) return;
|
|
244
245
|
var handlePaste = function handlePaste(e) {
|
|
245
|
-
var _e$clipboardData, _agentObjRef$current3, _fileList$length, _uploadFileRef$curren;
|
|
246
|
-
var
|
|
246
|
+
var _e$clipboardData, _e$clipboardData2, _e$clipboardData3, _agentObjRef$current3, _fileList$length, _uploadFileRef$curren;
|
|
247
|
+
var pasteHtml = ((_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.getData('text/html')) || '';
|
|
248
|
+
var pasteText = ((_e$clipboardData2 = e.clipboardData) === null || _e$clipboardData2 === void 0 ? void 0 : _e$clipboardData2.getData('text/plain')) || '';
|
|
249
|
+
var items = Array.from(((_e$clipboardData3 = e.clipboardData) === null || _e$clipboardData3 === void 0 ? void 0 : _e$clipboardData3.items) || []);
|
|
247
250
|
var imageItem = items.find(function (item) {
|
|
248
251
|
return item.kind === 'file' && item.type.startsWith('image/');
|
|
249
252
|
});
|
|
253
|
+
|
|
254
|
+
// 含技能节点时,降级为纯文本插入(剥离 refer-slot 标签)
|
|
255
|
+
if (!imageItem && pasteHtml.includes('<refer-slot')) {
|
|
256
|
+
e.preventDefault();
|
|
257
|
+
e.stopPropagation();
|
|
258
|
+
if (pasteText) {
|
|
259
|
+
var _inputRef$current7;
|
|
260
|
+
if (preInputValueRef.current.length + pasteText.length > maxInputLength) {
|
|
261
|
+
Toast.warning(t('chatInput.maxLength'));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
(_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 || (_inputRef$current7 = _inputRef$current7.getEditor()) === null || _inputRef$current7 === void 0 || (_inputRef$current7 = _inputRef$current7.commands) === null || _inputRef$current7 === void 0 || _inputRef$current7.insertContent(pasteText);
|
|
265
|
+
}
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (!imageItem && pasteText) {
|
|
269
|
+
if (preInputValueRef.current.length + pasteText.length > maxInputLength) {
|
|
270
|
+
e.preventDefault();
|
|
271
|
+
e.stopPropagation();
|
|
272
|
+
Toast.warning(t('chatInput.maxLength'));
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
250
277
|
if (!imageItem) return;
|
|
251
278
|
|
|
252
279
|
// 有图片时阻止 tiptap 默认行为(避免图片被插入编辑器)
|
|
@@ -544,7 +571,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
544
571
|
return file.status === FileStatus.UPLOADING || file.status === FileStatus.PADDING || file.status === FileStatus.RETRING;
|
|
545
572
|
});
|
|
546
573
|
if (uploadingFile) {
|
|
547
|
-
var _inputRef$
|
|
574
|
+
var _inputRef$current8;
|
|
548
575
|
// 文件处理中,恢复输入内容,不发送
|
|
549
576
|
var message = '';
|
|
550
577
|
if (uploadingFile.status === FileStatus.UPLOADING || uploadingFile.status === FileStatus.RETRING) {
|
|
@@ -553,7 +580,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
553
580
|
message = t('fileValidation.parsing');
|
|
554
581
|
}
|
|
555
582
|
Toast.info(message);
|
|
556
|
-
(_inputRef$
|
|
583
|
+
(_inputRef$current8 = inputRef.current) === null || _inputRef$current8 === void 0 || _inputRef$current8.setContent(text);
|
|
557
584
|
return;
|
|
558
585
|
}
|
|
559
586
|
(_props$onSend = props.onSend) === null || _props$onSend === void 0 || _props$onSend.call(props, text);
|