@myun/gimi-chat 0.2.0 → 0.2.2
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/useApi.d.ts +3 -0
- package/dist/apis/useApi.js +24 -3
- package/dist/client/components/history-list/index.js +10 -6
- package/dist/client/components/new-main/index.js +3 -116
- package/dist/client/components/slider/index.d.ts +2 -1
- package/dist/client/components/slider/index.js +9 -21
- package/dist/client/core/chat.js +27 -13
- package/dist/client/core/index.css +6 -3
- package/dist/client/core/index.d.ts +2 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/components/answer-item/index.js +14 -1
- package/dist/components/chat-input/index.js +9 -1
- package/dist/components/chat-input/index.module.css +2 -0
- package/dist/components/message-list/index.module.css +2 -0
- package/dist/components/templates/CommonChat.js +8 -13
- package/dist/components/templates/index.module.css +1 -0
- package/dist/hooks/useChatHistory.js +1 -2
- package/dist/hooks/useChatStream.js +1 -2
- package/dist/hooks/useCommonChatAPI.d.ts +4 -4
- package/dist/hooks/useCommonChatAPI.js +230 -166
- package/dist/store/slices/gimiMenuSlice.d.ts +4 -2
- package/dist/store/slices/gimiMenuSlice.js +16 -15
- package/dist/types/chat.d.ts +2 -0
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
- package/dist/client/components/common-chat/index.d.ts +0 -5
- package/dist/client/components/common-chat/index.js +0 -207
- package/dist/client/components/common-chat/index.module.css +0 -109
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CommonChatProps } from '../../../types/chat';
|
|
3
|
-
import { CommonChatRef } from '../../../types/chat';
|
|
4
|
-
declare const CommonChat: React.ForwardRefExoticComponent<CommonChatProps & React.RefAttributes<CommonChatRef>>;
|
|
5
|
-
export default CommonChat;
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
3
|
-
import { store } from "../../../store";
|
|
4
|
-
import { useAppDispatch, useAppSelector } from "../../../store/hooks";
|
|
5
|
-
import { setBussinessParams } from "../../../store/slices/gimiMenuSlice";
|
|
6
|
-
import useCommonChatAPI from "../../../hooks/useCommonChatAPI";
|
|
7
|
-
import { replaceBraces } from "../../../utils/tools";
|
|
8
|
-
import styles from "./index.module.css";
|
|
9
|
-
import ChatInput from "../../../components/chat-input";
|
|
10
|
-
import MessageList from "../../../components/message-list";
|
|
11
|
-
import PresetAgentContent from "../../../components/preset-agent-content";
|
|
12
|
-
import useChatVoice from "../../../hooks/useChatVoice";
|
|
13
|
-
import { useChatUI } from "../../../hooks/useChatUI";
|
|
14
|
-
import { IconChevronDown } from '@douyinfe/semi-icons';
|
|
15
|
-
import KonwledgeTrace from "../../../components/knowledge-trace";
|
|
16
|
-
import FileCardSideBar from "../../../components/file-card/fileCardSidebar";
|
|
17
|
-
import OfficeFilePreviewPanel from "../../../components/file-preview";
|
|
18
|
-
import AiLoading from "../../../components/ai-loading";
|
|
19
|
-
var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
20
|
-
var _props$businessType = props.businessType,
|
|
21
|
-
businessType = _props$businessType === void 0 ? 'chat' : _props$businessType,
|
|
22
|
-
_props$showInput = props.showInput,
|
|
23
|
-
showInput = _props$showInput === void 0 ? true : _props$showInput,
|
|
24
|
-
_props$showHeader = props.showHeader,
|
|
25
|
-
showHeader = _props$showHeader === void 0 ? true : _props$showHeader,
|
|
26
|
-
_props$chatInputConfi = props.chatInputConfig,
|
|
27
|
-
chatInputConfig = _props$chatInputConfi === void 0 ? {
|
|
28
|
-
enableVoiceRecord: true,
|
|
29
|
-
enableVoiceChat: true,
|
|
30
|
-
enableFileUpload: true
|
|
31
|
-
} : _props$chatInputConfi,
|
|
32
|
-
_props$defaultMessage = props.defaultMessages,
|
|
33
|
-
defaultMessages = _props$defaultMessage === void 0 ? [] : _props$defaultMessage,
|
|
34
|
-
agentId = props.agentId,
|
|
35
|
-
_props$showPrologue = props.showPrologue,
|
|
36
|
-
showPrologue = _props$showPrologue === void 0 ? true : _props$showPrologue,
|
|
37
|
-
_props$model = props.model,
|
|
38
|
-
model = _props$model === void 0 ? 'fullscreen' : _props$model,
|
|
39
|
-
conversationId = props.conversationId,
|
|
40
|
-
bussinessParams = props.bussinessParams;
|
|
41
|
-
var dispatch = useAppDispatch();
|
|
42
|
-
var containerRef = React.useRef(null);
|
|
43
|
-
var chatInputRef = React.useRef(null);
|
|
44
|
-
var messageList = useAppSelector(function (state) {
|
|
45
|
-
return state.gimiMenu.messageList;
|
|
46
|
-
});
|
|
47
|
-
var agentObj = useAppSelector(function (state) {
|
|
48
|
-
return state.gimiMenu.agentObj;
|
|
49
|
-
});
|
|
50
|
-
var storedBaseUrl = useAppSelector(function (state) {
|
|
51
|
-
return state.gimiMenu.baseUrl;
|
|
52
|
-
});
|
|
53
|
-
var storedToken = useAppSelector(function (state) {
|
|
54
|
-
return state.gimiMenu.token;
|
|
55
|
-
});
|
|
56
|
-
var initMsg = useAppSelector(function (state) {
|
|
57
|
-
return state.gimiMenu.initMsg;
|
|
58
|
-
});
|
|
59
|
-
var chatUI = useChatUI();
|
|
60
|
-
var _useChatVoice = useChatVoice(),
|
|
61
|
-
isRecording = _useChatVoice.isRecording,
|
|
62
|
-
recordingCount = _useChatVoice.recordingCount,
|
|
63
|
-
asrText = _useChatVoice.asrText,
|
|
64
|
-
shortAsrClick = _useChatVoice.shortAsrClick,
|
|
65
|
-
isExecuting = _useChatVoice.isExecuting,
|
|
66
|
-
playTTSByText = _useChatVoice.playTTSByText,
|
|
67
|
-
stopTTSByText = _useChatVoice.stopTTSByText,
|
|
68
|
-
isPlaying = _useChatVoice.isPlaying;
|
|
69
|
-
var _useCommonChatAPI = useCommonChatAPI(containerRef, businessType, stopTTSByText, isPlaying, agentId),
|
|
70
|
-
headerValue = _useCommonChatAPI.headerValue,
|
|
71
|
-
msgLoading = _useCommonChatAPI.msgLoading,
|
|
72
|
-
onSucessExcel = _useCommonChatAPI.onSucessExcel,
|
|
73
|
-
handleInterrupt = _useCommonChatAPI.handleInterrupt,
|
|
74
|
-
onFailureExcel = _useCommonChatAPI.onFailureExcel,
|
|
75
|
-
onRetryExcel = _useCommonChatAPI.onRetryExcel,
|
|
76
|
-
disableSend = _useCommonChatAPI.disableSend,
|
|
77
|
-
inputModelRef = _useCommonChatAPI.inputModelRef,
|
|
78
|
-
isMoreLoading = _useCommonChatAPI.isMoreLoading,
|
|
79
|
-
startConversationAndChat = _useCommonChatAPI.startConversationAndChat,
|
|
80
|
-
getContentMessageList = _useCommonChatAPI.getContentMessageList,
|
|
81
|
-
hasMore = _useCommonChatAPI.hasMore,
|
|
82
|
-
handleSend = _useCommonChatAPI.handleSend,
|
|
83
|
-
scrollBottomForce = _useCommonChatAPI.scrollBottomForce,
|
|
84
|
-
showBackBottom = _useCommonChatAPI.showBackBottom,
|
|
85
|
-
isScrolling = _useCommonChatAPI.isScrolling,
|
|
86
|
-
regenerate = _useCommonChatAPI.regenerate,
|
|
87
|
-
startAICorrection = _useCommonChatAPI.startAICorrection;
|
|
88
|
-
React.useImperativeHandle(ref, function () {
|
|
89
|
-
return {
|
|
90
|
-
messageList: messageList,
|
|
91
|
-
agentDetail: agentObj,
|
|
92
|
-
conversationId: store.getState().gimiMenu.conversationId,
|
|
93
|
-
inputEditor: chatInputRef.current
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
React.useEffect(function () {
|
|
97
|
-
// 组件初始化
|
|
98
|
-
dispatch(setBussinessParams({
|
|
99
|
-
bussinessParams: bussinessParams || {}
|
|
100
|
-
}));
|
|
101
|
-
}, [bussinessParams]);
|
|
102
|
-
React.useEffect(function () {
|
|
103
|
-
if (bussinessParams !== null && bussinessParams !== void 0 && bussinessParams.QUESTION_ID && bussinessParams !== null && bussinessParams !== void 0 && bussinessParams.ANSWER_ID && businessType === 'correction' && storedBaseUrl && storedToken) {
|
|
104
|
-
startAICorrection(bussinessParams.ANSWER_ID, bussinessParams.QUESTION_ID);
|
|
105
|
-
}
|
|
106
|
-
}, [bussinessParams, storedBaseUrl, storedToken, businessType]);
|
|
107
|
-
var disableVoiceCommunication = React.useMemo(function () {
|
|
108
|
-
var lastedMessage = messageList[messageList.length - 1];
|
|
109
|
-
var content = (lastedMessage === null || lastedMessage === void 0 ? void 0 : lastedMessage.content) || '';
|
|
110
|
-
if (content.indexOf('<excel>') > -1) return true;
|
|
111
|
-
if (['ask', 'skill'].includes((lastedMessage === null || lastedMessage === void 0 ? void 0 : lastedMessage.moduleType) || '')) return true;
|
|
112
|
-
return false;
|
|
113
|
-
}, [messageList]);
|
|
114
|
-
var onHistoryReload = function onHistoryReload() {
|
|
115
|
-
hasMore.current = true;
|
|
116
|
-
getContentMessageList(1, 10);
|
|
117
|
-
};
|
|
118
|
-
var setInputValue = React.useCallback(function (content) {
|
|
119
|
-
var _chatInputRef$current;
|
|
120
|
-
(_chatInputRef$current = chatInputRef.current) === null || _chatInputRef$current === void 0 || _chatInputRef$current.setValue(content);
|
|
121
|
-
}, []);
|
|
122
|
-
|
|
123
|
-
// const onInputValueChange = React.useCallback((content: string) => {
|
|
124
|
-
// setInputValue(content);
|
|
125
|
-
// }, []);
|
|
126
|
-
|
|
127
|
-
var handleInputSend = React.useCallback(function (val, agent, isSystemAuto) {
|
|
128
|
-
var _chatInputRef$current2;
|
|
129
|
-
(_chatInputRef$current2 = chatInputRef.current) === null || _chatInputRef$current2 === void 0 || _chatInputRef$current2.setValue('');
|
|
130
|
-
if (!conversationId) {
|
|
131
|
-
startConversationAndChat(val);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
handleSend(val, agent, isSystemAuto);
|
|
135
|
-
}, [handleSend, startConversationAndChat, conversationId]);
|
|
136
|
-
useEffect(function () {
|
|
137
|
-
if (initMsg) {
|
|
138
|
-
handleInputSend(initMsg);
|
|
139
|
-
}
|
|
140
|
-
}, [initMsg]);
|
|
141
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
142
|
-
className: styles.main,
|
|
143
|
-
id: "myun_gimi_design_chat"
|
|
144
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
145
|
-
className: styles.chat_content
|
|
146
|
-
}, showHeader && headerValue && /*#__PURE__*/React.createElement("div", {
|
|
147
|
-
className: styles.content_header
|
|
148
|
-
}, replaceBraces(headerValue)), /*#__PURE__*/React.createElement("div", {
|
|
149
|
-
className: styles.scroll_wrapper
|
|
150
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
151
|
-
className: "".concat(styles.scroll_container, " ").concat(isScrolling ? styles.scrolling : ''),
|
|
152
|
-
ref: containerRef
|
|
153
|
-
}, showPrologue && messageList.length === 0 && !isMoreLoading && /*#__PURE__*/React.createElement(PresetAgentContent, {
|
|
154
|
-
prologue: (agentObj === null || agentObj === void 0 ? void 0 : agentObj.prologue) || '',
|
|
155
|
-
questionList: (agentObj === null || agentObj === void 0 ? void 0 : agentObj.questionList) || [],
|
|
156
|
-
setInputValue: setInputValue
|
|
157
|
-
}), isMoreLoading ? /*#__PURE__*/React.createElement("div", {
|
|
158
|
-
style: {
|
|
159
|
-
height: '100%'
|
|
160
|
-
}
|
|
161
|
-
}, /*#__PURE__*/React.createElement(AiLoading, null)) : /*#__PURE__*/React.createElement(MessageList, _extends({
|
|
162
|
-
chatList: messageList || defaultMessages,
|
|
163
|
-
handleSend: handleSend,
|
|
164
|
-
inputModelRef: inputModelRef,
|
|
165
|
-
msgLoading: msgLoading,
|
|
166
|
-
onSucessExcel: onSucessExcel,
|
|
167
|
-
onFailureExcel: onFailureExcel,
|
|
168
|
-
onRegenerateClick: regenerate,
|
|
169
|
-
onRetryExcel: onRetryExcel,
|
|
170
|
-
chatUI: chatUI,
|
|
171
|
-
model: model,
|
|
172
|
-
isPlaying: isPlaying,
|
|
173
|
-
playTTSByText: playTTSByText,
|
|
174
|
-
stopTTSByText: stopTTSByText
|
|
175
|
-
}, props.messageConfig))), showBackBottom && /*#__PURE__*/React.createElement("div", {
|
|
176
|
-
className: styles.backBottomBtn,
|
|
177
|
-
onClick: function onClick() {
|
|
178
|
-
return scrollBottomForce(true);
|
|
179
|
-
}
|
|
180
|
-
}, /*#__PURE__*/React.createElement(IconChevronDown, {
|
|
181
|
-
size: "large"
|
|
182
|
-
}))), showInput && /*#__PURE__*/React.createElement(ChatInput, _extends({
|
|
183
|
-
ref: chatInputRef
|
|
184
|
-
}, chatInputConfig, {
|
|
185
|
-
onSend: handleInputSend,
|
|
186
|
-
disabled: disableSend || isMoreLoading,
|
|
187
|
-
defaultPrompt: messageList.length > 0 ? '' : (agentObj === null || agentObj === void 0 ? void 0 : agentObj.defaultPrompt) || '',
|
|
188
|
-
titleSlot: messageList.length > 0 ? '' : (agentObj === null || agentObj === void 0 ? void 0 : agentObj.agentName) || '',
|
|
189
|
-
showDefaultPrompt: messageList.length === 0
|
|
190
|
-
// onContentChange={onInputValueChange}
|
|
191
|
-
,
|
|
192
|
-
onInterrupt: handleInterrupt,
|
|
193
|
-
isRecording: isRecording,
|
|
194
|
-
isVoiceGetting: isExecuting,
|
|
195
|
-
recordingCount: recordingCount,
|
|
196
|
-
asrText: asrText,
|
|
197
|
-
shortAsrClick: shortAsrClick,
|
|
198
|
-
disableVoiceCommunication: disableVoiceCommunication,
|
|
199
|
-
onHistoryReload: onHistoryReload
|
|
200
|
-
}, props.chatInputConfig))), /*#__PURE__*/React.createElement(KonwledgeTrace, _extends({}, props.sidebarConfig, {
|
|
201
|
-
chatList: messageList || defaultMessages,
|
|
202
|
-
isOverFlow: model === 'fullscreen' ? false : true
|
|
203
|
-
})), /*#__PURE__*/React.createElement(FileCardSideBar, _extends({}, props.sidebarConfig, {
|
|
204
|
-
isOverFlow: model === 'fullscreen' ? false : true
|
|
205
|
-
})), /*#__PURE__*/React.createElement(OfficeFilePreviewPanel, null));
|
|
206
|
-
});
|
|
207
|
-
export default CommonChat;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
@charset "UTF-8";
|
|
2
|
-
.main {
|
|
3
|
-
width: 100%;
|
|
4
|
-
height: 100%;
|
|
5
|
-
display: flex;
|
|
6
|
-
gap: 20px;
|
|
7
|
-
overflow: hidden;
|
|
8
|
-
position: relative;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.chat_content {
|
|
12
|
-
flex: 1;
|
|
13
|
-
height: 100%;
|
|
14
|
-
display: flex;
|
|
15
|
-
flex-direction: column;
|
|
16
|
-
min-width: 0;
|
|
17
|
-
position: relative;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.scroll_wrapper {
|
|
21
|
-
flex: 1;
|
|
22
|
-
position: relative;
|
|
23
|
-
width: 100%;
|
|
24
|
-
min-height: 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.scroll_container {
|
|
28
|
-
height: 100%;
|
|
29
|
-
overflow-y: auto;
|
|
30
|
-
overflow-x: hidden;
|
|
31
|
-
width: 100%;
|
|
32
|
-
position: relative;
|
|
33
|
-
}
|
|
34
|
-
.scroll_container::-webkit-scrollbar {
|
|
35
|
-
width: 6px;
|
|
36
|
-
height: 6px;
|
|
37
|
-
}
|
|
38
|
-
.scroll_container::-webkit-scrollbar-thumb {
|
|
39
|
-
border-radius: 6px;
|
|
40
|
-
background: transparent;
|
|
41
|
-
}
|
|
42
|
-
.scroll_container::-webkit-scrollbar-track {
|
|
43
|
-
background: transparent;
|
|
44
|
-
border-radius: 6px;
|
|
45
|
-
}
|
|
46
|
-
.scroll_container.scrolling::-webkit-scrollbar-thumb {
|
|
47
|
-
background: rgba(144, 147, 153, 0.3);
|
|
48
|
-
}
|
|
49
|
-
.scroll_container::-webkit-scrollbar-thumb:hover {
|
|
50
|
-
background: rgba(144, 147, 153, 0.5);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.backBottomBtn {
|
|
54
|
-
position: absolute;
|
|
55
|
-
bottom: 20px;
|
|
56
|
-
right: 20px;
|
|
57
|
-
width: 40px;
|
|
58
|
-
height: 40px;
|
|
59
|
-
background: #fff;
|
|
60
|
-
border-radius: 50%;
|
|
61
|
-
box-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.1);
|
|
62
|
-
display: flex;
|
|
63
|
-
align-items: center;
|
|
64
|
-
justify-content: center;
|
|
65
|
-
cursor: pointer;
|
|
66
|
-
z-index: 10;
|
|
67
|
-
transition: all 0.3s;
|
|
68
|
-
color: #1c1f23;
|
|
69
|
-
}
|
|
70
|
-
.backBottomBtn:hover {
|
|
71
|
-
background: #f2f3f5;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.content_header {
|
|
75
|
-
width: 100%;
|
|
76
|
-
height: 50px;
|
|
77
|
-
display: flex;
|
|
78
|
-
align-items: center;
|
|
79
|
-
justify-content: center;
|
|
80
|
-
font-family: PingFangSC, PingFang SC;
|
|
81
|
-
font-weight: 500;
|
|
82
|
-
font-size: 16px;
|
|
83
|
-
color: #2e394c;
|
|
84
|
-
line-height: 22px;
|
|
85
|
-
text-align: center;
|
|
86
|
-
font-style: normal;
|
|
87
|
-
position: relative;
|
|
88
|
-
}
|
|
89
|
-
.content_header .content_header_title {
|
|
90
|
-
width: 340px;
|
|
91
|
-
height: 100%;
|
|
92
|
-
line-height: 50px;
|
|
93
|
-
overflow: hidden;
|
|
94
|
-
/* 隐藏溢出内容 */
|
|
95
|
-
white-space: nowrap;
|
|
96
|
-
/* 强制文本不换行 */
|
|
97
|
-
text-overflow: ellipsis;
|
|
98
|
-
/* 超出部分显示省略号 */
|
|
99
|
-
}
|
|
100
|
-
.content_header .text_shanow {
|
|
101
|
-
z-index: 5;
|
|
102
|
-
pointer-events: none;
|
|
103
|
-
background: linear-gradient(rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 100%);
|
|
104
|
-
width: 97%;
|
|
105
|
-
height: 32px;
|
|
106
|
-
position: absolute;
|
|
107
|
-
top: 100%;
|
|
108
|
-
left: 1px;
|
|
109
|
-
}
|