yt-chat-components 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/static/js/bundle.min.js +1 -1
- package/build/static/js/bundle.min.js.LICENSE.txt +8 -0
- package/package.json +1 -1
- package/src/YtChatView/chatWidget/chatWindow/controllers/index.ts +7 -5
- package/src/YtChatView/chatWidget/chatWindow/index.tsx +11 -3
- package/src/YtChatView/chatWidget/index.tsx +4 -3
- package/src/YtChatView/previewDialog/index.jsx +73 -40
- package/yt-chat-components-0.4.0.tgz +0 -0
|
@@ -97,10 +97,18 @@
|
|
|
97
97
|
|
|
98
98
|
/** */
|
|
99
99
|
|
|
100
|
+
/** */
|
|
101
|
+
|
|
100
102
|
/** */
|
|
101
103
|
|
|
102
104
|
/** */
|
|
103
105
|
|
|
106
|
+
/** */
|
|
107
|
+
|
|
108
|
+
/** */
|
|
109
|
+
|
|
110
|
+
/** */
|
|
111
|
+
|
|
104
112
|
/** */
|
|
105
113
|
|
|
106
114
|
/** */
|
package/package.json
CHANGED
|
@@ -48,7 +48,7 @@ export async function sendMessage(
|
|
|
48
48
|
if (embed_app_extend) {
|
|
49
49
|
data['embed_app_extend'] = embed_app_extend;
|
|
50
50
|
}
|
|
51
|
-
let headers: { [key: string]: string } = {'Content-Type': 'application/json'};
|
|
51
|
+
let headers: { [key: string]: string } = {'Content-Type': 'application/json', 'timeout': 600000};
|
|
52
52
|
if (api_key) {
|
|
53
53
|
headers['x-api-key'] = api_key;
|
|
54
54
|
}
|
|
@@ -81,7 +81,7 @@ export async function sendMessage(
|
|
|
81
81
|
async function fetchCustomStream(url, body, headers, handleMessageContent, signal) {
|
|
82
82
|
const response = await fetch(url, {
|
|
83
83
|
method: 'POST',
|
|
84
|
-
headers: headers,
|
|
84
|
+
headers: {...headers, timeout: 600000},
|
|
85
85
|
body: JSON.stringify(body),
|
|
86
86
|
signal: signal,
|
|
87
87
|
});
|
|
@@ -182,7 +182,7 @@ function extractAndParseJSON(buffer, handleMessageContent) {
|
|
|
182
182
|
* @param operatorId
|
|
183
183
|
*/
|
|
184
184
|
export async function getHistoryList(baseUrl: string, flowId: string, operatorId: string) {
|
|
185
|
-
return axios.get(`${baseUrl}/api/v1/embed/chat_history_list/${flowId}/${operatorId}
|
|
185
|
+
return axios.get(`${baseUrl}/api/v1/embed/chat_history_list/${flowId}/${operatorId}`, {timeout: 600000});
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/**
|
|
@@ -212,7 +212,8 @@ export async function getChatHistory(
|
|
|
212
212
|
export async function fetchUploadFile(baseUrl: string, file: File, flowId: string, api_key: string) {
|
|
213
213
|
const headers = {
|
|
214
214
|
'Content-Type': 'multipart/form-data',
|
|
215
|
-
'x-api-key': api_key
|
|
215
|
+
'x-api-key': api_key,
|
|
216
|
+
timeout:600000
|
|
216
217
|
};
|
|
217
218
|
const formData = new FormData();
|
|
218
219
|
formData.append('file', file);
|
|
@@ -230,7 +231,8 @@ export async function fetchUploadFile(baseUrl: string, file: File, flowId: strin
|
|
|
230
231
|
export async function getSceneInfo(baseUrl: string, sceneId: string, api_key: string) {
|
|
231
232
|
const headers = {
|
|
232
233
|
'Content-Type': 'multipart/form-data',
|
|
233
|
-
'x-api-key': api_key
|
|
234
|
+
'x-api-key': api_key,
|
|
235
|
+
timeout:600000
|
|
234
236
|
};
|
|
235
237
|
return axios.get(`${baseUrl}/api/t1/scene/detail/${sceneId}`,{headers});
|
|
236
238
|
}
|
|
@@ -22,7 +22,7 @@ import typeRPubPng from '../../../assets/aicenter/type-rpub.png';
|
|
|
22
22
|
import soundWavePng from '../../../assets/aicenter/sound-wave.gif';
|
|
23
23
|
import luyinPng from '../../../assets/aicenter/luyin.png';
|
|
24
24
|
import { RightOutlined } from '@ant-design/icons';
|
|
25
|
-
import { Image, message as messageTip, Tooltip } from 'antd';
|
|
25
|
+
import { Image, message as messageTip, Tooltip, Typography } from 'antd';
|
|
26
26
|
import { isEmpty, isFunction } from 'lodash';
|
|
27
27
|
import btn_answer from '../../../assets/aicenter/btn_answer.png';
|
|
28
28
|
|
|
@@ -591,7 +591,9 @@ export default function ChatWindow({
|
|
|
591
591
|
fetchChatHistory();
|
|
592
592
|
|
|
593
593
|
return () => {
|
|
594
|
-
abortControllerRef.current.abort();
|
|
594
|
+
abortControllerRef.current.abort('disconnect');
|
|
595
|
+
// abortControllerRef是一次性的,中止之后要初始化,否则fetch请求会被中止导致请求无响应
|
|
596
|
+
abortControllerRef.current = new AbortController();
|
|
595
597
|
};
|
|
596
598
|
}, [sessionId]);
|
|
597
599
|
|
|
@@ -612,7 +614,13 @@ export default function ChatWindow({
|
|
|
612
614
|
<div className="drop-down-list">
|
|
613
615
|
{dropDownList.map(({ backgroundImg, title }) => (
|
|
614
616
|
<div className="drop-down-item-card" key={title}>
|
|
615
|
-
|
|
617
|
+
<Typography.Paragraph
|
|
618
|
+
className="drop-down-item-title"
|
|
619
|
+
ellipsis={{
|
|
620
|
+
rows: 2,
|
|
621
|
+
tooltip: `“${title}”`,
|
|
622
|
+
}}>{'“'+title+'”'}
|
|
623
|
+
</Typography.Paragraph>
|
|
616
624
|
<div className="drop-down-item-bottom">
|
|
617
625
|
<div
|
|
618
626
|
className="drop-down-item-bottom-button"
|
|
@@ -495,8 +495,8 @@ video {
|
|
|
495
495
|
}
|
|
496
496
|
.drop-down-item-card {
|
|
497
497
|
width: 32%;
|
|
498
|
-
padding: 1.
|
|
499
|
-
height:
|
|
498
|
+
padding: 1.2rem 1.2rem 0.3rem;
|
|
499
|
+
height:7.5rem;
|
|
500
500
|
font-weight: 400;
|
|
501
501
|
font-size: 14px;
|
|
502
502
|
color: #FFFFFF;
|
|
@@ -516,9 +516,10 @@ video {
|
|
|
516
516
|
font-weight: 400;
|
|
517
517
|
font-size: 16px;
|
|
518
518
|
color: #000000;
|
|
519
|
-
line-height:
|
|
519
|
+
line-height: 20px;
|
|
520
520
|
text-align: left;
|
|
521
521
|
width: 100%;
|
|
522
|
+
margin-bottom:0 !important;
|
|
522
523
|
}
|
|
523
524
|
.drop-down-item-bottom{
|
|
524
525
|
display:flex;
|
|
@@ -9,7 +9,7 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
9
9
|
import historyListEmptyPng from '../../assets/aicenter/history-list-empty.png';
|
|
10
10
|
import addPng from '../../assets/aicenter/add.png';
|
|
11
11
|
import {isEmpty, isFunction} from "lodash";
|
|
12
|
-
import { Button, message as messageTip, Progress } from 'antd'
|
|
12
|
+
import { Button, message as messageTip, Progress, Skeleton } from 'antd'
|
|
13
13
|
import { CloseOutlined } from "@ant-design/icons";
|
|
14
14
|
import moreAi from '../../assets/aicenter/moreAi.png';
|
|
15
15
|
import moreBg from '../../assets/aicenter/moreBg.png';
|
|
@@ -346,17 +346,23 @@ export class ToolDialog extends React.Component {
|
|
|
346
346
|
|
|
347
347
|
// 获取历史对话列表
|
|
348
348
|
getHistoryList = (sceneData) => {
|
|
349
|
-
const
|
|
350
|
-
if(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
this.setState({ currentFlow, dropDownList })
|
|
355
|
-
}else{
|
|
356
|
-
this.setState({ dropDownList:defaultList })
|
|
349
|
+
const { sceneId, flowId } = this.props;
|
|
350
|
+
if(isEmpty(sceneId)){
|
|
351
|
+
// 单独组件情况
|
|
352
|
+
this.setState({ dropDownList: defaultList })
|
|
353
|
+
this.getCurrentFlowHistory(flowId)
|
|
357
354
|
|
|
355
|
+
}else{
|
|
356
|
+
const currentScene = sceneData||this.state.sceneInfo;
|
|
357
|
+
const currentFlow = currentScene.flows[0];
|
|
358
|
+
const dropDownList = this.getDropDownList(currentFlow.welcome_words);
|
|
359
|
+
if(!isEmpty(sceneData)){
|
|
360
|
+
this.setState({ currentFlow, dropDownList })
|
|
361
|
+
}else if(isEmpty(this.state.sceneInfo)){
|
|
362
|
+
this.setState({ dropDownList:defaultList })
|
|
363
|
+
}
|
|
364
|
+
this.getCurrentFlowHistory(currentFlow.id)
|
|
358
365
|
}
|
|
359
|
-
this.getCurrentFlowHistory(realFlowId)
|
|
360
366
|
};
|
|
361
367
|
|
|
362
368
|
getSceneInfo = async ()=>{
|
|
@@ -466,7 +472,7 @@ export class ToolDialog extends React.Component {
|
|
|
466
472
|
/>
|
|
467
473
|
</div>
|
|
468
474
|
{
|
|
469
|
-
isShowSideRight&&
|
|
475
|
+
isShowSideRight &&
|
|
470
476
|
<div className={"p_toolRightToRight"}>
|
|
471
477
|
<div className={"rightInnerContainer"}>
|
|
472
478
|
<div>
|
|
@@ -474,42 +480,69 @@ export class ToolDialog extends React.Component {
|
|
|
474
480
|
<img width={15} src={self_skills}/>
|
|
475
481
|
<span style={{ color: "#333333" }}>专项技能</span>
|
|
476
482
|
</h3>
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
483
|
+
{
|
|
484
|
+
isEmpty(flows) ?
|
|
485
|
+
<Skeleton
|
|
486
|
+
title={false}
|
|
487
|
+
active
|
|
488
|
+
paragraph={{ rows: 5, width: '100%' }}
|
|
489
|
+
/>
|
|
490
|
+
:
|
|
491
|
+
<div className={"rightSkillContainer"}>
|
|
492
|
+
<div className={"rightSkillList"}>
|
|
493
|
+
{flows.slice(0, 12).map((item) => (
|
|
494
|
+
<div className={"rightSkillItem"} key={item.id} onClick={() => {
|
|
495
|
+
// 右侧点击一个技能,更新sessionId,切换当前flow信息,重新查询历史记录
|
|
496
|
+
this.setState({
|
|
497
|
+
sessionId: uuidv4(),
|
|
498
|
+
currentFlow: item,
|
|
499
|
+
dropDownList: this.getDropDownList(item.welcome_words)
|
|
500
|
+
});
|
|
501
|
+
this.getCurrentFlowHistory(item.id);
|
|
502
|
+
}}>
|
|
503
|
+
<img
|
|
504
|
+
src={item.icon}
|
|
505
|
+
alt={item.name}/>
|
|
506
|
+
<p>{item.name}</p>
|
|
507
|
+
</div>
|
|
508
|
+
))}
|
|
493
509
|
</div>
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
</div>
|
|
510
|
+
</div>
|
|
511
|
+
}
|
|
497
512
|
</div>
|
|
498
513
|
<div>
|
|
499
514
|
<h3 className={"rightKnowledgeTitle"}>
|
|
500
515
|
<img width={15} src={self_knowledge}/>
|
|
501
516
|
<span style={{ color: "#333333" }}>个人知识库</span>
|
|
502
517
|
</h3>
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
518
|
+
{
|
|
519
|
+
isEmpty(currentFlow) ?
|
|
520
|
+
<Skeleton
|
|
521
|
+
title={false}
|
|
522
|
+
active
|
|
523
|
+
paragraph={{ rows: 5, width: '100%' }}
|
|
524
|
+
/> :
|
|
525
|
+
<div className={"rightKnowledgeContainer"}>
|
|
526
|
+
<img src={moreBg}/>
|
|
527
|
+
<div style={{ position: 'absolute', top: '40px', left: '16px' }}>
|
|
528
|
+
<div>文件总数<span style={{
|
|
529
|
+
padding: 8,
|
|
530
|
+
fontSize: '20px',
|
|
531
|
+
fontWeight: 700
|
|
532
|
+
}}>{currentFlow.k_count || 0}</span>个
|
|
533
|
+
</div>
|
|
534
|
+
<div style={{ marginTop: 10 }}>文件总量<span style={{
|
|
535
|
+
padding: 8,
|
|
536
|
+
fontSize: '20px',
|
|
537
|
+
fontWeight: 700
|
|
538
|
+
}}>{formatFileSize(currentFlow.k_size).formattedSize}</span>{formatFileSize(currentFlow.k_size).unit}
|
|
539
|
+
</div>
|
|
540
|
+
</div>
|
|
541
|
+
<div className={"rightMoreButton"}>
|
|
542
|
+
<div className={"rightMoreTitle"} onClick={() => messageTip.info("敬请期待")}>训练你的专属知识库</div>
|
|
543
|
+
</div>
|
|
544
|
+
</div>
|
|
545
|
+
}
|
|
513
546
|
</div>
|
|
514
547
|
</div>
|
|
515
548
|
</div>
|
|
Binary file
|