@myun/gimi-chat 0.0.8 → 0.1.0

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.
Files changed (101) hide show
  1. package/dist/apis/useApi.d.ts +2 -0
  2. package/dist/apis/useApi.js +50 -2
  3. package/dist/components/ai-chat-dialogue/index.js +135 -181
  4. package/dist/components/ai-correction/index.js +25 -38
  5. package/dist/components/ai-loading/index.js +8 -12
  6. package/dist/components/answer-item/index.d.ts +3 -0
  7. package/dist/components/answer-item/index.js +126 -135
  8. package/dist/components/ask-card/index.js +33 -42
  9. package/dist/components/chat-input/extension/index.d.ts +2 -0
  10. package/dist/components/chat-input/extension/index.js +2 -0
  11. package/dist/components/chat-input/extension/keydown/index.d.ts +3 -0
  12. package/dist/components/chat-input/extension/keydown/index.js +37 -0
  13. package/dist/components/chat-input/extension/title-slot/Component.d.ts +4 -0
  14. package/dist/components/chat-input/extension/title-slot/Component.js +18 -0
  15. package/dist/components/chat-input/extension/title-slot/index.d.ts +3 -0
  16. package/dist/components/chat-input/extension/title-slot/index.js +47 -0
  17. package/dist/components/chat-input/extension/title-slot/index.less +22 -0
  18. package/dist/components/chat-input/index.d.ts +4 -0
  19. package/dist/components/chat-input/index.js +144 -145
  20. package/dist/components/chat-input/index.module.css +7 -0
  21. package/dist/components/chat-voice/VoiceCommunication.js +21 -23
  22. package/dist/components/chat-voice/VoiceRecord.js +21 -24
  23. package/dist/components/conversation-delete/index.js +8 -10
  24. package/dist/components/dots-loading/index.js +7 -10
  25. package/dist/components/empty/index.js +7 -12
  26. package/dist/components/excel-components/ExcelCard.js +3 -7
  27. package/dist/components/excel-components/ExcelExcuting.js +43 -60
  28. package/dist/components/excel-components/ExcelFailCard.js +10 -15
  29. package/dist/components/excel-components/ExcelSuccessCard.d.ts +5 -1
  30. package/dist/components/excel-components/ExcelSuccessCard.js +13 -6
  31. package/dist/components/file-card/fileCardSidebar.js +17 -23
  32. package/dist/components/file-card/index.d.ts +3 -0
  33. package/dist/components/file-card/index.js +59 -69
  34. package/dist/components/file-card/index.module.css +1 -1
  35. package/dist/components/file-preview/index.js +62 -37
  36. package/dist/components/file-preview/index.module.css +33 -0
  37. package/dist/components/file-upload/index.js +7 -10
  38. package/dist/components/file-upload/uploadV1.js +27 -33
  39. package/dist/components/gimi-sidebar/index.js +13 -20
  40. package/dist/components/header/index.js +11 -18
  41. package/dist/components/iconfont-com/index.js +33 -12
  42. package/dist/components/index.d.ts +1 -1
  43. package/dist/components/index.js +1 -1
  44. package/dist/components/knowledge-trace/KnowledgeIconComponent.js +22 -28
  45. package/dist/components/knowledge-trace/classList.js +28 -37
  46. package/dist/components/knowledge-trace/documentList.js +27 -36
  47. package/dist/components/knowledge-trace/index.js +21 -28
  48. package/dist/components/knowledge-trace/videoList.js +36 -46
  49. package/dist/components/lottie-img/index.js +8 -10
  50. package/dist/components/message-actions/CopyButton.d.ts +1 -1
  51. package/dist/components/message-actions/CopyButton.js +22 -25
  52. package/dist/components/message-actions/LikeButton.js +22 -25
  53. package/dist/components/message-actions/RegenerateButton.js +18 -21
  54. package/dist/components/message-actions/UnLikeButton.js +22 -25
  55. package/dist/components/message-actions/VoicePlay.js +22 -25
  56. package/dist/components/message-list/index.js +83 -87
  57. package/dist/components/no-microphone-root/index.js +29 -39
  58. package/dist/components/preset-agent-content/index.d.ts +1 -0
  59. package/dist/components/preset-agent-content/index.js +27 -20
  60. package/dist/components/quoted-content/index.d.ts +3 -0
  61. package/dist/components/quoted-content/index.js +271 -163
  62. package/dist/components/quoted-content/index.module.css +20 -0
  63. package/dist/components/reasoning-content/index.d.ts +3 -2
  64. package/dist/components/reasoning-content/index.js +50 -61
  65. package/dist/components/reference-content/index.js +62 -71
  66. package/dist/components/reference-content/index.module.css +1 -0
  67. package/dist/components/search-result/index.d.ts +7 -0
  68. package/dist/components/search-result/index.js +182 -0
  69. package/dist/components/search-result/index.module.css +235 -0
  70. package/dist/components/templates/CommonChat.js +75 -79
  71. package/dist/components/templates/GimiChatComponent.js +6 -13
  72. package/dist/components/upload-list/index.js +41 -56
  73. package/dist/components/voice-bars/index.js +19 -22
  74. package/dist/components/voice-check-dialog/index.js +17 -24
  75. package/dist/components/voice-recording/index.js +42 -57
  76. package/dist/components/work-flow-content/index.js +8 -11
  77. package/dist/hooks/useChatActions.d.ts +1 -1
  78. package/dist/hooks/useChatActions.js +3 -1
  79. package/dist/hooks/useCommonChatAPI.d.ts +2 -1
  80. package/dist/hooks/useCommonChatAPI.js +10 -8
  81. package/dist/hooks/useQuoted.d.ts +12 -0
  82. package/dist/hooks/useQuoted.js +202 -0
  83. package/dist/index.d.ts +2 -0
  84. package/dist/index.js +3 -1
  85. package/dist/interfaces/index.d.ts +3 -0
  86. package/dist/interfaces/index.js +3 -0
  87. package/dist/types/answer.d.ts +16 -0
  88. package/dist/types/chat.d.ts +124 -0
  89. package/dist/types/file.d.ts +20 -0
  90. package/dist/types/index.d.ts +3 -0
  91. package/dist/types/index.js +3 -0
  92. package/dist/types/modules.d.ts +36 -0
  93. package/dist/utils/aes.d.ts +21 -0
  94. package/dist/utils/aes.js +61 -0
  95. package/dist/utils/chatInputUtil.d.ts +1 -1
  96. package/dist/utils/chatInputUtil.js +4 -3
  97. package/package.json +1 -1
  98. package/dist/components/templates/demo/demo.d.ts +0 -2
  99. package/dist/components/templates/demo/demo.js +0 -111
  100. package/dist/components/work-flow-content/demo.d.ts +0 -3
  101. package/dist/components/work-flow-content/demo.js +0 -12
