yt-chat-components 2.0.6 → 2.0.7

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.
@@ -0,0 +1,648 @@
1
+ import React from 'react';
2
+ import ChatWidget from '../chatWidget/index';
3
+ import aiAvatarPng from '../../assets/aicenter/aiavatar.png';
4
+ import {
5
+ getFlowInfo,
6
+ getFlowPage,
7
+ getHistoryList,
8
+ getQaInfo,
9
+ getSceneInfo, modifyScene
10
+ } from '../chatWidget/chatWindow/controllers/index';
11
+ import './index.module.css'
12
+ import { v4 as uuidv4 } from 'uuid';
13
+ import { isEmpty } from "lodash";
14
+ import { Drawer, message, message as messageTip, Skeleton, Tooltip } from 'antd'
15
+ import LeftMenu from "./LeftMenu";
16
+ import Icon, { HistoryOutlined, PlusOutlined } from "@ant-design/icons";
17
+ import historyListEmptyPng from "../../assets/aicenter/history-list-empty.png";
18
+
19
+
20
+ const commentSvg = ()=> (
21
+ <svg t="1751111611885" className="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
22
+ p-id="3118" width="24" height="20">
23
+ <path
24
+ d="M806.9 155.2H217.2c-64 0-116.1 55.6-116.1 124v380c0 68.4 52.1 124 116.1 124h101.3l-5.9 101.6c-0.5 9.4 4.5 18.3 12.8 22.6 3.5 1.8 7.3 2.8 11.2 2.8 5.2 0 10.4-1.7 14.7-5.1l156.8-122h298.7c64 0 116.1-55.6 116.1-124v-380c0.1-68.3-52-123.9-116-123.9zM303 528.7c-33.1 0-60-26.9-60-60s26.9-60 60-60 60 26.9 60 60-26.8 60-60 60z m209 1c-33.1 0-60-26.9-60-60s26.9-60 60-60 60 26.9 60 60-26.8 60-60 60z m209-1c-33.1 0-60-26.9-60-60s26.9-60 60-60 60 26.9 60 60-26.8 60-60 60z"
25
+ p-id="3119"></path>
26
+ </svg>
27
+ )
28
+
29
+ const CommentIcon = (props) => (
30
+ <Icon component={commentSvg} {...props} />
31
+ );
32
+
33
+ export const knowledgeInfo = {
34
+ media: [
35
+ {
36
+ a: "https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/school/bcyz/user/ai/banner.png",
37
+ a_type: "image"
38
+ },
39
+ {
40
+ a: "https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/temp/test.mp4",
41
+ a_type: "video"
42
+ }
43
+ ],
44
+ question: [
45
+ {category:'学校文化',data: [{q:'学校最有特色的传统是什么?'}, {q:'有哪些值得传承的校训?'}, {q:'学校重视学生个性发展吗?'}, {q:'有什么知名校友吗?'}, {q:'新生入学是否有迎新活动?'}, {q:'学校支持学生创业吗?'}, {q:'学校节日有哪些特色?'}, {q:'学校的学习氛围怎么样?'}, {q:'学生组织有哪些?'}, {q:'是否有艺术或文化类社团?'}]},
46
+ {category:'校园风景',data: [{q:'校园内有哪些打卡景点?'}, {q:'校园绿化做得好吗?'}, {q:'有湖泊或花园吗?'}, {q:'有特色建筑吗?'}, {q:'校园大不大?适合散步吗?'}, {q:'有哪些适合拍照的地方?'}, {q:'有室外自习空间吗?'}, {q:'校园晚上灯光如何?'}, {q:'有没有露天表演广场?'}, {q:'有樱花或银杏树吗?'}]},
47
+ {category:'招生流程',data: [{q:'什么时候开始填志愿?'}, {q:'招生简章在哪查看?'}, {q:'是否有预估分数线?'}, {q:'如何获取往年录取线?'}, {q:'能否跨省报考?'}, {q:'有哪些专项招生计划?'}, {q:'报志愿前可参观校园吗?'}, {q:'有无强基计划?'}, {q:'是否有面试环节?'}, {q:'报名后多久公布录取?'}]},
48
+ {category:'住宿生活',data: [{q:'几人一间宿舍?'}, {q:'宿舍有空调吗?'}, {q:'洗衣机是否自助?'}, {q:'有独立卫生间吗?'}, {q:'能否申请调换宿舍?'}, {q:'有晚归门禁吗?'}, {q:'网络信号好吗?'}, {q:'有宿舍文化活动吗?'}, {q:'宿舍能使用电器吗?'}, {q:'有快递柜或驿站吗?'}]},
49
+ {category:'餐饮服务',data: [{q:'食堂饭菜贵不贵?'}, {q:'食堂口味多样吗?'}, {q:'有无清真窗口?'}, {q:'学校周边吃饭方便吗?'}, {q:'是否支持刷脸就餐?'}, {q:'饭卡能否线上充值?'}, {q:'有没有饮品店?'}, {q:'食堂有无特色菜?'}, {q:'吃饭时间是否固定?'}, {q:'是否有外卖平台?'}]},
50
+ {category:'教学资源',data: [{q:'师资力量如何?'}, {q:'有外教课程吗?'}, {q:'是否提供选修课?'}, {q:'教材是否统一购买?'}, {q:'有开放实验室吗?'}, {q:'是否配有学习中心?'}, {q:'有哪些在线课程平台?'}, {q:'图书馆开放时间?'}, {q:'能否跨专业听课?'}, {q:'有无名师公开课?'}]},
51
+ {category:'就业实习',data: [{q:'是否提供实习机会?'}, {q:'就业指导服务如何?'}, {q:'有哪些合作企业?'}, {q:'实习是否计入学分?'}, {q:'就业率有多高?'}, {q:'毕业生去向有哪些?'}, {q:'能否推荐实习单位?'}, {q:'是否有职业规划课?'}, {q:'能考研继续深造吗?'}, {q:'就业双选会多不多?'}]},
52
+ ]
53
+ }
54
+
55
+ const style = `
56
+ .p_closeImg {
57
+ width: 14px;
58
+ cursor: pointer;
59
+ }
60
+
61
+ .p_toolDialog {
62
+ height:100%;
63
+ border-radius:8px;
64
+ display: flex;
65
+ flex-direction: column;
66
+ justify-content: space-between;
67
+ background: unset;
68
+ }
69
+ .p_toolDialog .p_sign{
70
+ width: calc(100vw - 140px);
71
+ min-width:1380px;
72
+ margin: 0 auto;
73
+ }
74
+
75
+ .dialog_box{
76
+ width: 100vw;
77
+ height:100vh;
78
+ background: #fff;
79
+ border-radius: 15px;
80
+ display: flex;
81
+ flex-direction: row;
82
+ }
83
+
84
+ .p_toolDialog .dialog_box .p_toolLogo {
85
+ user-select: none;
86
+ display: flex;
87
+ align-items: center;
88
+ justify-content: space-between;
89
+ margin-top: 18px;
90
+ padding-left: 32px;
91
+ padding-bottom:12px;
92
+ border-bottom: #E5E5E5 solid 1px;
93
+ }
94
+
95
+ .p_toolDialog .dialog_box .p_toolLogo .p_logoImg {
96
+ width: 48px;
97
+ position: absolute;
98
+ }
99
+
100
+ .p_toolDialog .dialog_box .p_toolLogo .p_logoText {
101
+ font-weight: bold;
102
+ margin-left: 10px;
103
+ font-size: 20px;
104
+ background: #000000;
105
+ // background: linear-gradient(to right, #1551FF, #8F4BFF);
106
+ -webkit-background-clip: text;
107
+ -webkit-text-fill-color: transparent;
108
+ }
109
+
110
+ .p_historyDialog {
111
+ user-select: none;
112
+ margin-top: 24px;
113
+ margin-bottom: 24px;
114
+ border-radius: 10px;
115
+ flex: 1;
116
+ width: 100%;
117
+ background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 100%);
118
+ border-image: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0)) 1 1;
119
+ backdrop-filter: blur(10px);
120
+ position: relative;
121
+ max-height:calc(100% - 60px);
122
+ padding:16px;
123
+ }
124
+
125
+ .p_historyDialog ::-webkit-scrollbar-thumb {
126
+ border-radius: 10px;
127
+ -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
128
+ background: #535353 !important;
129
+ }
130
+
131
+ .p_historyDialog .p_historyTitle {
132
+ display: flex;
133
+ align-items: center;
134
+ justify-content: space-between;
135
+ padding: unset;
136
+ }
137
+
138
+ .p_historyDialog .p_historyTitle .p_historyImg {
139
+ width: 25px;
140
+ }
141
+
142
+ .p_historyDialog .p_historyTitle .p_dialogTitle {
143
+ font-size: 18px;
144
+ line-height: 16px;
145
+ text-align: left;
146
+ font-style: normal;
147
+ display:flex;
148
+ font-weight: normal;
149
+ color: #A4A4A4;
150
+ }
151
+
152
+ .p_historyDialog .p_historyListEmpty {
153
+ position: absolute;
154
+ top: 50%;
155
+ left: 50%;
156
+ transform: translate(-50%, -50%);
157
+ text-align: center;
158
+ font-size: 12px;
159
+ color: #999999;
160
+ max-height: calc(100% - 1.7rem);
161
+
162
+ }
163
+
164
+ .p_historyDialog .p_historyList {
165
+ height: calc(100% - 1.7rem);
166
+ margin-top: 10px;
167
+ overflow-y: auto;
168
+ scrollbar-width: none !important; /* firefox */
169
+ }
170
+
171
+ .p_historyDialog .p_historyList::-webkit-scrollbar{
172
+ display:none;
173
+ }
174
+
175
+ .p_historyDialog .p_historyList:hover {
176
+ scrollbar-width: thin !important; /* firefox */
177
+ scrollbar-color: #ced4e3 transparent;
178
+ }
179
+
180
+ .p_historyDialog .p_historyList .p_historyItem {
181
+ padding: 10px 16px;
182
+ padding-left: 0;
183
+
184
+ }
185
+
186
+ .p_historyDialog .p_historyList .p_historyItem:hover{
187
+ background: #F5F5F5;
188
+ border-radius: 9px;
189
+ color: #1552FF
190
+ }
191
+
192
+ .p_historyDialog .p_historyList .p_historyItem:hover .p_historyName{
193
+
194
+ }
195
+
196
+ .p_historyDialog .p_historyList .p_activeItem{
197
+ background: #1974FF !important;
198
+ border-radius: 9px;
199
+ color:#FFFFFF !important;
200
+ }
201
+
202
+ .p_historyDialog .p_historyList .p_historyItem .p_historyName {
203
+ overflow: hidden;
204
+ text-overflow: ellipsis;
205
+ white-space: nowrap;
206
+ cursor: pointer;
207
+ display: flex;
208
+ align-items: center;
209
+ }
210
+
211
+ .p_historyDialog .p_historyList .p_historyItem .p_activeHistoryName {
212
+ color: #fff !important;
213
+ }
214
+
215
+ .p_toolDialog .p_toolRight {
216
+ flex: 1;
217
+ max-width: 780px;
218
+ margin-bottom:16px;
219
+ }
220
+
221
+ :where(.css-dev-only-do-not-override-1v613y0).ant-carousel .slick-dots li.slick-active::after{
222
+ background:#1974FF;
223
+ }
224
+
225
+ :where(.css-dev-only-do-not-override-1v613y0).ant-carousel .slick-dots li button{
226
+ background: #000000;
227
+ }
228
+
229
+ :where(.css-1v613y0).ant-carousel .slick-dots li.slick-active::after {
230
+ background: #1974FF;
231
+ }
232
+
233
+ :where(.css-1v613y0).ant-carousel .slick-dots li button {
234
+ background: #000000;
235
+ }
236
+
237
+ .p_newDialog {
238
+ width: 252px;
239
+ height: 40px;
240
+ min-height:40px;
241
+ cursor: pointer;
242
+ display: flex;
243
+ color:#0060FF;
244
+ align-items: center;
245
+ background: #EAF3FF;
246
+ border-radius: 11px;
247
+ border: 1px solid #1974FF;
248
+ transition: all 0.2s ease; /* 添加过渡动画 */
249
+ margin-top: unset;
250
+ }
251
+
252
+ .p_newDialog:hover {
253
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
254
+ }
255
+
256
+ .p_newDialog:active {
257
+ background-color: #c4d9ff;
258
+ border-color: #0040aa;
259
+ transform: translateY(2px); /* 模拟按下效果 */
260
+ box-shadow: none; /* 取消阴影,增强按下效果 */
261
+ }
262
+
263
+ .p_newDialog .p_newDialogText {
264
+ margin-left: 6px;
265
+ color: unset;
266
+ }
267
+ `
268
+
269
+ const defaultList = [
270
+ {
271
+ backgroundImg: 'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/ai/drop-down-item-card-01.png',
272
+ title: '我这学期的课程安排是什么样?',
273
+ },
274
+ {
275
+ backgroundImg: 'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/ai/drop-down-item-card-02.png',
276
+ title: '我上个学期的成绩是多少?',
277
+ },
278
+ {
279
+ backgroundImg: 'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/ai/drop-down-item-card-03.png',
280
+ title: '哪里可以找到心理咨询服务?',
281
+ },
282
+ ];
283
+
284
+ const api_key = 'sk-mniUFDpcWwvNF3iFzssXa6etN-S_Y4AApyHYcBU44L0';
285
+
286
+ export const MethodContext = React.createContext();
287
+
288
+ export class ToolDialogV3 extends React.Component {
289
+ sessionUserInfo = {};
290
+ state = {
291
+ appId:'',
292
+ historyList: [], // 历史对话列表
293
+ sessionId: uuidv4(), // 当前激活的对话对应的sessionId
294
+ dropDownList: [],
295
+ currentFlow: {},
296
+ knowledgeInfo: {},
297
+ loading: false,
298
+ allFlowList: [],
299
+ sceneInfo:{},
300
+ };
301
+
302
+ componentWillMount() {
303
+ const { userInfo = {} } = this.props;
304
+ const { sessionId } = this.state;
305
+ if (isEmpty(userInfo.code)) {
306
+ const code = sessionId.replaceAll("-", "").slice(2);
307
+ this.sessionUserInfo.code = code;
308
+ this.sessionUserInfo.id = code;
309
+ this.sessionUserInfo.name = code;
310
+ }else{
311
+ this.sessionUserInfo = userInfo;
312
+ }
313
+ }
314
+
315
+ async componentDidMount() {
316
+ const { appId: flowId,sceneId } = this.props;
317
+ this.setState({ appId: flowId }, () => {
318
+ this.getHistoryList(true);
319
+ })
320
+ this.getSceneInfo();
321
+ getFlowPage(this.props.hostUrl, api_key)
322
+ .then(res => {
323
+ if(res.status === 200) {
324
+ this.setState({ allFlowList: res.data?.data_list })
325
+ }
326
+ })
327
+ }
328
+
329
+ getCurrentFlowHistory=(flowId)=>{
330
+ const { sessionId } = this.state;
331
+ const operationId = this.sessionUserInfo['code'] || '';
332
+ getHistoryList(this.props.hostUrl, flowId, operationId).then((res) => {
333
+ if(res.status === 200 && typeof res.data !== "string" && typeof res.data !== "string"){
334
+ this.setState({ historyList: res.data });
335
+ }
336
+ });
337
+ }
338
+
339
+ // 获取历史对话列表
340
+ getHistoryList = (isRefreshWords) => {
341
+ const { isShowSideLeft = true } = this.props;
342
+ const { appId } = this.state;
343
+ // 单独组件情况
344
+ if(isRefreshWords){
345
+ this.getFlowInfo().then(currentFlow=>{
346
+ const dropDownList = this.getDropDownList(currentFlow?.welcome_words||[]);
347
+ this.setState({ dropDownList, currentFlow })
348
+ })
349
+ }
350
+ if(isShowSideLeft) {
351
+ this.getCurrentFlowHistory(appId)
352
+ }
353
+ };
354
+
355
+ getFlowInfo = async () => {
356
+ const res = await getFlowInfo(this.props.hostUrl, this.state.appId, api_key);
357
+ if(res.status === 200 && typeof res.data !== "string") {
358
+ // 查询知识库相关信息用作预置问题
359
+ getQaInfo(this.props.hostUrl, this.state.appId, api_key).then(res => {
360
+ if (res.status === 200 && typeof res.data !== "string") {
361
+ if ( !isEmpty(res.data) && !isEmpty(res.data.media) && !isEmpty(res.data.question)) {
362
+ this.setState({ knowledgeInfo: res.data })
363
+ } else if ( !isEmpty(this.props.knowledgeInfo)) {
364
+ this.setState({ knowledgeInfo: this.props.knowledgeInfo })
365
+ } else {
366
+ this.setState({ knowledgeInfo: knowledgeInfo })
367
+ }
368
+ }
369
+ }).catch(e => {
370
+ console.log(e);
371
+ });
372
+ this.setState({ currentFlow: res.data });
373
+ }
374
+ return res.data;
375
+ }
376
+
377
+ getSceneInfo = async () => {
378
+ const res = await getSceneInfo(this.props.hostUrl, this.props.sceneId, api_key);
379
+ if(res.status === 200 && typeof res.data !== "string") {
380
+ this.setState({ sceneInfo: res.data });
381
+ return res;
382
+ }
383
+ }
384
+
385
+ // 新建对话
386
+ newDialog = () => {
387
+ if(this.state.dropDownList) {
388
+ messageTip.info("当前已是最新对话")
389
+ return;
390
+ }
391
+ this.setState({ sessionId: uuidv4() });
392
+ this.setState({ dropDownList: this.getDropDownList(this.state.currentFlow?.welcome_words||[]) })
393
+ }
394
+
395
+ updateSessionId = (sessionId) => {
396
+ this.setState({ sessionId });
397
+ };
398
+
399
+ registerChatMethods = ({ isActiveMessage, handleSendMessage }) => {
400
+ this.handleSendMessage = handleSendMessage;
401
+ this.isActiveMessage = isActiveMessage;
402
+ }
403
+
404
+
405
+ handleClick = (word) => {
406
+ if(!this.isActiveMessage()){
407
+ this.handleSendMessage(word);
408
+ }else{
409
+ message.destroy();
410
+ message.info("请等待回复结束后再发送")
411
+ }
412
+ };
413
+
414
+ getDropDownList = (welcome_words)=>{
415
+ if(isEmpty(welcome_words)){
416
+ return defaultList;
417
+ }
418
+ return welcome_words.slice(0,3).map((question,index)=>(
419
+ {
420
+ backgroundImg:defaultList[index].backgroundImg,
421
+ title:question,
422
+ }
423
+ ))
424
+ }
425
+
426
+ handleSetDialog = (flow) => {
427
+ this.setState({ loading: true },
428
+ () => this.setState({ appId: flow.id },
429
+ () => {
430
+ this.getHistoryList(true);
431
+ this.newDialog();
432
+ setTimeout(()=>{
433
+ this.setState({ loading: false })
434
+ },500)
435
+ }))
436
+ }
437
+
438
+ addToScene = (flow) => {
439
+ const { sceneInfo } = this.state;
440
+ sceneInfo.flow_ids = [...sceneInfo.flow_ids, flow.id]
441
+ modifyScene(this.props.hostUrl, api_key, sceneInfo).then(res => {
442
+ if(res.status === 200) {
443
+ this.getSceneInfo();
444
+ }
445
+ })
446
+ }
447
+
448
+ removeFromScene = (flow) => {
449
+ const { sceneInfo } = this.state;
450
+ sceneInfo.flow_ids = sceneInfo.flow_ids.filter(item => item !== flow.id)
451
+ modifyScene(this.props.hostUrl, api_key, sceneInfo).then(res => {
452
+ if(res.status === 200) {
453
+ this.getSceneInfo();
454
+ }
455
+ })
456
+ }
457
+
458
+ render() {
459
+ const {
460
+ title,
461
+ hostUrl,
462
+ setDialogVisible,
463
+ userInfo,
464
+ boxStyle,
465
+ tags = [],
466
+ agentUrl = aiAvatarPng,
467
+ agentName = '校园智多星',
468
+ logoWidth = '42px',
469
+ logoFontSize = '26px',
470
+ isTitleSideIcon = false,// 是否将左侧历史顶部icon移到中间顶部左侧蓝点位置
471
+ assetMap,
472
+ isShowUploadButton = false,
473
+ modalWidth,
474
+ isShowReadIcon = false,
475
+ cnxwBottomUrl,
476
+ isShowVoiceButton,
477
+ isHideTabSelector,
478
+ dialogStyle,
479
+ customAiToldYou
480
+ } = this.props;
481
+ const { currentFlow = {}, appId } = this.state;
482
+ return (
483
+ <div style={boxStyle}>
484
+ <style dangerouslySetInnerHTML={{ __html: style }}></style>
485
+ <div className="p_toolDialog">
486
+ <div className={"dialog_box"} style={dialogStyle}>
487
+ <LeftMenu
488
+ onNewChat={this.newDialog} // 如果有新建会话方法
489
+ onSelectSession={this.handleSetDialog} // 如果有切换会话方法
490
+ activeId={this.state.sessionId} // 根据你的状态字段调整
491
+ userInfo={userInfo}
492
+ sceneInfo={this.state.sceneInfo}
493
+ handleLoadHistoryList={async () => getHistoryList(this.props.hostUrl, appId, this.sessionUserInfo['code'] || '')}
494
+ addToScene={this.addToScene}
495
+ removeFromScene={this.removeFromScene}
496
+ appId={appId}
497
+ flow={currentFlow}
498
+ allFlowList={this.state.allFlowList}
499
+ />
500
+ <div style={{flex:1,display:'flex',flexDirection:'column',height:'100vh'}}>
501
+ <div className="p_toolLogo">
502
+ {
503
+ <div style={{ display: 'flex', alignItems: 'center', flexDirection: 'row' }}>
504
+ <div style={{
505
+ width: logoWidth,
506
+ height: logoWidth,
507
+ backgroundColor: '#D5D5D5',
508
+ borderRadius: '22px',
509
+ position: 'relative',
510
+ overflow: 'hidden',
511
+ }}>
512
+ {
513
+ this.state.loading ? <Skeleton
514
+ title={false}
515
+ style={{ padding: '0px' }}
516
+ active
517
+ paragraph={{ rows: 1, width: '100%', style: { margin: '0px', } }}
518
+ /> :
519
+ <img className="p_logoImg" src={currentFlow.icon}/>
520
+ }
521
+ </div>
522
+ <div className="p_logoText" style={{ fontSize: logoFontSize }}>{currentFlow.name}</div>
523
+ </div>
524
+ }
525
+ <div style={{ display: 'flex', alignItems: 'center', flexDirection: 'row' }}>
526
+ <PlusOutlined
527
+ style={{ marginRight: '16px', fontSize: '20px' }}
528
+ onClick={() => {
529
+ this.newDialog();
530
+ }}
531
+ />
532
+ <HistoryOutlined
533
+ style={{ marginRight: '16px', fontSize: '20px' }}
534
+ onClick={() => {
535
+ this.setState({ isShowHistoryList: true })
536
+ }}
537
+ />
538
+ </div>
539
+ </div>
540
+ <div style={{
541
+ display: 'flex',
542
+ flexDirection: "row",
543
+ justifyContent: 'center',
544
+ flex: 1,
545
+ height: 'calc(100% - 75px)'
546
+ }}>
547
+ {
548
+ this.state.loading ? <Skeleton
549
+ title={false}
550
+ style={{ padding: '20px' }}
551
+ active
552
+ paragraph={{ rows: 5, width: '100%' }}
553
+ /> :
554
+ <div className="p_toolRight" style={{ borderBottomRightRadius: '15px' }}>
555
+ <MethodContext.Provider value={{ registerChatMethods: this.registerChatMethods }}>
556
+ <ChatWidget
557
+ window_title={currentFlow?.name || title}
558
+ flow_id={currentFlow?.id || appId}
559
+ tags={currentFlow?.keywords || tags}
560
+ is_enable_call={currentFlow?.is_enable_call || false}
561
+ host_url={hostUrl}
562
+ api_key={api_key}
563
+ session_id={this.state.sessionId}
564
+ userInfo={this.sessionUserInfo}
565
+ getHistoryList={this.getHistoryList}
566
+ setDropDownList={(list) => this.setState({ dropDownList: list })}
567
+ // dropDownList={this.state.dropDownList}
568
+ baseConfig={{
569
+ isTitleSideIcon,
570
+ logoWidth,
571
+ agentUrl, ...assetMap,
572
+ isHideTabSelector,
573
+ customAiToldYou
574
+ }}
575
+ isShowUploadButton={isShowUploadButton}
576
+ isShowVoiceButton={isShowVoiceButton}
577
+ dropManUrl={currentFlow.character}
578
+ modalWidth={modalWidth}
579
+ isShowReadIcon={isShowReadIcon}
580
+ isShowChatHeader={false}
581
+ renderCustomDropDown={this.renderCustomDropDown}
582
+ isTagsHidden={true}
583
+ placeholder={'请输入您想咨询的问题'}
584
+ isEnableForV1={false}
585
+ questions={this.state.knowledgeInfo?.question || []}
586
+ voice={currentFlow.call_voice}
587
+ cnxwBottomUrl={cnxwBottomUrl}
588
+ />
589
+ </MethodContext.Provider>
590
+ </div>
591
+ }
592
+ </div>
593
+ </div>
594
+ </div>
595
+ </div>
596
+ <Drawer
597
+ title={null}
598
+ closable={false}
599
+ placement="right"
600
+ width={'300px'}
601
+ bodyStyle={{ padding: 0 }}
602
+ onClose={() => this.setState({ isShowHistoryList: false })}
603
+ open={this.state.isShowHistoryList}
604
+ >
605
+ <div className="p_historyDialog">
606
+ <div className="p_historyTitle">
607
+ <div className="p_dialogTitle">对话列表</div>
608
+ <Tooltip
609
+ title={isEmpty(userInfo) ? '当前历史记录将会在页面刷新后清除' : '历史对话记录'}><HistoryOutlined
610
+ style={{ color: '#A4A4A4' }}/></Tooltip>
611
+ </div>
612
+ {this.state.historyList.length > 0 ? (
613
+ <div className="p_historyList">
614
+ {this.state.historyList?.map((item) => (
615
+ <div
616
+ key={item.session_id}
617
+ className={`p_historyItem ${item.session_id === this.state.sessionId ? 'p_activeItem' : ''}`}
618
+ onClick={() => {
619
+ this.setState({ dropDownList: undefined })
620
+ this.updateSessionId(item.session_id);
621
+ }}
622
+ >
623
+ <div
624
+ className={`p_historyName ${item.session_id === this.state.sessionId ? 'p_activeHistoryName' : ''}`}
625
+ >
626
+ <CommentIcon style={{
627
+ marginRight: '8px',
628
+ fill: item.session_id === this.state.sessionId ? '#FFFFFF' : '#bfbfbf'
629
+ }}/>
630
+ <span>{item.text}</span>
631
+ </div>
632
+ </div>
633
+ ))}
634
+ </div>
635
+ ) : (
636
+ <div className="p_historyListEmpty">
637
+ <img src={historyListEmptyPng}/>
638
+ <div className="p_historyListEmptyText">暂无对话记录</div>
639
+ </div>
640
+ )}
641
+ </div>
642
+ </Drawer>
643
+ </div>
644
+ );
645
+ }
646
+ }
647
+
648
+ export default ToolDialogV3;