@myun/gimi-chat 0.2.7 → 0.2.9

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.
@@ -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: props.onInterrupt
444
+ onStopGenerate: handleInterrupt
435
445
  // 上传文件配置开始
436
446
  ,
437
447
  showUploadButton: false,
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  interface IProps {
3
3
  prologue: string;
4
4
  questionList: any[];
5
- setInputValue: (value: string) => void;
5
+ onQuickSend: (value: string) => void;
6
6
  layout: 'vertical' | 'horizontal';
7
7
  }
8
8
  declare const PresetAgentContent: React.FC<IProps>;
@@ -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
- setInputValue = _ref.setInputValue,
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 setInputValue(item.question);
30
+ return onQuickSend(item.question);
31
31
  }
32
32
  }, item.question);
33
33
  })));
@@ -5,6 +5,8 @@
5
5
  align-items: start;
6
6
  padding: 14px 0px 20px 10px;
7
7
  width: 100%;
8
+ max-width: 800px;
9
+ margin: 0 auto;
8
10
  }
9
11
  .container .prologue {
10
12
  font-family: PingFang SC;
@@ -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
- }), text);
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 :global(.ant-table-content) {
50
- font-size: 12px;
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(.ant-table-tbody > tr > td) {
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$current2;
149
- (_chatInputRef$current2 = chatInputRef.current) === null || _chatInputRef$current2 === void 0 || _chatInputRef$current2.setValue('');
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
- setInputValue: setInputValue,
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
- setInputValue: setInputValue,
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 || -1);
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 17:
335
+ case 18:
335
336
  case "end":
336
337
  return _context3.stop();
337
338
  }
@@ -684,18 +685,12 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
684
685
  });
685
686
  case 3:
686
687
  res = _context10.sent;
687
- if (res.result) {
688
- _context10.next = 7;
689
- break;
690
- }
691
- Toast.error('当前消息不可进行重试');
692
- return _context10.abrupt("return");
693
- case 7:
694
688
  if (res.status === 0 && res.result) {
695
689
  retryId = res.result;
696
690
  newMessageList = [].concat(_toConsumableArray(messageListRef.current.slice(0, -1)), [_objectSpread(_objectSpread({}, messageListRef.current[messageListRef.current.length - 1]), {}, {
697
691
  content: '',
698
692
  reasoningContent: '',
693
+ expand: true,
699
694
  relatedResourceList: [],
700
695
  loading: false,
701
696
  reasoningLoading: false,
@@ -710,17 +705,17 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
710
705
  } else {
711
706
  Toast.error(res.message || '当前消息不可进行重试');
712
707
  }
713
- _context10.next = 13;
708
+ _context10.next = 10;
714
709
  break;
715
- case 10:
716
- _context10.prev = 10;
710
+ case 7:
711
+ _context10.prev = 7;
717
712
  _context10.t0 = _context10["catch"](0);
718
713
  Toast.error('重试失败');
719
- case 13:
714
+ case 10:
720
715
  case "end":
721
716
  return _context10.stop();
722
717
  }
723
- }, _callee10, null, [[0, 10]]);
718
+ }, _callee10, null, [[0, 7]]);
724
719
  })), [streamChat]);
725
720
 
726
721
  // 单独的断点续传
@@ -824,19 +819,26 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTS
824
819
  React.useEffect(function () {
825
820
  if (conversationId && conversationIdRef.current !== conversationId) {
826
821
  conversationIdRef.current = conversationId;
827
- if (controllerRef.current) {
828
- controllerRef.current.abort();
829
- }
830
- if (streamEsAbortRef.current) {
831
- streamEsAbortRef.current.abort();
832
- }
833
- clearQuotesFromRedux();
834
822
  if (autoLoadConversation) {
835
823
  getHeaderValue(conversationId);
836
824
  getContentMessageList();
837
825
  }
838
826
  }
839
827
  }, [conversationId, autoLoadConversation]);
828
+ React.useEffect(function () {
829
+ var idAtEffectTime = conversationId;
830
+ return function () {
831
+ if (idAtEffectTime !== null && idAtEffectTime !== undefined && idAtEffectTime !== -1) {
832
+ if (controllerRef.current) {
833
+ controllerRef.current.abort();
834
+ }
835
+ if (streamEsAbortRef.current) {
836
+ streamEsAbortRef.current.abort();
837
+ }
838
+ }
839
+ clearQuotesFromRedux();
840
+ };
841
+ }, [conversationId]);
840
842
 
841
843
  // 开始会话
842
844
  var startChat = React.useCallback( /*#__PURE__*/function () {