@@ -16,9 +16,6 @@ import styles from "./index.module.css";
16
16
  import NoMicrophoneModalContent from "../no-microphone-root";
17
17
  import { useAppDispatch, useAppSelector } from "../../store/hooks";
18
18
  import { setShowMicWarning } from "../../store/slices/gimiMenuSlice";
19
- import { jsx as _jsx } from "react/jsx-runtime";
20
- import { Fragment as _Fragment } from "react/jsx-runtime";
21
- import { jsxs as _jsxs } from "react/jsx-runtime";
22
19
  var VoiceCheckDialog = function VoiceCheckDialog(_ref) {
23
20
  var _layout$x, _layout$y;
24
21
  var className = _ref.className,
@@ -145,26 +142,22 @@ var VoiceCheckDialog = function VoiceCheckDialog(_ref) {
145
142
  showMicWarning: false
146
143
  }));
147
144
  };
148
- return /*#__PURE__*/_jsxs(_Fragment, {
149
- children: [trigger && /*#__PURE__*/_jsx("div", {
150
- ref: triggerRef,
151
- style: {
152
- display: 'flex'
153
- },
154
- children: trigger
155
- }), showMicWarning && /*#__PURE__*/_jsx("div", {
156
- ref: dialogRef,
157
- className: classNames(styles['voice-check-dialog'], className),
158
- style: _objectSpread({
159
- left: "".concat((_layout$x = layout === null || layout === void 0 ? void 0 : layout.x) !== null && _layout$x !== void 0 ? _layout$x : 0, "px"),
160
- top: "".concat((_layout$y = layout === null || layout === void 0 ? void 0 : layout.y) !== null && _layout$y !== void 0 ? _layout$y : 0, "px"),
161
- opacity: layout ? 1 : 0,
162
- visibility: layout ? 'visible' : 'hidden'
163
- }, style),
164
- children: /*#__PURE__*/_jsx(NoMicrophoneModalContent, {
165
- onOk: onCancel
166
- })
167
- })]
168
- });
145
+ return /*#__PURE__*/React.createElement(React.Fragment, null, trigger && /*#__PURE__*/React.createElement("div", {
146
+ ref: triggerRef,
147
+ style: {
148
+ display: 'flex'
149
+ }
150
+ }, trigger), showMicWarning && /*#__PURE__*/React.createElement("div", {
151
+ ref: dialogRef,
152
+ className: classNames(styles['voice-check-dialog'], className),
153
+ style: _objectSpread({
154
+ left: "".concat((_layout$x = layout === null || layout === void 0 ? void 0 : layout.x) !== null && _layout$x !== void 0 ? _layout$x : 0, "px"),
155
+ top: "".concat((_layout$y = layout === null || layout === void 0 ? void 0 : layout.y) !== null && _layout$y !== void 0 ? _layout$y : 0, "px"),
156
+ opacity: layout ? 1 : 0,
157
+ visibility: layout ? 'visible' : 'hidden'
158
+ }, style)
159
+ }, /*#__PURE__*/React.createElement(NoMicrophoneModalContent, {
160
+ onOk: onCancel
161
+ })));
169
162
  };
