@myun/gimi-chat 0.0.3 → 0.0.5
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/apis/fetch.d.ts +64 -0
- package/dist/apis/fetch.js +512 -0
- package/dist/apis/useApi.d.ts +57 -0
- package/dist/apis/useApi.js +378 -0
- package/dist/assets/image/Subtract.png +0 -0
- package/dist/assets/image/ai-logo.png +0 -0
- package/dist/assets/image/copyIcon.png +0 -0
- package/dist/assets/image/deepthinkActive.png +0 -0
- package/dist/assets/image/empty-img-dark.png +0 -0
- package/dist/assets/image/empty-img.png +0 -0
- package/dist/assets/image/like_active.png +0 -0
- package/dist/assets/image/love.png +0 -0
- package/dist/assets/image/retry.png +0 -0
- package/dist/assets/image/soundOut.png +0 -0
- package/dist/assets/image/unlike_active.png +0 -0
- package/dist/assets/image/unlove.png +0 -0
- package/dist/assets/lottie/ai-bg.json +1704 -0
- package/dist/assets/lottie/ai-loading.json +192 -0
- package/dist/assets/lottie/ai-output-loading.json +272 -0
- package/dist/assets/lottie/ai-output-normal.json +17694 -0
- package/dist/assets/lottie/ai-output-strengthen.json +17321 -0
- package/dist/assets/lottie/ai-voice-play.json +1 -0
- package/dist/assets/lottie/living.json +705 -0
- package/dist/assets/lottie/myun-living.json +726 -0
- package/dist/assets/lottie/myun-loading.json +530 -0
- package/dist/components/ai-chat-dialogue/index.d.ts +16 -0
- package/dist/components/ai-chat-dialogue/index.js +1056 -0
- package/dist/components/ai-chat-dialogue/index.module.css +230 -0
- package/dist/components/ai-chat-dialogue/message-parser.d.ts +36 -0
- package/dist/components/ai-chat-dialogue/message-parser.js +52 -0
- package/dist/components/ai-chat-dialogue/tlv.d.ts +7 -0
- package/dist/components/ai-chat-dialogue/tlv.js +32 -0
- package/dist/components/ai-chat-dialogue/volc-voice-call-client.d.ts +47 -0
- package/dist/components/ai-chat-dialogue/volc-voice-call-client.js +246 -0
- package/dist/components/ai-correction/index.d.ts +5 -0
- package/dist/components/ai-correction/index.js +45 -0
- package/dist/components/ai-loading/index.d.ts +3 -0
- package/dist/components/ai-loading/index.js +14 -0
- package/dist/components/ai-loading/index.module.css +11 -0
- package/dist/components/answer-item/index.d.ts +27 -0
- package/dist/components/answer-item/index.js +194 -0
- package/dist/components/answer-item/index.module.css +266 -0
- package/dist/components/ask-card/index.d.ts +10 -0
- package/dist/components/ask-card/index.js +76 -0
- package/dist/components/ask-card/index.module.css +122 -0
- package/dist/components/chat-input/index.d.ts +31 -0
- package/dist/components/chat-input/index.js +433 -0
- package/dist/components/chat-input/index.module.css +42 -0
- package/dist/components/chat-voice/VoiceCommunication.d.ts +7 -0
- package/dist/components/chat-voice/VoiceCommunication.js +69 -0
- package/dist/components/chat-voice/VoiceRecord.d.ts +7 -0
- package/dist/components/chat-voice/VoiceRecord.js +34 -0
- package/dist/components/conversation-delete/index.d.ts +5 -0
- package/dist/components/conversation-delete/index.js +24 -0
- package/dist/components/dots-loading/index.d.ts +2 -0
- package/dist/components/dots-loading/index.js +11 -0
- package/dist/components/dots-loading/index.module.css +41 -0
- package/dist/components/empty/index.d.ts +9 -0
- package/dist/components/empty/index.js +32 -0
- package/dist/components/empty/index.module.css +24 -0
- package/dist/components/excel-components/ExcelCard.d.ts +11 -0
- package/dist/components/excel-components/ExcelCard.js +35 -0
- package/dist/components/excel-components/ExcelExcuting.d.ts +10 -0
- package/dist/components/excel-components/ExcelExcuting.js +263 -0
- package/dist/components/excel-components/ExcelFailCard.d.ts +9 -0
- package/dist/components/excel-components/ExcelFailCard.js +20 -0
- package/dist/components/excel-components/ExcelSuccessCard.d.ts +5 -0
- package/dist/components/excel-components/ExcelSuccessCard.js +50 -0
- package/dist/components/excel-components/index.module.css +212 -0
- package/dist/components/excel-components/styles.module.css +178 -0
- package/dist/components/file-card/fileCardSidebar.d.ts +8 -0
- package/dist/components/file-card/fileCardSidebar.js +56 -0
- package/dist/components/file-card/index.d.ts +15 -0
- package/dist/components/file-card/index.js +97 -0
- package/dist/components/file-card/index.module.css +139 -0
- package/dist/components/file-preview/index.d.ts +3 -0
- package/dist/components/file-preview/index.js +227 -0
- package/dist/components/file-preview/index.module.css +83 -0
- package/dist/components/file-upload/index.d.ts +16 -0
- package/dist/components/file-upload/index.js +238 -0
- package/dist/components/file-upload/uploadV1.d.ts +16 -0
- package/dist/components/file-upload/uploadV1.js +267 -0
- package/dist/components/gimi-sidebar/index.d.ts +17 -0
- package/dist/components/gimi-sidebar/index.js +41 -0
- package/dist/components/gimi-sidebar/index.module.css +118 -0
- package/dist/components/header/index.d.ts +5 -0
- package/dist/components/header/index.js +20 -0
- package/dist/components/header/index.module.css +19 -0
- package/dist/components/iconfont-com/index.d.ts +11 -0
- package/dist/components/iconfont-com/index.js +29 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/knowledge-trace/KnowledgeIconComponent.d.ts +7 -0
- package/dist/components/knowledge-trace/KnowledgeIconComponent.js +101 -0
- package/dist/components/knowledge-trace/classList.d.ts +6 -0
- package/dist/components/knowledge-trace/classList.js +72 -0
- package/dist/components/knowledge-trace/documentList.d.ts +6 -0
- package/dist/components/knowledge-trace/documentList.js +75 -0
- package/dist/components/knowledge-trace/index.d.ts +18 -0
- package/dist/components/knowledge-trace/index.js +155 -0
- package/dist/components/knowledge-trace/index.module.css +254 -0
- package/dist/components/knowledge-trace/interfaces.d.ts +166 -0
- package/dist/components/knowledge-trace/interfaces.js +1 -0
- package/dist/components/knowledge-trace/videoList.d.ts +6 -0
- package/dist/components/knowledge-trace/videoList.js +91 -0
- package/dist/components/lottie-img/index.d.ts +8 -0
- package/dist/components/lottie-img/index.js +99 -0
- package/dist/components/message-actions/CopyButton.d.ts +7 -0
- package/dist/components/message-actions/CopyButton.js +33 -0
- package/dist/components/message-actions/LikeButton.d.ts +7 -0
- package/dist/components/message-actions/LikeButton.js +34 -0
- package/dist/components/message-actions/RegenerateButton.d.ts +5 -0
- package/dist/components/message-actions/RegenerateButton.js +27 -0
- package/dist/components/message-actions/UnLikeButton.d.ts +7 -0
- package/dist/components/message-actions/UnLikeButton.js +34 -0
- package/dist/components/message-actions/VoicePlay.d.ts +10 -0
- package/dist/components/message-actions/VoicePlay.js +74 -0
- package/dist/components/message-list/index.d.ts +19 -0
- package/dist/components/message-list/index.js +164 -0
- package/dist/components/message-list/index.module.css +261 -0
- package/dist/components/no-microphone-root/index.d.ts +6 -0
- package/dist/components/no-microphone-root/index.js +36 -0
- package/dist/components/no-microphone-root/index.module.css +48 -0
- package/dist/components/preset-agent-content/index.d.ts +8 -0
- package/dist/components/preset-agent-content/index.js +24 -0
- package/dist/components/preset-agent-content/index.module.css +46 -0
- package/dist/components/quoted-content/index.d.ts +0 -0
- package/dist/components/quoted-content/index.js +171 -0
- package/dist/components/quoted-content/index.module.css +80 -0
- package/dist/components/reasoning-content/index.d.ts +6 -0
- package/dist/components/reasoning-content/index.js +116 -0
- package/dist/components/reasoning-content/index.module.css +169 -0
- package/dist/components/reference-content/index.d.ts +28 -0
- package/dist/components/reference-content/index.js +125 -0
- package/dist/components/reference-content/index.module.css +84 -0
- package/dist/components/templates/CommonChat.d.ts +5 -0
- package/dist/components/templates/CommonChat.js +218 -0
- package/dist/components/templates/GimiChatComponent.d.ts +4 -0
- package/dist/components/templates/GimiChatComponent.js +23 -0
- package/dist/components/templates/demo/demo.d.ts +2 -0
- package/dist/components/templates/demo/demo.js +109 -0
- package/dist/components/templates/index.module.css +109 -0
- package/dist/components/upload-list/index.d.ts +15 -0
- package/dist/components/upload-list/index.js +90 -0
- package/dist/components/upload-list/index.module.css +119 -0
- package/dist/components/voice-bars/index.d.ts +4 -0
- package/dist/components/voice-bars/index.js +174 -0
- package/dist/components/voice-check-dialog/index.d.ts +8 -0
- package/dist/components/voice-check-dialog/index.js +163 -0
- package/dist/components/voice-check-dialog/index.module.css +9 -0
- package/dist/components/voice-recording/index.d.ts +9 -0
- package/dist/components/voice-recording/index.js +54 -0
- package/dist/components/voice-recording/index.module.css +41 -0
- package/dist/components/work-flow-content/demo.d.ts +3 -0
- package/dist/components/work-flow-content/demo.js +11 -0
- package/dist/components/work-flow-content/index.d.ts +6 -0
- package/dist/components/work-flow-content/index.js +55 -0
- package/dist/components/work-flow-content/index.module.css +24 -0
- package/dist/constants.d.ts +24 -0
- package/dist/constants.js +24 -0
- package/dist/hooks/useChatActions.d.ts +12 -0
- package/dist/hooks/useChatActions.js +207 -0
- package/dist/hooks/useChatHistory.d.ts +8 -0
- package/dist/hooks/useChatHistory.js +225 -0
- package/dist/hooks/useChatMessage.d.ts +49 -0
- package/dist/hooks/useChatMessage.js +87 -0
- package/dist/hooks/useChatRecommend.d.ts +8 -0
- package/dist/hooks/useChatRecommend.js +126 -0
- package/dist/hooks/useChatStream.d.ts +20 -0
- package/dist/hooks/useChatStream.js +244 -0
- package/dist/hooks/useChatUI.d.ts +32 -0
- package/dist/hooks/useChatUI.js +134 -0
- package/dist/hooks/useChatVoice.d.ts +11 -0
- package/dist/hooks/useChatVoice.js +379 -0
- package/dist/hooks/useCommonChatAPI.d.ts +27 -0
- package/dist/hooks/useCommonChatAPI.js +1276 -0
- package/dist/hooks/useFile.d.ts +13 -0
- package/dist/hooks/useFile.js +288 -0
- package/dist/hooks/useKnowledgeService.d.ts +17 -0
- package/dist/hooks/useKnowledgeService.js +210 -0
- package/dist/hooks/useLastEventId.d.ts +8 -0
- package/dist/hooks/useLastEventId.js +66 -0
- package/dist/hooks/useLongPoll.d.ts +3 -0
- package/dist/hooks/useLongPoll.js +111 -0
- package/dist/hooks/useScroll.d.ts +4 -0
- package/dist/hooks/useScroll.js +172 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/chatMessage.d.ts +139 -0
- package/dist/interfaces/fileInterface.d.ts +10 -0
- package/dist/interfaces/fileInterface.js +11 -0
- package/dist/interfaces/knowledgeTrace.d.ts +177 -0
- package/dist/store/hooks.d.ts +4 -0
- package/dist/store/hooks.js +3 -0
- package/dist/store/index.d.ts +7 -0
- package/dist/store/index.js +7 -0
- package/dist/store/slices/gimiMenuSlice.d.ts +95 -0
- package/dist/store/slices/gimiMenuSlice.js +251 -0
- package/dist/utils/chatInputUtil.d.ts +19 -0
- package/dist/utils/chatInputUtil.js +45 -0
- package/dist/utils/tools.d.ts +50 -0
- package/dist/utils/tools.js +474 -0
- package/dist/utils/voice-stream.d.ts +119 -0
- package/dist/utils/voice-stream.js +1162 -0
- package/package.json +5 -6
- package/LICENSE +0 -21
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Reducer } from '@reduxjs/toolkit';
|
|
2
|
+
import type { KonwledgeTraceState } from '../../types/answer';
|
|
3
|
+
import type { FileItem, IFileCardProps } from '../../types/file';
|
|
4
|
+
import { IChatMessageItem } from '../../interfaces/chatMessage';
|
|
5
|
+
export interface GimiMenuState {
|
|
6
|
+
platform: 'myun' | 'preview' | 'damai';
|
|
7
|
+
token: string;
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
conversationId: number | null;
|
|
10
|
+
messageList: IChatMessageItem[];
|
|
11
|
+
isMsgRecieving: boolean;
|
|
12
|
+
currentMessageId: number | null;
|
|
13
|
+
historyList: any[];
|
|
14
|
+
loading: boolean;
|
|
15
|
+
loadingMore: boolean;
|
|
16
|
+
hasMore: boolean;
|
|
17
|
+
params: {
|
|
18
|
+
pageIndex: number;
|
|
19
|
+
pageSize: number;
|
|
20
|
+
};
|
|
21
|
+
bussinessParams: Record<string, any>;
|
|
22
|
+
agentObj: any;
|
|
23
|
+
deepStatus: number;
|
|
24
|
+
expend: boolean;
|
|
25
|
+
isShowConversation: any;
|
|
26
|
+
menuName: string;
|
|
27
|
+
fileList: FileItem[];
|
|
28
|
+
konwledgeTraceState: KonwledgeTraceState;
|
|
29
|
+
showKonwledgeTrace: boolean;
|
|
30
|
+
showSidebarFileList: boolean;
|
|
31
|
+
sidebarFileList: IFileCardProps[];
|
|
32
|
+
filePreviewState: {
|
|
33
|
+
show: boolean;
|
|
34
|
+
url: string;
|
|
35
|
+
filename: string;
|
|
36
|
+
};
|
|
37
|
+
quoteProductList: {
|
|
38
|
+
productId: number;
|
|
39
|
+
productName: string;
|
|
40
|
+
}[];
|
|
41
|
+
quoteTeachModelList: {
|
|
42
|
+
teachModelId: number;
|
|
43
|
+
teachModelName: string;
|
|
44
|
+
type?: string;
|
|
45
|
+
duration: number;
|
|
46
|
+
}[];
|
|
47
|
+
displayImage: number;
|
|
48
|
+
imageUrl: string;
|
|
49
|
+
showMicWarning: boolean;
|
|
50
|
+
}
|
|
51
|
+
export declare const getChatHistoryList: import("@reduxjs/toolkit").AsyncThunk<{
|
|
52
|
+
data: any;
|
|
53
|
+
last: any;
|
|
54
|
+
loadMore: boolean;
|
|
55
|
+
}, {
|
|
56
|
+
pageIndex: number;
|
|
57
|
+
pageSize: number;
|
|
58
|
+
loadMore?: boolean | undefined;
|
|
59
|
+
}, import("@reduxjs/toolkit").AsyncThunkConfig>;
|
|
60
|
+
export declare const setAgentDetail: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
61
|
+
agentDetail: any;
|
|
62
|
+
}, "gimiMenu/setAgentDetail">, setConversationId: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
63
|
+
conversationId: number | null;
|
|
64
|
+
}, "gimiMenu/setConversationId">, setIsMsgRecieving: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
65
|
+
isMsgRecieving: boolean;
|
|
66
|
+
}, "gimiMenu/setIsMsgRecieving">, setBaseUrl: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
67
|
+
baseUrl: string;
|
|
68
|
+
}, "gimiMenu/setBaseUrl">, setToken: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
69
|
+
token: string;
|
|
70
|
+
}, "gimiMenu/setToken">, setPlatform: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
71
|
+
platform: 'myun' | 'preview' | 'damai';
|
|
72
|
+
}, "gimiMenu/setPlatform">, updateState: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<GimiMenuState>, "gimiMenu/updateState">, setMessageList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
73
|
+
messageList: IChatMessageItem[];
|
|
74
|
+
}, "gimiMenu/setMessageList">, setFileList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
75
|
+
fileList: FileItem[];
|
|
76
|
+
}, "gimiMenu/setFileList">, setCurrentMessageId: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
77
|
+
currentMessageId: number;
|
|
78
|
+
}, "gimiMenu/setCurrentMessageId">, updateParams: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<{
|
|
79
|
+
pageIndex: number;
|
|
80
|
+
pageSize: number;
|
|
81
|
+
}>, "gimiMenu/updateParams">, setShowKonwledgeTrace: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
82
|
+
showKonwledgeTrace: boolean;
|
|
83
|
+
}, "gimiMenu/setShowKonwledgeTrace">, setShowSidebarFileList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
84
|
+
showSidebarFileList: boolean;
|
|
85
|
+
}, "gimiMenu/setShowSidebarFileList">, setSidebarFileList: import("@reduxjs/toolkit").ActionCreatorWithPayload<IFileCardProps[], "gimiMenu/setSidebarFileList">, setKonwledgeTraceState: import("@reduxjs/toolkit").ActionCreatorWithPayload<KonwledgeTraceState, "gimiMenu/setKonwledgeTraceState">, setFilePreviewState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
86
|
+
filePreviewState: Partial<GimiMenuState['filePreviewState']>;
|
|
87
|
+
}, "gimiMenu/setFilePreviewState">, setQuoteProductList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
88
|
+
quoteProductList: GimiMenuState['quoteProductList'];
|
|
89
|
+
}, "gimiMenu/setQuoteProductList">, setQuoteTeachModelList: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
90
|
+
quoteTeachModelList: GimiMenuState['quoteTeachModelList'];
|
|
91
|
+
}, "gimiMenu/setQuoteTeachModelList">, setShowMicWarning: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
92
|
+
showMicWarning: boolean;
|
|
93
|
+
}, "gimiMenu/setShowMicWarning">, setBussinessParams: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<Record<string, any>>, "gimiMenu/setBussinessParams">;
|
|
94
|
+
declare const reducer: Reducer<GimiMenuState>;
|
|
95
|
+
export default reducer;
|
|
@@ -0,0 +1,251 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
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."); }
|
|
4
|
+
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); }
|
|
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 _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; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
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); } }
|
|
15
|
+
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); }); }; }
|
|
16
|
+
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
|
|
17
|
+
import { createFetch } from "../../apis/fetch";
|
|
18
|
+
var initialState = {
|
|
19
|
+
platform: 'myun',
|
|
20
|
+
token: '',
|
|
21
|
+
baseUrl: '',
|
|
22
|
+
conversationId: null,
|
|
23
|
+
messageList: [],
|
|
24
|
+
isMsgRecieving: false,
|
|
25
|
+
currentMessageId: null,
|
|
26
|
+
historyList: [],
|
|
27
|
+
loading: false,
|
|
28
|
+
loadingMore: false,
|
|
29
|
+
hasMore: true,
|
|
30
|
+
params: {
|
|
31
|
+
pageIndex: 1,
|
|
32
|
+
pageSize: 50
|
|
33
|
+
},
|
|
34
|
+
bussinessParams: {},
|
|
35
|
+
agentObj: {},
|
|
36
|
+
deepStatus: 0,
|
|
37
|
+
expend: false,
|
|
38
|
+
isShowConversation: 0,
|
|
39
|
+
menuName: '',
|
|
40
|
+
fileList: [],
|
|
41
|
+
konwledgeTraceState: {
|
|
42
|
+
type: 'video',
|
|
43
|
+
resources: [],
|
|
44
|
+
messageId: null
|
|
45
|
+
},
|
|
46
|
+
showKonwledgeTrace: false,
|
|
47
|
+
showSidebarFileList: false,
|
|
48
|
+
sidebarFileList: [],
|
|
49
|
+
filePreviewState: {
|
|
50
|
+
show: false,
|
|
51
|
+
url: '',
|
|
52
|
+
filename: ''
|
|
53
|
+
},
|
|
54
|
+
quoteProductList: [],
|
|
55
|
+
quoteTeachModelList: [],
|
|
56
|
+
displayImage: 1,
|
|
57
|
+
imageUrl: '',
|
|
58
|
+
showMicWarning: false
|
|
59
|
+
};
|
|
60
|
+
export var getChatHistoryList = createAsyncThunk('gimiMenu/getChatHistoryList', /*#__PURE__*/function () {
|
|
61
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(payload, _ref) {
|
|
62
|
+
var rejectWithValue, getState, pageIndex, pageSize, params, state, api, res;
|
|
63
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
64
|
+
while (1) switch (_context.prev = _context.next) {
|
|
65
|
+
case 0:
|
|
66
|
+
rejectWithValue = _ref.rejectWithValue, getState = _ref.getState;
|
|
67
|
+
pageIndex = payload.pageIndex, pageSize = payload.pageSize;
|
|
68
|
+
params = {
|
|
69
|
+
pageIndex: pageIndex,
|
|
70
|
+
pageSize: pageSize,
|
|
71
|
+
where: {
|
|
72
|
+
conversationTypes: [2, 3]
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
_context.prev = 3;
|
|
76
|
+
state = getState();
|
|
77
|
+
api = createFetch({
|
|
78
|
+
baseURL: state.gimiMenu.baseUrl,
|
|
79
|
+
timeout: 10000
|
|
80
|
+
});
|
|
81
|
+
_context.next = 8;
|
|
82
|
+
return api.get('/chat/history', {
|
|
83
|
+
params: params
|
|
84
|
+
});
|
|
85
|
+
case 8:
|
|
86
|
+
res = _context.sent;
|
|
87
|
+
if (!((res === null || res === void 0 ? void 0 : res.status) === 0)) {
|
|
88
|
+
_context.next = 11;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
return _context.abrupt("return", {
|
|
92
|
+
data: res.result.data || [],
|
|
93
|
+
last: res.result.last,
|
|
94
|
+
loadMore: payload.loadMore || false
|
|
95
|
+
});
|
|
96
|
+
case 11:
|
|
97
|
+
return _context.abrupt("return", rejectWithValue('获取历史记录失败'));
|
|
98
|
+
case 14:
|
|
99
|
+
_context.prev = 14;
|
|
100
|
+
_context.t0 = _context["catch"](3);
|
|
101
|
+
return _context.abrupt("return", rejectWithValue(_context.t0));
|
|
102
|
+
case 17:
|
|
103
|
+
case "end":
|
|
104
|
+
return _context.stop();
|
|
105
|
+
}
|
|
106
|
+
}, _callee, null, [[3, 14]]);
|
|
107
|
+
}));
|
|
108
|
+
return function (_x, _x2) {
|
|
109
|
+
return _ref2.apply(this, arguments);
|
|
110
|
+
};
|
|
111
|
+
}());
|
|
112
|
+
var gimiMenuSlice = createSlice({
|
|
113
|
+
name: 'gimiMenu',
|
|
114
|
+
initialState: initialState,
|
|
115
|
+
reducers: {
|
|
116
|
+
setAgentDetail: function setAgentDetail(state, action) {
|
|
117
|
+
var agentDetail = action.payload.agentDetail;
|
|
118
|
+
state.agentObj = agentDetail;
|
|
119
|
+
},
|
|
120
|
+
setConversationId: function setConversationId(state, action) {
|
|
121
|
+
var conversationId = action.payload.conversationId;
|
|
122
|
+
state.conversationId = conversationId;
|
|
123
|
+
},
|
|
124
|
+
setIsMsgRecieving: function setIsMsgRecieving(state, action) {
|
|
125
|
+
var isMsgRecieving = action.payload.isMsgRecieving;
|
|
126
|
+
state.isMsgRecieving = isMsgRecieving;
|
|
127
|
+
},
|
|
128
|
+
setPlatform: function setPlatform(state, action) {
|
|
129
|
+
var platform = action.payload.platform;
|
|
130
|
+
state.platform = platform;
|
|
131
|
+
},
|
|
132
|
+
setToken: function setToken(state, action) {
|
|
133
|
+
var token = action.payload.token;
|
|
134
|
+
state.token = token;
|
|
135
|
+
},
|
|
136
|
+
setBaseUrl: function setBaseUrl(state, action) {
|
|
137
|
+
var baseUrl = action.payload.baseUrl;
|
|
138
|
+
state.baseUrl = baseUrl;
|
|
139
|
+
},
|
|
140
|
+
setMessageList: function setMessageList(state, action) {
|
|
141
|
+
var messageList = action.payload.messageList;
|
|
142
|
+
state.messageList = messageList;
|
|
143
|
+
},
|
|
144
|
+
setFileList: function setFileList(state, action) {
|
|
145
|
+
var fileList = action.payload.fileList;
|
|
146
|
+
state.fileList = fileList;
|
|
147
|
+
},
|
|
148
|
+
updateState: function updateState(state, action) {
|
|
149
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
150
|
+
},
|
|
151
|
+
setCurrentMessageId: function setCurrentMessageId(state, action) {
|
|
152
|
+
var currentMessageId = action.payload.currentMessageId;
|
|
153
|
+
state.currentMessageId = currentMessageId;
|
|
154
|
+
},
|
|
155
|
+
updateParams: function updateParams(state, action) {
|
|
156
|
+
state.params = _objectSpread(_objectSpread({}, state.params), action.payload);
|
|
157
|
+
},
|
|
158
|
+
setBussinessParams: function setBussinessParams(state, action) {
|
|
159
|
+
state.bussinessParams = _objectSpread(_objectSpread({}, state.bussinessParams), action.payload);
|
|
160
|
+
},
|
|
161
|
+
setShowKonwledgeTrace: function setShowKonwledgeTrace(state, action) {
|
|
162
|
+
var showKonwledgeTrace = action.payload.showKonwledgeTrace;
|
|
163
|
+
state.showKonwledgeTrace = showKonwledgeTrace;
|
|
164
|
+
if (showKonwledgeTrace) {
|
|
165
|
+
state.filePreviewState.show = false;
|
|
166
|
+
state.showSidebarFileList = false;
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
setShowSidebarFileList: function setShowSidebarFileList(state, action) {
|
|
170
|
+
var showSidebarFileList = action.payload.showSidebarFileList;
|
|
171
|
+
state.showSidebarFileList = showSidebarFileList;
|
|
172
|
+
if (showSidebarFileList) {
|
|
173
|
+
state.filePreviewState.show = false;
|
|
174
|
+
state.showKonwledgeTrace = false;
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
setSidebarFileList: function setSidebarFileList(state, action) {
|
|
178
|
+
state.sidebarFileList = action.payload;
|
|
179
|
+
},
|
|
180
|
+
setKonwledgeTraceState: function setKonwledgeTraceState(state, action) {
|
|
181
|
+
state.konwledgeTraceState = action.payload;
|
|
182
|
+
},
|
|
183
|
+
setFilePreviewState: function setFilePreviewState(state, action) {
|
|
184
|
+
var filePreviewState = action.payload.filePreviewState;
|
|
185
|
+
state.filePreviewState = _objectSpread(_objectSpread({}, state.filePreviewState), filePreviewState);
|
|
186
|
+
if (filePreviewState.show) {
|
|
187
|
+
state.showKonwledgeTrace = false;
|
|
188
|
+
state.showSidebarFileList = false;
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
setQuoteProductList: function setQuoteProductList(state, action) {
|
|
192
|
+
state.quoteProductList = action.payload.quoteProductList;
|
|
193
|
+
},
|
|
194
|
+
setQuoteTeachModelList: function setQuoteTeachModelList(state, action) {
|
|
195
|
+
state.quoteTeachModelList = action.payload.quoteTeachModelList;
|
|
196
|
+
},
|
|
197
|
+
setShowMicWarning: function setShowMicWarning(state, action) {
|
|
198
|
+
state.showMicWarning = action.payload.showMicWarning;
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
extraReducers: function extraReducers(builder) {
|
|
202
|
+
builder.addCase(getChatHistoryList.pending, function (state, action) {
|
|
203
|
+
var loadMore = action.meta.arg.loadMore;
|
|
204
|
+
if (loadMore) {
|
|
205
|
+
state.loadingMore = true;
|
|
206
|
+
} else {
|
|
207
|
+
state.loading = true;
|
|
208
|
+
}
|
|
209
|
+
}).addCase(getChatHistoryList.fulfilled, function (state, action) {
|
|
210
|
+
var _action$payload = action.payload,
|
|
211
|
+
data = _action$payload.data,
|
|
212
|
+
last = _action$payload.last,
|
|
213
|
+
loadMore = _action$payload.loadMore;
|
|
214
|
+
if (loadMore) {
|
|
215
|
+
state.historyList = [].concat(_toConsumableArray(state.historyList), _toConsumableArray(data));
|
|
216
|
+
} else {
|
|
217
|
+
state.historyList = data;
|
|
218
|
+
}
|
|
219
|
+
state.hasMore = !last;
|
|
220
|
+
state.loading = false;
|
|
221
|
+
state.loadingMore = false;
|
|
222
|
+
}).addCase(getChatHistoryList.rejected, function (state) {
|
|
223
|
+
state.loading = false;
|
|
224
|
+
state.loadingMore = false;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
var _gimiMenuSlice$action = gimiMenuSlice.actions,
|
|
229
|
+
setAgentDetail = _gimiMenuSlice$action.setAgentDetail,
|
|
230
|
+
setConversationId = _gimiMenuSlice$action.setConversationId,
|
|
231
|
+
setIsMsgRecieving = _gimiMenuSlice$action.setIsMsgRecieving,
|
|
232
|
+
setBaseUrl = _gimiMenuSlice$action.setBaseUrl,
|
|
233
|
+
setToken = _gimiMenuSlice$action.setToken,
|
|
234
|
+
setPlatform = _gimiMenuSlice$action.setPlatform,
|
|
235
|
+
updateState = _gimiMenuSlice$action.updateState,
|
|
236
|
+
setMessageList = _gimiMenuSlice$action.setMessageList,
|
|
237
|
+
setFileList = _gimiMenuSlice$action.setFileList,
|
|
238
|
+
setCurrentMessageId = _gimiMenuSlice$action.setCurrentMessageId,
|
|
239
|
+
updateParams = _gimiMenuSlice$action.updateParams,
|
|
240
|
+
setShowKonwledgeTrace = _gimiMenuSlice$action.setShowKonwledgeTrace,
|
|
241
|
+
setShowSidebarFileList = _gimiMenuSlice$action.setShowSidebarFileList,
|
|
242
|
+
setSidebarFileList = _gimiMenuSlice$action.setSidebarFileList,
|
|
243
|
+
setKonwledgeTraceState = _gimiMenuSlice$action.setKonwledgeTraceState,
|
|
244
|
+
setFilePreviewState = _gimiMenuSlice$action.setFilePreviewState,
|
|
245
|
+
setQuoteProductList = _gimiMenuSlice$action.setQuoteProductList,
|
|
246
|
+
setQuoteTeachModelList = _gimiMenuSlice$action.setQuoteTeachModelList,
|
|
247
|
+
setShowMicWarning = _gimiMenuSlice$action.setShowMicWarning,
|
|
248
|
+
setBussinessParams = _gimiMenuSlice$action.setBussinessParams;
|
|
249
|
+
export { setAgentDetail, setConversationId, setIsMsgRecieving, setBaseUrl, setToken, setPlatform, updateState, setMessageList, setFileList, setCurrentMessageId, updateParams, setShowKonwledgeTrace, setShowSidebarFileList, setSidebarFileList, setKonwledgeTraceState, setFilePreviewState, setQuoteProductList, setQuoteTeachModelList, setShowMicWarning, setBussinessParams };
|
|
250
|
+
var reducer = gimiMenuSlice.reducer;
|
|
251
|
+
export default reducer;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将包含双花括号占位符的字符串转换为包含 input-slot 组件的字符串。
|
|
3
|
+
*
|
|
4
|
+
* 该函数会查找所有 `{{content}}` 格式的子串,并将其替换为
|
|
5
|
+
* `<input-slot placeholder="[content]" />`。
|
|
6
|
+
*
|
|
7
|
+
* @param templateString - 包含 `{{...}}` 占位符的原始字符串。
|
|
8
|
+
* @returns 转换后的新字符串。
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const str1 = '我要生成一个{{模板名称,如PVM模板}},用于{{使用场景,如分析增长力}}。数据如下:\n{{直接输入或上传数据进行建模}}';
|
|
12
|
+
* const str2 = transformToInputSlots(str1);
|
|
13
|
+
* console.log(str2);
|
|
14
|
+
* // 输出:
|
|
15
|
+
* // 我要生成一个<input-slot placeholder="[模板名称,如PVM模板]" />,用于<input-slot placeholder="[使用场景,如分析增长力]" />。数据如下:
|
|
16
|
+
* // <input-slot placeholder="[直接输入或上传数据进行建模]" />
|
|
17
|
+
*/
|
|
18
|
+
export declare const transformToInputSlots: (templateString: string) => string;
|
|
19
|
+
export declare const debounce: <T extends (...args: any[]) => any>(func: T, wait: number) => (...args: Parameters<T>) => void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将包含双花括号占位符的字符串转换为包含 input-slot 组件的字符串。
|
|
3
|
+
*
|
|
4
|
+
* 该函数会查找所有 `{{content}}` 格式的子串,并将其替换为
|
|
5
|
+
* `<input-slot placeholder="[content]" />`。
|
|
6
|
+
*
|
|
7
|
+
* @param templateString - 包含 `{{...}}` 占位符的原始字符串。
|
|
8
|
+
* @returns 转换后的新字符串。
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const str1 = '我要生成一个{{模板名称,如PVM模板}},用于{{使用场景,如分析增长力}}。数据如下:\n{{直接输入或上传数据进行建模}}';
|
|
12
|
+
* const str2 = transformToInputSlots(str1);
|
|
13
|
+
* console.log(str2);
|
|
14
|
+
* // 输出:
|
|
15
|
+
* // 我要生成一个<input-slot placeholder="[模板名称,如PVM模板]" />,用于<input-slot placeholder="[使用场景,如分析增长力]" />。数据如下:
|
|
16
|
+
* // <input-slot placeholder="[直接输入或上传数据进行建模]" />
|
|
17
|
+
*/
|
|
18
|
+
export var transformToInputSlots = function transformToInputSlots(templateString) {
|
|
19
|
+
// 1. 定义正则表达式
|
|
20
|
+
var placeholderRegex = /\{\{(.*?)\}\}/g;
|
|
21
|
+
// 2. 使用 replace 方法,并传入一个替换函数
|
|
22
|
+
// 每当正则表达式找到一个匹配项时,这个函数就会被调用
|
|
23
|
+
var resultString = templateString.replace(placeholderRegex, function (match, capturedContent) {
|
|
24
|
+
// match 参数是完整匹配的子串,例如: "{{模板名称,如PVM模板}}"
|
|
25
|
+
// capturedContent 参数是捕获组(.*?)匹配到的内容,例如: "模板名称,如PVM模板"
|
|
26
|
+
return "<input-slot placeholder=\"[".concat(capturedContent, "]\"></input-slot>");
|
|
27
|
+
});
|
|
28
|
+
// 3. 返回最终结果
|
|
29
|
+
return resultString;
|
|
30
|
+
};
|
|
31
|
+
export var debounce = function debounce(func, wait) {
|
|
32
|
+
var timeoutId = null;
|
|
33
|
+
return function () {
|
|
34
|
+
var _this = this;
|
|
35
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
36
|
+
args[_key] = arguments[_key];
|
|
37
|
+
}
|
|
38
|
+
if (timeoutId !== null) {
|
|
39
|
+
clearTimeout(timeoutId);
|
|
40
|
+
}
|
|
41
|
+
timeoutId = setTimeout(function () {
|
|
42
|
+
func.apply(_this, args);
|
|
43
|
+
}, wait);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { IChatMessageItem } from "../interfaces/chatMessage";
|
|
2
|
+
import { FileItem } from "../types/file";
|
|
3
|
+
export declare function downloadExcelByUrl(url: string, fileName?: string): Promise<void>;
|
|
4
|
+
export declare function parseMessageContent(str: string): {
|
|
5
|
+
moduleInfo: any | null;
|
|
6
|
+
content: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function processString(str: string): string;
|
|
9
|
+
export declare const getKnowledgeTraceListFromConent: (matchMessage: IChatMessageItem, sendMessage: IChatMessageItem) => {
|
|
10
|
+
qutoType?: string | undefined;
|
|
11
|
+
type: string;
|
|
12
|
+
resources: any;
|
|
13
|
+
}[];
|
|
14
|
+
/**
|
|
15
|
+
* 指数退避重试逻辑
|
|
16
|
+
* @param fn 要执行的异步函数
|
|
17
|
+
* @param options 重试配置
|
|
18
|
+
*/
|
|
19
|
+
export declare const retryWithExponentialBackoff: <T>(fn: () => Promise<T>, options: {
|
|
20
|
+
maxRetries: number;
|
|
21
|
+
initialDelay: number;
|
|
22
|
+
factor: number;
|
|
23
|
+
onRetry?: ((attempt: number) => void) | undefined;
|
|
24
|
+
}) => Promise<T | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* 将秒数转换为中文格式时间字符串 (时长xxx分钟)
|
|
27
|
+
* @param seconds - 待转换的秒数(必须为非负整数)
|
|
28
|
+
* @returns 格式化后的中文时间字符串
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatSecondsToChinese(seconds: number): number;
|
|
31
|
+
export declare function replaceBraces(str: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* 将字节数转换为KB或MB格式的字符串
|
|
34
|
+
* @param {number} bytes - 字节数
|
|
35
|
+
* @returns {string} 格式化后的大小字符串(**KB 或 **MB)
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatSizeToKB(bytes: number): string;
|
|
38
|
+
export declare const fileValidation: (fileList: FileItem[]) => "" | "文件上传失败,请重试" | "文件解析失败,请重试" | "文件正在上传中,请稍后" | "文件正在解析中,请稍后" | "文件正在重试处理中,请稍后";
|
|
39
|
+
/**
|
|
40
|
+
* 过滤用户输出中与默认模版相同的模板部分
|
|
41
|
+
* @param {*} prompt 我要生成一个{{模版名称}}....
|
|
42
|
+
* @param {*} input 用户输入的内容
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
export declare function filterPropmptFromUserInput(prompt: string, input: string): string;
|
|
46
|
+
export declare const updatedSkillResult: (resData: any) => any;
|
|
47
|
+
export declare function getValueFromDynamicKey(jsonStr: string): any;
|
|
48
|
+
export declare function getSelectValue(content: string, moduleInfo: any, isLastItem: boolean, nextItem: IChatMessageItem | undefined): any;
|
|
49
|
+
export declare function getDisableUploadFile(content: string, moduleInfo: any, isLastItem: boolean): boolean;
|
|
50
|
+
export declare function formatFields(dataList: IChatMessageItem[], chatList: IChatMessageItem[]): IChatMessageItem[];
|