@myun/gimi-chat 0.9.72 → 0.9.74

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.
@@ -370,13 +370,22 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
370
370
  var curToolIndex = curToolList.findIndex(function (item) {
371
371
  return (item === null || item === void 0 ? void 0 : item.id) === dataObj.id;
372
372
  });
373
- var curThinkingContent = ((_curToolList$curToolI = curToolList[curToolIndex]) === null || _curToolList$curToolI === void 0 ? void 0 : _curToolList$curToolI.content) || '';
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
+ }
374
383
  // 为新节点类型根据 status 生成 toolName
375
384
  var isNewNodeType = !['tool_invocation', 'tool_result', "agent"].includes(dataObj.moduleType);
376
385
  var toolName = isNewNodeType ? getToolNameByStatus(dataObj.moduleType, dataObj.status) : dataObj.toolName;
377
386
  if (curToolIndex >= 0) {
378
387
  curToolList[curToolIndex] = _objectSpread(_objectSpread({}, curToolList[curToolIndex]), {}, {
379
- content: dataObj.moduleType === 'thinking' ? curThinkingContent + (dataObj.reasoningContent || '') : dataObj.content || '',
388
+ content: curContent,
380
389
  // tool_invocation 更新 toolName 和 status,新节点类型也更新
381
390
  toolName: dataObj.moduleType === 'tool_invocation' ? dataObj.toolName || '' : isNewNodeType ? toolName : curToolList[curToolIndex].toolName,
382
391
  status: dataObj.moduleType === 'tool_invocation' || isNewNodeType ? dataObj.status : curToolList[curToolIndex].status
@@ -572,7 +581,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
572
581
  currentMessageList = messageListRef.current;
573
582
  lastToolList = _toConsumableArray(currentMessageList[currentMessageList.length - 1].toolList || []);
574
583
  newMessageList = [];
575
- if (type === 'user_confirm') {
584
+ if (type === 'user_confirm' || type === 'ask') {
576
585
  newMessageList = [].concat(_toConsumableArray(currentMessageList.slice(0, -1)), [_objectSpread(_objectSpread({}, currentMessageList[currentMessageList.length - 1]), {}, {
577
586
  moduleType: type,
578
587
  moduleInfo: Response,
@@ -589,11 +598,11 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
589
598
  toolList: [].concat(_toConsumableArray(lastToolList), [{
590
599
  moduleType: type,
591
600
  content: '',
592
- data: Response,
601
+ data: type === 'ask' ? Response.data : Response,
593
602
  status: "RUNNING",
594
603
  toolName: t('chatApi.waitingForConfirmation'),
595
604
  confirmStatus: "PENDING",
596
- id: "".concat(new Date().getTime())
605
+ id: Response.id || "".concat(new Date().getTime())
597
606
  }])
598
607
  })]);
599
608
  } else {
@@ -994,9 +1003,12 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
994
1003
  cleanVal,
995
1004
  userChat,
996
1005
  prevChatList,
997
- _prevChatList,
998
- lastItem,
999
1006
  newChatList,
1007
+ lastItem,
1008
+ _lastItem$toolList,
1009
+ _lastItem$toolList2,
1010
+ lastAskTool,
1011
+ updatedToolList,
1000
1012
  _args10 = arguments;
1001
1013
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1002
1014
  while (1) switch (_context10.prev = _context10.next) {
@@ -1048,27 +1060,55 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1048
1060
 
1049
1061
  // 根据isSystemAuto决定是否添加用户消息到列表
1050
1062
  prevChatList = messageListRef.current.slice();
1051
- if (!isSystemAuto) {
1052
- setMsgLoading(true);
1053
- if (((_prevChatList = prevChatList) === null || _prevChatList === void 0 ? void 0 : _prevChatList.length) > 1) {
1054
- lastItem = prevChatList[prevChatList.length - 1];
1055
- if (lastItem.moduleType === 'ask') {
1056
- prevChatList = [].concat(_toConsumableArray(prevChatList.slice(0, -1)), [_objectSpread(_objectSpread({}, prevChatList[prevChatList.length - 1]), {}, {
1057
- disableUploadFile: true
1058
- })]);
1059
- }
1060
- }
1061
- newChatList = [].concat(_toConsumableArray(prevChatList), [userChat]);
1062
- dispatch(setMessageList({
1063
- messageList: newChatList
1064
- }));
1065
- startChat(newChatList, isSystemAuto, conversationId, undefined, skipCreateNewMessage);
1066
- } else {
1067
- setMsgLoading(true);
1068
- // 系统自动上传,直接开始会话,不更新列表
1069
- startChat(_toConsumableArray(prevChatList), isSystemAuto, conversationId, undefined, skipCreateNewMessage);
1063
+ newChatList = [].concat(_toConsumableArray(prevChatList), [userChat]);
1064
+ if (isSystemAuto) {
1065
+ _context10.next = 40;
1066
+ break;
1070
1067
  }
1071
- case 25:
1068
+ setMsgLoading(true);
1069
+ if (!((prevChatList === null || prevChatList === void 0 ? void 0 : prevChatList.length) > 1)) {
1070
+ _context10.next = 36;
1071
+ break;
1072
+ }
1073
+ lastItem = prevChatList[prevChatList.length - 1];
1074
+ if (!(lastItem.moduleType === 'ask')) {
1075
+ _context10.next = 36;
1076
+ break;
1077
+ }
1078
+ lastAskTool = (_lastItem$toolList = lastItem.toolList) === null || _lastItem$toolList === void 0 ? void 0 : _lastItem$toolList.find(function (tool) {
1079
+ return tool.moduleType === 'ask';
1080
+ });
1081
+ if (lastAskTool) {
1082
+ _context10.next = 33;
1083
+ break;
1084
+ }
1085
+ return _context10.abrupt("return");
1086
+ case 33:
1087
+ updatedToolList = (_lastItem$toolList2 = lastItem.toolList) === null || _lastItem$toolList2 === void 0 ? void 0 : _lastItem$toolList2.map(function (tool) {
1088
+ return tool.id === lastAskTool.id ? _objectSpread(_objectSpread({}, tool), {}, {
1089
+ moduleType: "ask",
1090
+ status: 'COMPLETED',
1091
+ confirmStatus: "CONFIRMED",
1092
+ content: value
1093
+ }) : tool;
1094
+ });
1095
+ skipCreateNewMessage = true;
1096
+ newChatList = [].concat(_toConsumableArray(prevChatList.slice(0, -1)), [_objectSpread(_objectSpread({}, prevChatList[prevChatList.length - 1]), {}, {
1097
+ disableUploadFile: true,
1098
+ toolList: updatedToolList
1099
+ })]);
1100
+ case 36:
1101
+ dispatch(setMessageList({
1102
+ messageList: newChatList
1103
+ }));
1104
+ startChat(newChatList, isSystemAuto, conversationId, undefined, skipCreateNewMessage);
1105
+ _context10.next = 42;
1106
+ break;
1107
+ case 40:
1108
+ setMsgLoading(true);
1109
+ // 系统自动上传,直接开始会话,不更新列表
1110
+ startChat(_toConsumableArray(prevChatList), isSystemAuto, conversationId, undefined, skipCreateNewMessage);
1111
+ case 42:
1072
1112
  case "end":
1073
1113
  return _context10.stop();
1074
1114
  }
@@ -1317,6 +1357,7 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
1317
1357
  var uploadFile = fileList[0];
1318
1358
  var isLastMessageEmptyUserChat = (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.moduleType) === 'ask'; // 空内容
1319
1359
  if (!isLastMessageEmptyUserChat) {
1360
+ console.log('isLastMessageEmptyUserChat', isLastMessageEmptyUserChat);
1320
1361
  var shouldEnableUpload = uploadFile.status === FileStatus.UPLOAD_FAILED || uploadFile.status === FileStatus.ANALYSE_FAILED;
1321
1362
  var newMessageList = [].concat(_toConsumableArray(messageList.slice(0, -2)), [_objectSpread(_objectSpread({}, messageList[messageList.length - 2]), {}, {
1322
1363
  disableUploadFile: !shouldEnableUpload
@@ -24,6 +24,7 @@ export interface ToolItem {
24
24
  * PARTIAL:部分同意;
25
25
  */
26
26
  confirmStatus?: "PENDING" | "CONFIRMED" | "REJECTED" | "PARTIAL";
27
+ workflowAskResult?: any;
27
28
  }
28
29
  /**
29
30
  * 聊天消息主接口