170
163
  export default VoiceCheckDialog;
@@ -2,68 +2,53 @@ import { Tooltip } from '@douyinfe/semi-ui';
2
2
  import VoiceBars from "../voice-bars";
3
3
  import styles from "./index.module.css";
4
4
  import React from 'react';
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- import { Fragment as _Fragment } from "react/jsx-runtime";
7
- import { jsxs as _jsxs } from "react/jsx-runtime";
8
5
  var CHECK_ICON_ADDRESS = 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202601/04/8b0e2_20260104154821.png';
9
6
  var CANCEL_ICON_ADDRESS = 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202601/04/94bfe_20260104154857.png';
10
7
  var VoiceRecording = function VoiceRecording(_ref) {
11
8
  var recordingCount = _ref.recordingCount,
12
9
  stopRecording = _ref.stopRecording,
13
10
  containerWidth = _ref.containerWidth;
14
- return /*#__PURE__*/_jsxs("div", {
15
- className: styles.main,
16
- children: [/*#__PURE__*/_jsxs("div", {
17
- className: styles.text,
18
- children: [/*#__PURE__*/_jsx("span", {
19
- className: styles.font_weight_600,
20
- children: "\u8BED\u97F3\u8F93\u5165\u4E2D"
21
- }), recordingCount > 0 && recordingCount <= 10 && /*#__PURE__*/_jsxs(_Fragment, {
22
- children: [/*#__PURE__*/_jsx("span", {
23
- className: styles.font_weight_400,
24
- children: "(\u5012\u8BA1\u65F6"
25
- }), /*#__PURE__*/_jsx("span", {
26
- className: styles.count,
27
- children: recordingCount
28
- }), /*#__PURE__*/_jsx("span", {
29
- className: styles.font_weight_400,
30
- children: "\u79D2)"
31
- })]
32
- })]
33
- }), /*#__PURE__*/_jsxs("div", {
34
- className: styles.voice_bar,
35
- children: [/*#__PURE__*/_jsx(VoiceBars, {
36
- parentWidth: containerWidth - 48 * 2 - 20 * 2 - 10
37
- }), /*#__PURE__*/_jsxs("div", {
38
- style: {
39
- display: 'flex',
40
- gap: '10px'
41
- },
42
- children: [/*#__PURE__*/_jsx(Tooltip, {
43
- content: "\u653E\u5F03\u8F6C\u5199",
44
- arrowPointAtCenter: true,
45
- children: /*#__PURE__*/_jsx("img", {
46
- className: styles.icon,
47
- src: CANCEL_ICON_ADDRESS,
48
- alt: "\u653E\u5F03\u8F6C\u5199",
49
- onClick: function onClick() {
50
- stopRecording(false);
51
- }
52
- })
53
- }), /*#__PURE__*/_jsx(Tooltip, {
54
- content: "\u5F00\u59CB\u8F6C\u5199",
55
- arrowPointAtCenter: true,
56
- children: /*#__PURE__*/_jsx("img", {
57
- className: styles.icon,
58
- src: CHECK_ICON_ADDRESS,
59
- alt: "\u5F00\u59CB\u8F6C\u5199",
60
- onClick: function onClick() {
61
- stopRecording(true);
62
- }
63
- })
64
- })]
65
- })]
66
- })]
67
- });
11
+ return /*#__PURE__*/React.createElement("div", {
12
+ className: styles.main
13
+ }, /*#__PURE__*/React.createElement("div", {
14
+ className: styles.text
15
+ }, /*#__PURE__*/React.createElement("span", {
16
+ className: styles.font_weight_600
17
+ }, "\u8BED\u97F3\u8F93\u5165\u4E2D"), recordingCount > 0 && recordingCount <= 10 && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
18
+ className: styles.font_weight_400
19
+ }, "(\u5012\u8BA1\u65F6"), /*#__PURE__*/React.createElement("span", {
20
+ className: styles.count
21
+ }, recordingCount), /*#__PURE__*/React.createElement("span", {
22
+ className: styles.font_weight_400
23
+ }, "\u79D2)"))), /*#__PURE__*/React.createElement("div", {
24
+ className: styles.voice_bar
25
+ }, /*#__PURE__*/React.createElement(VoiceBars, {
26
+ parentWidth: containerWidth - 48 * 2 - 20 * 2 - 10
27
+ }), /*#__PURE__*/React.createElement("div", {
28
+ style: {
29
+ display: 'flex',
30
+ gap: '10px'
31
+ }
32
+ }, /*#__PURE__*/React.createElement(Tooltip, {
33
+ content: "\u653E\u5F03\u8F6C\u5199",
34
+ arrowPointAtCenter: true
35
+ }, /*#__PURE__*/React.createElement("img", {
36
+ className: styles.icon,
37
+ src: CANCEL_ICON_ADDRESS,
38
+ alt: "\u653E\u5F03\u8F6C\u5199",
39
+ onClick: function onClick() {
40
+ stopRecording(false);
41
+ }
42
+ })), /*#__PURE__*/React.createElement(Tooltip, {
43
+ content: "\u5F00\u59CB\u8F6C\u5199",
44
+ arrowPointAtCenter: true
45
+ }, /*#__PURE__*/React.createElement("img", {
46
+ className: styles.icon,
47
+ src: CHECK_ICON_ADDRESS,
48
+ alt: "\u5F00\u59CB\u8F6C\u5199",
49
+ onClick: function onClick() {
50
+ stopRecording(true);
51
+ }
52
+ })))));
68
53
  };
