yt-chat-components 1.5.3 → 1.5.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/package.json +1 -1
- package/public/index.html +2 -3
- package/src/YtChatView/chatWidget/chatWindow/callInterface/StreamAudioPlayer.tsx +1 -1
- package/src/YtChatView/chatWidget/chatWindow/chatMessage/index.tsx +21 -2
- package/src/YtChatView/chatWidget/chatWindow/controllers/index.ts +2 -2
- package/src/YtChatView/chatWidget/chatWindow/index.tsx +53 -17
- package/src/YtChatView/chatWidget/index.tsx +7 -2
- package/src/YtChatView/chatWidget/style.js +6 -1
- package/src/YtChatView/components/TabSelector/index.jsx +8 -13
- package/src/YtChatView/components/TabSelector/index.module.css +2 -2
- package/src/YtChatView/previewDialogV2/index.jsx +56 -46
- package/src/YtChatView/previewDialogV2/index.module.css +3 -2
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -111,8 +111,8 @@
|
|
|
111
111
|
host-url="https://ai-api.yuntu.cn"
|
|
112
112
|
sign-url="https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/user/ai/logo.png"
|
|
113
113
|
app-id="5f48c683-38d8-430e-8479-17730a605821"
|
|
114
|
-
box-style='{"height":"100%","background":"url(https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/system/portal_bg_blue.png) center top / 100% 100% no-repeat"}'
|
|
115
|
-
is-show-side-right=
|
|
114
|
+
box-style='{"height":"100%","minWidth": "1380px","background":"url(https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/system/portal_bg_blue.png) center top / 100% 100% no-repeat"}'
|
|
115
|
+
is-show-side-right=true
|
|
116
116
|
is-show-side-left=true
|
|
117
117
|
dialog-index="999999999"
|
|
118
118
|
agent-url="https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/kai_yuan/byz/xinge.png"
|
|
@@ -122,7 +122,6 @@
|
|
|
122
122
|
is-title-side-icon=true
|
|
123
123
|
is-show-upload-button=false
|
|
124
124
|
drop-man-url="https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/ai/ai_man01.png"
|
|
125
|
-
banner-map='{"a":"https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/user/ai/banner.png","b":"https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/user/ai/banner.png","c":"https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/user/ai/banner.png"}'
|
|
126
125
|
asset-map='{"sendMessageUrl":"https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/user/ai/sendMessage.png","stopMessageUrl":"https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/user/ai/stopMessage.png","speakUrl":"https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/user/ai/speak.png"}'
|
|
127
126
|
/>
|
|
128
127
|
</body>
|
|
@@ -67,7 +67,7 @@ export class StreamAudioPlayer {
|
|
|
67
67
|
this.pendingBufferSizeSec += durationSec;
|
|
68
68
|
|
|
69
69
|
// 如果累计 ≥ 0.5s 才创建 buffer 并推入队列
|
|
70
|
-
if (this.pendingBufferSizeSec >= 0.
|
|
70
|
+
if (this.pendingBufferSizeSec >= 0.3) {
|
|
71
71
|
const totalLength = this.pendingBuffer.reduce((sum, b) => sum + b.length, 0);
|
|
72
72
|
const mergedChannel = new Float32Array(totalLength);
|
|
73
73
|
|
|
@@ -23,6 +23,7 @@ import ChatMessagePlaceholder, {ChatMessagePlaceholderInThought} from "../chatPl
|
|
|
23
23
|
import {UrlCard} from "./urlCard"
|
|
24
24
|
import {CustomThoughtChainItem, CustomThoughtChainProps} from "./CustomThoughtChain";
|
|
25
25
|
import CustomThoughtChain from "./CustomThoughtChain";
|
|
26
|
+
import {isFunction} from "lodash";
|
|
26
27
|
let speechSynth = window.speechSynthesis;
|
|
27
28
|
let utterance = null;
|
|
28
29
|
|
|
@@ -60,7 +61,8 @@ export default function ChatMessage({
|
|
|
60
61
|
handleSendMessage,
|
|
61
62
|
isLatest,
|
|
62
63
|
key,
|
|
63
|
-
isShowReadIcon
|
|
64
|
+
isShowReadIcon,
|
|
65
|
+
renderInitNode,
|
|
64
66
|
}: ChatMessageType) {
|
|
65
67
|
const parseFileName = (
|
|
66
68
|
text: string,
|
|
@@ -167,6 +169,16 @@ export default function ChatMessage({
|
|
|
167
169
|
}
|
|
168
170
|
}
|
|
169
171
|
|
|
172
|
+
const getMessageClassSuffix = () => {
|
|
173
|
+
if (isFunction(renderInitNode)) {
|
|
174
|
+
return 'cl-justify-init'
|
|
175
|
+
}
|
|
176
|
+
if (isSend) {
|
|
177
|
+
return 'cl-justify-end';
|
|
178
|
+
}
|
|
179
|
+
return 'cl-justify-start';
|
|
180
|
+
}
|
|
181
|
+
|
|
170
182
|
const renderUserMessage = () => {
|
|
171
183
|
return (
|
|
172
184
|
<div key={key} style={user_message_style} className="msg_userMessageBox">
|
|
@@ -224,6 +236,10 @@ export default function ChatMessage({
|
|
|
224
236
|
)
|
|
225
237
|
}
|
|
226
238
|
|
|
239
|
+
const renderInitMessage = () => {
|
|
240
|
+
return renderInitNode()
|
|
241
|
+
}
|
|
242
|
+
|
|
227
243
|
const renderErrorMessage = () => {
|
|
228
244
|
return (
|
|
229
245
|
<div key={key} style={error_message_style} className={'cl-error_message'}>
|
|
@@ -668,6 +684,9 @@ export default function ChatMessage({
|
|
|
668
684
|
// }
|
|
669
685
|
|
|
670
686
|
const render = () => {
|
|
687
|
+
if (isFunction(renderInitNode)) {
|
|
688
|
+
return renderInitMessage()
|
|
689
|
+
}
|
|
671
690
|
if (isSend){
|
|
672
691
|
return renderUserMessage()
|
|
673
692
|
}else {
|
|
@@ -680,7 +699,7 @@ export default function ChatMessage({
|
|
|
680
699
|
}
|
|
681
700
|
|
|
682
701
|
return (
|
|
683
|
-
<div className={'cl-chat-message ' + (
|
|
702
|
+
<div className={'cl-chat-message ' + getMessageClassSuffix()}>
|
|
684
703
|
{
|
|
685
704
|
render()
|
|
686
705
|
}
|
|
@@ -249,11 +249,11 @@ export async function getFlowInfo(baseUrl: string, flowId: string, api_key: stri
|
|
|
249
249
|
return axios.get(`${baseUrl}/api/t1/flow/detail/${flowId}`,{headers});
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
export async function
|
|
252
|
+
export async function getQaInfo(baseUrl: string, flowId: string, api_key: string) {
|
|
253
253
|
const headers = {
|
|
254
254
|
'Content-Type': 'multipart/form-data',
|
|
255
255
|
'x-api-key': api_key,
|
|
256
256
|
timeout:600000
|
|
257
257
|
};
|
|
258
|
-
return axios.get(`${baseUrl}/api/t1/
|
|
258
|
+
return axios.get(`${baseUrl}/api/t1/qa_doc/find_doc_by_flow_id/${flowId}`,{headers});
|
|
259
259
|
}
|
|
@@ -28,6 +28,7 @@ import {Image, message as messageTip, Tooltip, Typography} from 'antd';
|
|
|
28
28
|
import {isEmpty, isFunction} from 'lodash';
|
|
29
29
|
import btn_answer from '../../../assets/aicenter/btn_answer.png';
|
|
30
30
|
import {MethodContext} from "../../previewDialogV2";
|
|
31
|
+
import TabSelector from "../../components/TabSelector";
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
let mediaRecorder = null; // 语音对象,用于录音
|
|
@@ -89,6 +90,8 @@ export default function ChatWindow({
|
|
|
89
90
|
isShowReadIcon,
|
|
90
91
|
renderCustomDropDown,
|
|
91
92
|
isTagsHidden,
|
|
93
|
+
isEnableForV1,
|
|
94
|
+
questions,
|
|
92
95
|
}: {
|
|
93
96
|
is_enable_call:boolean;
|
|
94
97
|
tags: [];
|
|
@@ -138,6 +141,8 @@ export default function ChatWindow({
|
|
|
138
141
|
isShowReadIcon?:boolean;
|
|
139
142
|
renderCustomDropDown?: Function;
|
|
140
143
|
isTagsHidden?: boolean;
|
|
144
|
+
isEnableForV1?: boolean;
|
|
145
|
+
questions?: any[];
|
|
141
146
|
}) {
|
|
142
147
|
const ref = useRef<HTMLDivElement>(null);
|
|
143
148
|
const lastMessage = useRef<HTMLDivElement>(null);
|
|
@@ -153,6 +158,7 @@ export default function ChatWindow({
|
|
|
153
158
|
{ file: File; fileUrl: string; fileType: string; fileId: string }[]
|
|
154
159
|
>([]);
|
|
155
160
|
const scrollContainerRef = useRef(null);
|
|
161
|
+
const sessionIdRef = useRef(null);
|
|
156
162
|
const [showLeftArrow, setShowLeftArrow] = useState(false); // 控制左侧箭头显示
|
|
157
163
|
const [showRightArrow, setShowRightArrow] = useState(false); // 控制右侧箭头显示
|
|
158
164
|
const isStream = true;//是否流式输出(手动开关)
|
|
@@ -529,7 +535,7 @@ export default function ChatWindow({
|
|
|
529
535
|
|
|
530
536
|
let userInfoClone = {...userInfo};
|
|
531
537
|
if(isEmpty(userInfoClone.code)) {
|
|
532
|
-
userInfoClone.code =
|
|
538
|
+
userInfoClone.code = sessionIdRef.current;
|
|
533
539
|
}
|
|
534
540
|
const code = userInfoClone['code'] ? userInfoClone['code'] : ""
|
|
535
541
|
const name = userInfoClone['name'] ? userInfoClone['name'] : ""
|
|
@@ -573,7 +579,7 @@ export default function ChatWindow({
|
|
|
573
579
|
message,
|
|
574
580
|
input_type,
|
|
575
581
|
output_type,
|
|
576
|
-
|
|
582
|
+
sessionIdRef.current,
|
|
577
583
|
output_component,
|
|
578
584
|
tweaks,
|
|
579
585
|
api_key,
|
|
@@ -598,13 +604,13 @@ export default function ChatWindow({
|
|
|
598
604
|
isSend: false
|
|
599
605
|
});
|
|
600
606
|
}else if (e.name !== 'AbortError') {
|
|
601
|
-
messageTip.error('
|
|
607
|
+
messageTip.error('当前网络繁忙,请稍后重试');
|
|
602
608
|
// ?????? done
|
|
603
609
|
addMessage({
|
|
604
610
|
messageItemList: [{
|
|
605
611
|
id:new Date().getTime() + '',
|
|
606
612
|
name: "AI",
|
|
607
|
-
message: "
|
|
613
|
+
message: "当前网络繁忙,请稍后重试",
|
|
608
614
|
type: MessageType.text,
|
|
609
615
|
}],
|
|
610
616
|
isSend: false
|
|
@@ -895,9 +901,9 @@ export default function ChatWindow({
|
|
|
895
901
|
try {
|
|
896
902
|
let userInfoClone = userInfo;
|
|
897
903
|
if(isEmpty(userInfoClone.code)) {
|
|
898
|
-
userInfoClone.code =
|
|
904
|
+
userInfoClone.code = sessionIdRef.current;
|
|
899
905
|
}
|
|
900
|
-
const res = await getChatHistory(hostUrl, flowId,
|
|
906
|
+
const res = await getChatHistory(hostUrl, flowId, sessionIdRef.current, userInfoClone['code']);
|
|
901
907
|
const chatHistory = res.data?.length ? res.data : [];
|
|
902
908
|
|
|
903
909
|
// 这里是多轮对话全量的信息,应该逐条处理成最终结果
|
|
@@ -948,7 +954,30 @@ export default function ChatWindow({
|
|
|
948
954
|
|
|
949
955
|
finalChatHistoryList.forEach((item) => {
|
|
950
956
|
addMessage(item)
|
|
951
|
-
})
|
|
957
|
+
});
|
|
958
|
+
if (!isEnableForV1 && !isEmpty(questions)) {
|
|
959
|
+
addMessage({
|
|
960
|
+
messageItemList: [],
|
|
961
|
+
renderInitNode: () => <div style={{minHeight: '365px', width: '100%'}}>
|
|
962
|
+
{
|
|
963
|
+
!isEmpty(finalChatHistoryList) && <div style={{display: 'flex', justifyContent: 'center'}}>
|
|
964
|
+
<div style={{width: '36px', height: '1px', border: '1px dashed rgb(192, 194, 197)'}}></div>
|
|
965
|
+
<div style={{color:'rgb(192, 194, 197)'}}> 以上是历史消息 </div>
|
|
966
|
+
<div style={{width: '36px', height: '1px', border: '1px dashed rgb(192, 194, 197)'}}></div>
|
|
967
|
+
</div>
|
|
968
|
+
}
|
|
969
|
+
<TabSelector
|
|
970
|
+
welcomeWords={`Hi,欢迎使用${window_title},您可以这样问我:`}
|
|
971
|
+
handleRowClick={(word) => {
|
|
972
|
+
handleSendMessage(word)
|
|
973
|
+
}}
|
|
974
|
+
dataList={questions}
|
|
975
|
+
/>
|
|
976
|
+
</div>,
|
|
977
|
+
isSend: false,
|
|
978
|
+
error: false,
|
|
979
|
+
});
|
|
980
|
+
}
|
|
952
981
|
} catch (error) {
|
|
953
982
|
console.error("Failed to fetch chat history:", error);
|
|
954
983
|
}
|
|
@@ -957,14 +986,18 @@ export default function ChatWindow({
|
|
|
957
986
|
* 当获取历史记录时(sessindId变化时),清空消息,并添加历史记录
|
|
958
987
|
*/
|
|
959
988
|
useEffect(() => {
|
|
960
|
-
|
|
989
|
+
// 新组件需要等待预置库信息加载完全来载入初始对话引导,旧组件不用
|
|
990
|
+
if (!isEnableForV1 && !isEmpty(questions) || isEnableForV1) {
|
|
991
|
+
sessionIdRef.current = sessionId;
|
|
992
|
+
fetchChatHistory().then();
|
|
961
993
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
994
|
+
return () => {
|
|
995
|
+
abortControllerRef.current.abort('disconnect');
|
|
996
|
+
// abortControllerRef是一次性的,中止之后要初始化,否则fetch请求会被中止导致请求无响应
|
|
997
|
+
abortControllerRef.current = new AbortController();
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
}, [sessionId, questions]);
|
|
968
1001
|
|
|
969
1002
|
useEffect(() => {
|
|
970
1003
|
if (registerChatMethods) {
|
|
@@ -999,7 +1032,7 @@ export default function ChatWindow({
|
|
|
999
1032
|
* 对话是否处于活跃状态
|
|
1000
1033
|
* */
|
|
1001
1034
|
const isActiveMessage = useCallback(() => {
|
|
1002
|
-
return
|
|
1035
|
+
return receivingMessageRef.current;
|
|
1003
1036
|
}, []);
|
|
1004
1037
|
|
|
1005
1038
|
const renderTipsInfo = () => {
|
|
@@ -1352,7 +1385,6 @@ export default function ChatWindow({
|
|
|
1352
1385
|
</>
|
|
1353
1386
|
)
|
|
1354
1387
|
}
|
|
1355
|
-
|
|
1356
1388
|
return (
|
|
1357
1389
|
<div
|
|
1358
1390
|
style={{...chat_window_style, width: width, height: "100%"}}
|
|
@@ -1376,7 +1408,10 @@ export default function ChatWindow({
|
|
|
1376
1408
|
}}
|
|
1377
1409
|
/>
|
|
1378
1410
|
:
|
|
1379
|
-
<div
|
|
1411
|
+
<div
|
|
1412
|
+
className="cl-middle-container"
|
|
1413
|
+
style={isEnableForV1 ? {paddingLeft: '1.6rem', paddingRight: '1.6rem'} : {}}
|
|
1414
|
+
>
|
|
1380
1415
|
<div className="cl-header" style={isMobile ? {
|
|
1381
1416
|
position: 'absolute',
|
|
1382
1417
|
top: 20,
|
|
@@ -1421,6 +1456,7 @@ export default function ChatWindow({
|
|
|
1421
1456
|
error={message.error}
|
|
1422
1457
|
handleSendMessage={handleSendMessage}
|
|
1423
1458
|
isShowReadIcon={isShowReadIcon}
|
|
1459
|
+
renderInitNode={message.renderInitNode}
|
|
1424
1460
|
/>
|
|
1425
1461
|
))
|
|
1426
1462
|
}
|
|
@@ -52,6 +52,8 @@ export default function ChatWidget({
|
|
|
52
52
|
isShowReadIcon,
|
|
53
53
|
renderCustomDropDown,
|
|
54
54
|
isTagsHidden,
|
|
55
|
+
isEnableForV1 = true,
|
|
56
|
+
questions
|
|
55
57
|
}: {
|
|
56
58
|
is_enable_call:boolean,
|
|
57
59
|
tags: [];
|
|
@@ -97,10 +99,11 @@ export default function ChatWidget({
|
|
|
97
99
|
isShowReadIcon: boolean,
|
|
98
100
|
renderCustomDropDown: Function,
|
|
99
101
|
isTagsHidden: boolean;
|
|
102
|
+
isEnableForV1: boolean;
|
|
103
|
+
questions: any[];
|
|
100
104
|
}) {
|
|
101
105
|
const [open, setOpen] = useState(start_open);
|
|
102
106
|
const [messages, setMessages] = useState<ChatMessageType[]>([]);
|
|
103
|
-
const sessionId = session_id;
|
|
104
107
|
|
|
105
108
|
function updateLastMessage(message: ChatMessageType) {
|
|
106
109
|
setMessages((prev) => {
|
|
@@ -157,7 +160,7 @@ export default function ChatWidget({
|
|
|
157
160
|
messages={messages}
|
|
158
161
|
triggerRef={triggerRef}
|
|
159
162
|
position={chat_position}
|
|
160
|
-
sessionId={
|
|
163
|
+
sessionId={session_id}
|
|
161
164
|
additional_headers={additional_headers}
|
|
162
165
|
setDropDownList={setDropDownList}
|
|
163
166
|
dropDownList={dropDownList}
|
|
@@ -173,6 +176,8 @@ export default function ChatWidget({
|
|
|
173
176
|
isShowReadIcon={isShowReadIcon}
|
|
174
177
|
renderCustomDropDown={renderCustomDropDown}
|
|
175
178
|
isTagsHidden={isTagsHidden}
|
|
179
|
+
isEnableForV1={isEnableForV1}
|
|
180
|
+
questions={questions}
|
|
176
181
|
/>
|
|
177
182
|
</div>
|
|
178
183
|
);
|
|
@@ -657,7 +657,7 @@ margin-bottom:1rem;
|
|
|
657
657
|
--tw-bg-opacity: 1;
|
|
658
658
|
padding-left: 1rem;
|
|
659
659
|
padding-right: 1rem;
|
|
660
|
-
padding-top: 0.5rem;
|
|
660
|
+
// padding-top: 0.5rem;
|
|
661
661
|
padding-bottom: 0.5rem;
|
|
662
662
|
-ms-overflow-style: none;
|
|
663
663
|
scrollbar-width: none;
|
|
@@ -710,6 +710,11 @@ margin-bottom:1rem;
|
|
|
710
710
|
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
711
711
|
}
|
|
712
712
|
|
|
713
|
+
.cl-justify-init {
|
|
714
|
+
justify-content: flex-start;
|
|
715
|
+
padding-top:0;
|
|
716
|
+
}
|
|
717
|
+
|
|
713
718
|
.cl-justify-start {
|
|
714
719
|
justify-content: flex-start;
|
|
715
720
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Tabs, Button, Typography, ConfigProvider } from 'antd';
|
|
3
3
|
import { LeftOutlined, RightOutlined, SyncOutlined } from '@ant-design/icons';
|
|
4
4
|
import styles from './index.module.css';
|
|
@@ -6,18 +6,8 @@ import styles from './index.module.css';
|
|
|
6
6
|
const middleImgUrl = 'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/user/ai/guessYourWant.png';
|
|
7
7
|
const bottomImgUrl = 'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/kai_yuan/byz/xinge.png';
|
|
8
8
|
|
|
9
|
-
const defaultMap = {
|
|
10
|
-
'学校文化': ['学校最有特色的传统是什么?', '有哪些值得传承的校训?', '学校重视学生个性发展吗?', '有什么知名校友吗?', '新生入学是否有迎新活动?', '学校支持学生创业吗?', '学校节日有哪些特色?', '学校的学习氛围怎么样?', '学生组织有哪些?', '是否有艺术或文化类社团?'],
|
|
11
|
-
'校园风景': ['校园内有哪些打卡景点?', '校园绿化做得好吗?', '有湖泊或花园吗?', '有特色建筑吗?', '校园大不大?适合散步吗?', '有哪些适合拍照的地方?', '有室外自习空间吗?', '校园晚上灯光如何?', '有没有露天表演广场?', '有樱花或银杏树吗?'],
|
|
12
|
-
'招生流程': ['什么时候开始填志愿?', '招生简章在哪查看?', '是否有预估分数线?', '如何获取往年录取线?', '能否跨省报考?', '有哪些专项招生计划?', '报志愿前可参观校园吗?', '有无强基计划?', '是否有面试环节?', '报名后多久公布录取?'],
|
|
13
|
-
'住宿生活': ['几人一间宿舍?', '宿舍有空调吗?', '洗衣机是否自助?', '有独立卫生间吗?', '能否申请调换宿舍?', '有晚归门禁吗?', '网络信号好吗?', '有宿舍文化活动吗?', '宿舍能使用电器吗?', '有快递柜或驿站吗?'],
|
|
14
|
-
'餐饮服务': ['食堂饭菜贵不贵?', '食堂口味多样吗?', '有无清真窗口?', '学校周边吃饭方便吗?', '是否支持刷脸就餐?', '饭卡能否线上充值?', '有没有饮品店?', '食堂有无特色菜?', '吃饭时间是否固定?', '是否有外卖平台?'],
|
|
15
|
-
'教学资源': ['师资力量如何?', '有外教课程吗?', '是否提供选修课?', '教材是否统一购买?', '有开放实验室吗?', '是否配有学习中心?', '有哪些在线课程平台?', '图书馆开放时间?', '能否跨专业听课?', '有无名师公开课?'],
|
|
16
|
-
'就业实习': ['是否提供实习机会?', '就业指导服务如何?', '有哪些合作企业?', '实习是否计入学分?', '就业率有多高?', '毕业生去向有哪些?', '能否推荐实习单位?', '是否有职业规划课?', '能考研继续深造吗?', '就业双选会多不多?'],
|
|
17
|
-
};
|
|
18
|
-
|
|
19
9
|
const TabSelector = ({ customUrl, handleRowClick, welcomeWords, isSimple, dataList = [] }) => {
|
|
20
|
-
const [activeKey, setActiveKey] = useState(
|
|
10
|
+
const [activeKey, setActiveKey] = useState();
|
|
21
11
|
const [valuePage, setValuePage] = useState(0);
|
|
22
12
|
const [tabLocation, setTabLocation] = useState(0);
|
|
23
13
|
const valuesPerPage = 5; // Number of values to show per page
|
|
@@ -27,6 +17,11 @@ const TabSelector = ({ customUrl, handleRowClick, welcomeWords, isSimple, dataLi
|
|
|
27
17
|
const keys = dataList.map(e=>e.category)||[];
|
|
28
18
|
const values = dataList.filter(e => activeKey === e.category).map(e => e.data)[0] || [];
|
|
29
19
|
const visibleValues = isSimple ? values : values.slice(valuePage * valuesPerPage, (valuePage + 1) * valuesPerPage);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setActiveKey(dataList[0]?.category)
|
|
23
|
+
}, [dataList]);
|
|
24
|
+
|
|
30
25
|
const handleTabChange = (key) => {
|
|
31
26
|
setActiveKey(key);
|
|
32
27
|
setValuePage(0); // Reset value page when changing tabs
|
|
@@ -138,7 +133,7 @@ const TabSelector = ({ customUrl, handleRowClick, welcomeWords, isSimple, dataLi
|
|
|
138
133
|
return (<div className={styles.row} key={index} onClick={() => handleRowClick(item.q)}>
|
|
139
134
|
<Typography.Paragraph
|
|
140
135
|
className={styles.text}
|
|
141
|
-
style={{ maxWidth: isSimple ? '
|
|
136
|
+
style={{ maxWidth: isSimple ? '190px' : '300px' }}
|
|
142
137
|
ellipsis={{ rows: 1, tooltip: `${item.q}`, }}>
|
|
143
138
|
{isSimple && <span style={{ marginRight: '12px' }}>·</span>}
|
|
144
139
|
{item.q}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.mainContainer {
|
|
2
2
|
flex: 1;
|
|
3
|
-
|
|
3
|
+
overflow-y: auto;
|
|
4
4
|
.welcome {
|
|
5
5
|
background: #FFFFFF;
|
|
6
6
|
border-radius: 8px 8px 8px 0px;
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
|
|
98
98
|
.valueList {
|
|
99
99
|
padding: 10px;
|
|
100
|
-
min-height:
|
|
100
|
+
min-height: 225px;
|
|
101
101
|
font-size: 16px;
|
|
102
102
|
color: #000000;
|
|
103
103
|
overflow-y: auto;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ChatWidget from '../chatWidget/index';
|
|
3
3
|
import aiAvatarPng from '../../assets/aicenter/aiavatar.png';
|
|
4
|
-
import { getFlowInfo, getHistoryList,
|
|
4
|
+
import { getFlowInfo, getHistoryList, getQaInfo } from '../chatWidget/chatWindow/controllers/index';
|
|
5
5
|
import './index.module.css'
|
|
6
6
|
import { v4 as uuidv4 } from 'uuid';
|
|
7
7
|
import historyListEmptyPng from '../../assets/aicenter/history-list-empty.png';
|
|
@@ -23,7 +23,7 @@ const CommentIcon = (props) => (
|
|
|
23
23
|
<Icon component={commentSvg} {...props} />
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
const knowledgeInfo = {
|
|
26
|
+
export const knowledgeInfo = {
|
|
27
27
|
media: [
|
|
28
28
|
{
|
|
29
29
|
a: "https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/user/ai/banner.png",
|
|
@@ -69,19 +69,19 @@ const style = `
|
|
|
69
69
|
}
|
|
70
70
|
.p_toolDialog .p_sign{
|
|
71
71
|
width: calc(100vw - 140px);
|
|
72
|
+
min-width:1380px;
|
|
72
73
|
margin: 0 auto;
|
|
73
|
-
min-width: 1200px;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
.dialog_box{
|
|
77
77
|
margin: 1.5rem auto 0;
|
|
78
78
|
width: calc(100vw - 140px);
|
|
79
79
|
height: calc(100vh - 192px);
|
|
80
|
+
min-width:1380px;
|
|
80
81
|
background: #fff;
|
|
81
82
|
border-radius: 15px;
|
|
82
83
|
display: flex;
|
|
83
84
|
flex-direction: column;
|
|
84
|
-
min-width: 1200px;
|
|
85
85
|
}
|
|
86
86
|
.p_toolDialog .p_toolLeft {
|
|
87
87
|
display: flex;
|
|
@@ -222,7 +222,8 @@ const style = `
|
|
|
222
222
|
|
|
223
223
|
.p_toolDialog .p_toolRight {
|
|
224
224
|
flex: 1;
|
|
225
|
-
background: #f5f5f5;
|
|
225
|
+
background: #f5f5f5;
|
|
226
|
+
min-width:780px;
|
|
226
227
|
}
|
|
227
228
|
|
|
228
229
|
.p_toolRightToRight {
|
|
@@ -327,7 +328,7 @@ export class ToolDialogV2 extends React.Component {
|
|
|
327
328
|
sessionId: uuidv4(), // 当前激活的对话对应的sessionId
|
|
328
329
|
dropDownList: [],
|
|
329
330
|
currentFlow: {},
|
|
330
|
-
knowledgeInfo: {
|
|
331
|
+
knowledgeInfo: {},
|
|
331
332
|
};
|
|
332
333
|
|
|
333
334
|
componentWillMount() {
|
|
@@ -376,17 +377,19 @@ export class ToolDialogV2 extends React.Component {
|
|
|
376
377
|
const res = await getFlowInfo(this.props.hostUrl, this.props.appId, api_key);
|
|
377
378
|
if(res.status === 200 && typeof res.data !== "string") {
|
|
378
379
|
// 查询知识库相关信息用作预置问题
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
380
|
+
getQaInfo(this.props.hostUrl, this.props.appId, api_key).then(res => {
|
|
381
|
+
if (res.status === 200 && typeof res.data !== "string") {
|
|
382
|
+
if ( !isEmpty(res.data) && !isEmpty(res.data.media) && !isEmpty(res.data.question)) {
|
|
383
|
+
this.setState({ knowledgeInfo: res.data })
|
|
384
|
+
} else if ( !isEmpty(this.props.knowledgeInfo)) {
|
|
385
|
+
this.setState({ knowledgeInfo: this.props.knowledgeInfo })
|
|
386
|
+
} else {
|
|
387
|
+
this.setState({ knowledgeInfo: knowledgeInfo })
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}).catch(e => {
|
|
391
|
+
console.log(e);
|
|
392
|
+
});
|
|
390
393
|
this.setState({ currentFlow: res.data });
|
|
391
394
|
}
|
|
392
395
|
return res.data;
|
|
@@ -434,6 +437,7 @@ export class ToolDialogV2 extends React.Component {
|
|
|
434
437
|
}
|
|
435
438
|
|
|
436
439
|
renderCustomDropDown=(dropDownList)=>{
|
|
440
|
+
return null;
|
|
437
441
|
const { title } = this.props;
|
|
438
442
|
const { currentFlow } = this.state;
|
|
439
443
|
return <TabSelector
|
|
@@ -474,7 +478,7 @@ export class ToolDialogV2 extends React.Component {
|
|
|
474
478
|
modalWidth,
|
|
475
479
|
isShowReadIcon = false,
|
|
476
480
|
signUrl,
|
|
477
|
-
|
|
481
|
+
isShowVoiceButton,
|
|
478
482
|
} = this.props;
|
|
479
483
|
const { currentFlow = {} } = this.state;
|
|
480
484
|
return (
|
|
@@ -562,6 +566,7 @@ export class ToolDialogV2 extends React.Component {
|
|
|
562
566
|
dropDownList={this.state.dropDownList}
|
|
563
567
|
baseConfig={{ isTitleSideIcon, logoWidth, agentUrl, ...assetMap }}
|
|
564
568
|
isShowUploadButton={isShowUploadButton}
|
|
569
|
+
isShowVoiceButton={isShowVoiceButton}
|
|
565
570
|
dropManUrl={currentFlow.character}
|
|
566
571
|
modalWidth={modalWidth}
|
|
567
572
|
isShowReadIcon={isShowReadIcon}
|
|
@@ -569,35 +574,39 @@ export class ToolDialogV2 extends React.Component {
|
|
|
569
574
|
renderCustomDropDown={this.renderCustomDropDown}
|
|
570
575
|
isTagsHidden={true}
|
|
571
576
|
placeholder={'请输入您想咨询的问题'}
|
|
577
|
+
isEnableForV1={false}
|
|
578
|
+
questions={this.state.knowledgeInfo?.question || []}
|
|
572
579
|
/>
|
|
573
580
|
</MethodContext.Provider>
|
|
574
581
|
</div>
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
{
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
<
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
<
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
<
|
|
599
|
-
|
|
600
|
-
|
|
582
|
+
{
|
|
583
|
+
isShowSideRight && <div className={'p_toolRightToRight'}>
|
|
584
|
+
<Carousel autoplay={{ dotDuration: true }} autoplaySpeed={4000} className={'p_carousel'}>
|
|
585
|
+
{
|
|
586
|
+
(this.state.knowledgeInfo?.media || []).map(item => {
|
|
587
|
+
if (item.a_type === 'image') {
|
|
588
|
+
return <div key={item.a}>
|
|
589
|
+
<Image
|
|
590
|
+
preview={{
|
|
591
|
+
mask: <div><EyeOutlined style={{ marginRight: '4px' }}/>预览</div>
|
|
592
|
+
}}
|
|
593
|
+
style={contentStyle} src={item.a}
|
|
594
|
+
/>
|
|
595
|
+
</div>
|
|
596
|
+
} else if (item.a_type === 'video') {
|
|
597
|
+
return <div key={item.a}>
|
|
598
|
+
<video style={contentStyle} src={item.a} controls={true}/>
|
|
599
|
+
</div>
|
|
600
|
+
}
|
|
601
|
+
})
|
|
602
|
+
}
|
|
603
|
+
</Carousel>
|
|
604
|
+
<div style={{ height: '1px', background: '#E5E5E5', marginTop: '25px' }}/>
|
|
605
|
+
<div className={'p_hot'}>
|
|
606
|
+
<img
|
|
607
|
+
src={'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/user/ai/hot.png'}/>
|
|
608
|
+
<span>热点问题</span>
|
|
609
|
+
</div>
|
|
601
610
|
<TabSelector
|
|
602
611
|
isSimple={true}
|
|
603
612
|
handleRowClick={(word) => {
|
|
@@ -605,10 +614,11 @@ export class ToolDialogV2 extends React.Component {
|
|
|
605
614
|
}}
|
|
606
615
|
dataList={this.state.knowledgeInfo?.question || []}
|
|
607
616
|
/>
|
|
608
|
-
|
|
617
|
+
</div>
|
|
618
|
+
}
|
|
609
619
|
</div>
|
|
610
620
|
</div>
|
|
611
|
-
<div className={'p_footer'}><span style={{fontSize: 16}}>技术支持:北京云图科技有限公司</span></div>
|
|
621
|
+
<div className={'p_footer'}><span style={{ fontSize: 16 }}>技术支持:北京云图科技有限公司</span></div>
|
|
612
622
|
</div>
|
|
613
623
|
</div>
|
|
614
624
|
);
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
.toolDialogSign {
|
|
15
15
|
width: calc(100vw - 140px);
|
|
16
|
+
min-width:1380px;
|
|
16
17
|
margin: 0 auto;
|
|
17
|
-
min-width: 1200px;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
.dialogBox {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
border-radius: 15px;
|
|
26
26
|
display: flex;
|
|
27
27
|
flex-direction: column;
|
|
28
|
-
min-width:
|
|
28
|
+
min-width:1380px;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
.toolLeft {
|
|
@@ -154,6 +154,7 @@
|
|
|
154
154
|
.toolRight {
|
|
155
155
|
flex: 1;
|
|
156
156
|
background: #f5f5f5;
|
|
157
|
+
min-width:780px;
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
.toolRightToRight {
|