69
54
  export default VoiceRecording;
@@ -2,15 +2,13 @@ import * as React from 'react';
2
2
  import styles from "./index.module.css";
3
3
  import { Spin } from '@douyinfe/semi-ui';
4
4
  import { IconSpin, IconInfoCircle } from '@douyinfe/semi-icons';
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- import { jsxs as _jsxs } from "react/jsx-runtime";
7
- var antIcon = /*#__PURE__*/_jsx(IconSpin, {
5
+ var antIcon = /*#__PURE__*/React.createElement(IconSpin, {
8
6
  style: {
9
7
  fontSize: 16
10
8
  },
11
9
  spin: true
12
10
  });
13
- var warnIcon = /*#__PURE__*/_jsx(IconInfoCircle, {
11
+ var warnIcon = /*#__PURE__*/React.createElement(IconInfoCircle, {
14
12
  style: {
15
13
  fontSize: 16
16
14
  }
@@ -19,13 +17,12 @@ var WorkFlowContent = function WorkFlowContent(_ref) {
19
17
  var chatItem = _ref.chatItem;
20
18
  // const isExecuting = chatItem.mcps.some((item: MCPItem) => !item.isFinished);
21
19
  var mcp = chatItem.mcp;
22
- return /*#__PURE__*/_jsxs("div", {
23
- className: styles.layout,
24
- children: [mcp.status === 'executeWorkflowByDescription' ? '正在查询可用工作流...' : mcp.status === 'interrupt' ? '运行终止' : "\u6B63\u5728\u8C03\u7528 ".concat(mcp.name || '工作流', "..."), mcp.status === 'interrupt' ? warnIcon : /*#__PURE__*/_jsx(Spin, {
25
- className: styles.spin,
26
- indicator: antIcon
27
- })]
28
- });
20
+ return /*#__PURE__*/React.createElement("div", {
21
+ className: styles.layout
22
+ }, mcp.status === 'executeWorkflowByDescription' ? '正在查询可用工作流...' : mcp.status === 'interrupt' ? '运行终止' : "\u6B63\u5728\u8C03\u7528 ".concat(mcp.name || '工作流', "..."), mcp.status === 'interrupt' ? warnIcon : /*#__PURE__*/React.createElement(Spin, {
23
+ className: styles.spin,
24
+ indicator: antIcon
25
+ }));
29
26
 
30
27
  // return (
31
28
  // <Collapse
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { IChatMessageItem } from '../interfaces/chatMessage';
3
3
  export declare const usePureChatActions: () => {
4
- copyToClipboard: (value: IChatMessageItem, replaceTags?: string[]) => Promise<void>;
4
+ copyToClipboard: (value: IChatMessageItem | string, replaceTags?: string[]) => Promise<void>;
5
5
  handleUnlove: (item: IChatMessageItem, type: 'love' | 'unlove') => Promise<void>;
6
6
  };
7
7
  declare const useChatActions: (showCopyId: number | null, inputModelRef: React.MutableRefObject<any>, handleSend: (val: string, agent?: any, isSystemAuto?: boolean) => void) => {
@@ -58,7 +58,9 @@ export var usePureChatActions = function usePureChatActions() {
58
58
  while (1) switch (_context.prev = _context.next) {
59
59
  case 0:
60
60
  replaceTags = _args.length > 1 && _args[1] !== undefined ? _args[1] : ['knowledge', 'excel'];
61
- if (value.moduleType === 'skill') {
61
+ if (typeof value === 'string') {
62
+ text = value;
63
+ } else if (value.moduleType === 'skill') {
62
64
  text = ((_value$moduleInfo = value.moduleInfo) === null || _value$moduleInfo === void 0 ? void 0 : _value$moduleInfo.data.results.skillResult.message) || '';
63
65
  } else if (value.moduleType === 'ask') {
64
66
  text = ((_value$moduleInfo2 = value.moduleInfo) === null || _value$moduleInfo2 === void 0 ? void 0 : _value$moduleInfo2.data.results.askShowInfo.questionContent) || '';
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- declare const useCommonChatAPI: (containerRef: React.RefObject<HTMLDivElement>, businessType: string, stopTTSByText?: () => void, isPlaying?: boolean, agentId?: number) => {
2
+ import { IChatMessageItem } from "../interfaces/chatMessage";
3
+ declare const useCommonChatAPI: (containerRef: React.RefObject<HTMLDivElement>, businessType: string, stopTTSByText?: () => void, isPlaying?: boolean, agentId?: number, onConversationCreated?: ((conversationId: number) => void) | undefined, onSendEnd?: ((message: IChatMessageItem) => void) | undefined) => {
3
4
  headerValue: string;
4
5
  getHeaderValue: (conversationId: number) => Promise<void>;
5
6
  msgLoading: boolean;
@@ -32,7 +32,7 @@ import { useChatRecommend } from "./useChatRecommend";
32
32
  import { set, cloneDeep } from 'lodash';
33
33
  import { FileStatus } from "../interfaces/fileInterface";
34
34
  import useChatHistory from "./useChatHistory";
35
- var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, stopTTSByText, isPlaying, agentId) {
35
+ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, stopTTSByText, isPlaying, agentId, onConversationCreated, onSendEnd) {
36
36
  var _useApi = useApi(),
37
37
  getMessageTitle = _useApi.getMessageTitle,
38
38
  stopStreamOut = _useApi.stopStreamOut,
@@ -173,7 +173,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
173
173
 
174
174
  var startAICorrection = React.useCallback( /*#__PURE__*/function () {
175
175
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(answerId, questionId) {
176
- var res, _res$result, _res$result2, message, aiChat;
176
+ var res, _res$result, _res$result2, _message, aiChat;
177
177
  return _regeneratorRuntime().wrap(function _callee$(_context) {
178
178
  while (1) switch (_context.prev = _context.next) {
179
179
  case 0:
@@ -185,10 +185,10 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
185
185
  case 2:
186
186
  res = _context.sent;
187
187
  if (res.status === 0) {
188
- message = createUserChat((_res$result = res.result) === null || _res$result === void 0 ? void 0 : _res$result.title, '');
188
+ _message = createUserChat((_res$result = res.result) === null || _res$result === void 0 ? void 0 : _res$result.title, '');
189
189
  aiChat = createAiChat({});
190
190
  dispatch(setMessageList({
191
- messageList: [message, aiChat]
191
+ messageList: [_message, aiChat]
192
192
  }));
193
193
  dispatch(setAgentDetail({
194
194
  agentDetail: {
@@ -607,6 +607,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
607
607
  dispatch(setMessageList({
608
608
  messageList: newMessageList
609
609
  }));
610
+ onSendEnd === null || onSendEnd === void 0 || onSendEnd(newMessageList[newMessageList.length - 1]);
610
611
  if (type === 'ask' || type === 'skill') {
611
612
  scrollBottomForce();
612
613
  }
@@ -615,19 +616,19 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
615
616
  // 获取最新的agent详情,防止redux异步更新
616
617
  agentDetail = agentInfo || agentObjRef.current;
617
618
  if (!((agentDetail === null || agentDetail === void 0 ? void 0 : agentDetail.isEnableRelated) === 1 && (type === 'end' || type === 'COMPLETED'))) {
618
- _context8.next = 10;
619
+ _context8.next = 11;
619
620
  break;
620
621
  }
621
- _context8.next = 10;
622
+ _context8.next = 11;
622
623
  return getRecommendList(newMessageList, lastId, statusRef.current);
623
- case 10:
624
+ case 11:
624
625
  if (valueRef.current) {
625
626
  setStatus(1);
626
627
  } else {
627
628
  setStatus(0);
628
629
  }
629
630
  setMsgLoading(false);
630
- case 12:
631
+ case 13:
631
632
  case "end":
632
633
  return _context8.stop();
633
634
  }
@@ -987,6 +988,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
987
988
  dispatch(setConversationId({
988
989
  conversationId: res.result
989
990
  }));
991
+ onConversationCreated === null || onConversationCreated === void 0 || onConversationCreated(res.result);
990
992
  getHeaderValue(res.result);
991
993
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
992
994
  handleSend(value, agentObjRef.current, false, res.result);
@@ -0,0 +1,12 @@
1
+ export declare type KonwledgeType = 'video' | 'course';
2
+ declare const useQuotedService: ({ type, searchValue, showmodel }: {
3
+ type: KonwledgeType;
4
+ searchValue: any;
5
+ showmodel: boolean;
6
+ }) => {
7
+ isLoading: boolean;
8
+ totalPage: number;
9
+ resource: any[];
10
+ getVideoResource: () => Promise<void>;
11
+ };
12
+ export default useQuotedService;
@@ -0,0 +1,202 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
8
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
9
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
18
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
19
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
+ import useApi from "../apis/useApi";
21
+ import { useEffect, useRef, useState } from 'react';
22
+ var useQuotedService = function useQuotedService(_ref) {
23
+ var type = _ref.type,
24
+ searchValue = _ref.searchValue,
25
+ showmodel = _ref.showmodel;
26
+ var _useState = useState(false),
27
+ _useState2 = _slicedToArray(_useState, 2),
28
+ isLoading = _useState2[0],
29
+ setIsloading = _useState2[1];
30
+ var _useState3 = useState(0),
31
+ _useState4 = _slicedToArray(_useState3, 2),
32
+ totalPage = _useState4[0],
33
+ setTotalPage = _useState4[1]; // 总页数
34
+ var _useState5 = useState([]),
35
+ _useState6 = _slicedToArray(_useState5, 2),
36
+ resource = _useState6[0],
37
+ setResource = _useState6[1];
38
+ var latestTypeRef = useRef(null);
39
+ var _useApi = useApi(),
40
+ getReferenceVideoList = _useApi.getReferenceVideoList,
41
+ getReferenceCourseList = _useApi.getReferenceCourseList;
42
+
43
+ //处理数据 统一设置key
44
+ var handleData = function handleData(data) {
45
+ return data.map(function (item) {
46
+ return _objectSpread(_objectSpread({}, item), {}, {
47
+ id: item.productId || item.teachModelId,
48
+ name: item.productName || item.teachModelName
49
+ });
50
+ });
51
+ };
52
+ var getVideoResource = /*#__PURE__*/function () {
53
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
54
+ var params, res, resData;
55
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
56
+ while (1) switch (_context.prev = _context.next) {
57
+ case 0:
58
+ _context.prev = 0;
59
+ params = {
60
+ pageIndex: searchValue.pageIndex || 1,
61
+ pageSize: searchValue.pageSize || 20,
62
+ where: {
63
+ teachModelName: searchValue.inputValue || ''
64
+ }
65
+ };
66
+ _context.next = 4;
67
+ return getReferenceVideoList(params);
68
+ case 4:
69
+ res = _context.sent;
70
+ if (!(res.status === 0 && res.result)) {
71
+ _context.next = 13;
72
+ break;
73
+ }
74
+ resData = handleData(res.result.data || []);
75
+ if (!(latestTypeRef.current !== 'video')) {
76
+ _context.next = 9;
77
+ break;
78
+ }
79
+ return _context.abrupt("return");
80
+ case 9:
81
+ if (res.result.page === 1 || res.result.page === 0) {
82
+ setResource(resData || []);
83
+ } else {
84
+ setResource([].concat(_toConsumableArray(resource), _toConsumableArray(resData)));
85
+ }
86
+ setTotalPage(res.result.totalPage);
87
+ _context.next = 14;
88
+ break;
89
+ case 13:
90
+ setResource([]);
91
+ case 14:
92
+ _context.next = 19;
93
+ break;
94
+ case 16:
95
+ _context.prev = 16;
96
+ _context.t0 = _context["catch"](0);
97
+ setResource([]);
98
+ case 19:
99
+ case "end":
100
+ return _context.stop();
101
+ }
102
+ }, _callee, null, [[0, 16]]);
103
+ }));
104
+ return function getVideoResource() {
105
+ return _ref2.apply(this, arguments);
106
+ };
107
+ }();
108
+ var getCourseResource = /*#__PURE__*/function () {
109
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
110
+ var params, res, resData;
111
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
112
+ while (1) switch (_context2.prev = _context2.next) {
113
+ case 0:
114
+ _context2.prev = 0;
115
+ params = {
116
+ pageIndex: searchValue.pageIndex || 1,
117
+ pageSize: searchValue.pageSize || 20,
118
+ where: {
119
+ productName: searchValue.inputValue || ''
120
+ }
121
+ };
122
+ _context2.next = 4;
123
+ return getReferenceCourseList(params);
124
+ case 4:
125
+ res = _context2.sent;
126
+ if (!(latestTypeRef.current !== 'course')) {
127
+ _context2.next = 7;
128
+ break;
129
+ }
130
+ return _context2.abrupt("return");
131
+ case 7:
132
+ if (res.status === 0 && res.result) {
133
+ resData = handleData(res.result.data || []);
134
+ if (res.result.page === 1 || res.result.page === 0) {
135
+ setResource(resData || []);
136
+ } else {
137
+ setResource([].concat(_toConsumableArray(resource), _toConsumableArray(resData)));
138
+ }
139
+ setTotalPage(res.result.totalPage);
140
+ } else {
141
+ setResource([]);
142
+ }
143
+ _context2.next = 13;
144
+ break;
145
+ case 10:
146
+ _context2.prev = 10;
147
+ _context2.t0 = _context2["catch"](0);
148
+ setResource([]);
149
+ case 13:
150
+ case "end":
151
+ return _context2.stop();
152
+ }
153
+ }, _callee2, null, [[0, 10]]);
154
+ }));
155
+ return function getCourseResource() {
156
+ return _ref3.apply(this, arguments);
157
+ };
158
+ }();
159
+ useEffect(function () {
160
+ latestTypeRef.current = type;
161
+ var getData = /*#__PURE__*/function () {
162
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
163
+ var api;
164
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
165
+ while (1) switch (_context3.prev = _context3.next) {
166
+ case 0:
167
+ setIsloading(true);
168
+ _context3.prev = 1;
169
+ api = type === 'video' ? getVideoResource : getCourseResource;
170
+ _context3.next = 5;
171
+ return api();
172
+ case 5:
173
+ setIsloading(false);
174
+ _context3.next = 11;
175
+ break;
176
+ case 8:
177
+ _context3.prev = 8;
178
+ _context3.t0 = _context3["catch"](1);
179
+ console.error(_context3.t0);
180
+ case 11:
181
+ case "end":
182
+ return _context3.stop();
183
+ }
184
+ }, _callee3, null, [[1, 8]]);
185
+ }));
186
+ return function getData() {
187
+ return _ref4.apply(this, arguments);
188
+ };
189
+ }();
190
+ if (showmodel) {
191
+ getData();
192
+ }
193
+ ;
194
+ }, [searchValue, type, showmodel]);
195
+ return {
196
+ isLoading: isLoading,
197
+ totalPage: totalPage,
198
+ resource: resource,
199
+ getVideoResource: getVideoResource
200
+ };
201
+ };
202
+ export default useQuotedService;
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * from './components';
2
+ export * from './types';
3
+ export * from './interfaces';
package/dist/index.js CHANGED
@@ -1 +1,3 @@
1
- export * from "./components";
1
+ export * from "./components";
2
+ export * from "./types";
3
+ export * from "./interfaces";
@@ -0,0 +1,3 @@
1
+ export * from './chatMessage';
2
+ export * from './fileInterface';
3
+ export * from './knowledgeTrace';
@@ -0,0 +1,3 @@
1
+ export * from "./chatMessage";
2
+ export * from "./fileInterface";
3
+ export * from "./knowledgeTrace";
@@ -0,0 +1,16 @@
1
+ export type MCPItem = {
2
+ name: string;
3
+ // executeWorkflowByDescription: 查询工作流
4
+ // notifyWorkflowStart: 开始执行工作流
5
+ // executeWorkflowById: 这个节点表示此条无效mcp应该被过滤掉
6
+ // interrupt: 前端自定义打断状态
7
+ status: 'executeWorkflowByDescription' | 'notifyWorkflowStart' | 'executeWorkflowById' | 'interrupt';
8
+ }
9
+
10
+ export type KonwledgeType = 'video' | 'document' | 'product';
11
+
12
+ export interface KonwledgeTraceState {
13
+ type: KonwledgeType;
14
+ resources: {id: string, productIds?: number[]}[];
15
+ messageId: number | null;
16
+ }