yt-chat-components 0.4.0 → 0.6.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/.idea/sonarlint/issuestore/2/7/27e69cb561aeea20c1afbdd32d260dd60b89a81b +0 -0
- package/.idea/sonarlint/issuestore/2/e/2e9f70bf32b414323ca1647e2b6f26e1533ee2fc +0 -0
- package/.idea/sonarlint/issuestore/3/6/364385cedcce4c06de1901392ffeeac0caef0f3c +0 -0
- package/.idea/sonarlint/issuestore/4/b/4b015aa5428c4d4c3d672893ec23f5fe3969f9be +0 -0
- package/.idea/sonarlint/issuestore/5/a/5ab44fe33ca96299f51ad4778a73e425b92bf439 +0 -0
- package/.idea/sonarlint/issuestore/6/1/61ebb9fd6e8cf9082658121d5d81e297791dacd0 +0 -0
- package/.idea/sonarlint/issuestore/6/c/6c024c1d0ad64656b9d4b0695ec3c49c0454addf +0 -0
- package/.idea/sonarlint/issuestore/6/e/6e75fc1c07c3a427a86fc213ca9479caaaff00ea +0 -0
- package/.idea/sonarlint/issuestore/c/c/cc2352788140b6778ac06df4b33f50b390d2d8be +0 -0
- package/.idea/sonarlint/issuestore/d/5/d5595158cc48f9bf3e51b06f6e6805a8fd2d6262 +0 -0
- package/.idea/sonarlint/issuestore/d/7/d747cbed4201192dfa83a1a51345b020a050b647 +0 -0
- package/.idea/sonarlint/issuestore/index.pb +23 -1
- 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 +79 -44
|
@@ -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';
|
|
@@ -324,13 +324,13 @@ export class ToolDialog extends React.Component {
|
|
|
324
324
|
async componentDidMount() {
|
|
325
325
|
if(isEmpty(this.props.sceneId)){
|
|
326
326
|
// 兼容非场景打开的情况
|
|
327
|
-
this.getHistoryList();
|
|
327
|
+
this.getHistoryList({},true);
|
|
328
328
|
}else{
|
|
329
329
|
const sceneData = await this.getSceneInfo();
|
|
330
330
|
if(isEmpty(sceneData)) {
|
|
331
|
-
this.getHistoryList();
|
|
331
|
+
this.getHistoryList({},true);
|
|
332
332
|
} else {
|
|
333
|
-
this.getHistoryList(sceneData);
|
|
333
|
+
this.getHistoryList(sceneData,true);
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
}
|
|
@@ -345,18 +345,26 @@ export class ToolDialog extends React.Component {
|
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
// 获取历史对话列表
|
|
348
|
-
getHistoryList = (sceneData) => {
|
|
349
|
-
const
|
|
350
|
-
if(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
348
|
+
getHistoryList = (sceneData, isRefreshWords) => {
|
|
349
|
+
const { sceneId, flowId } = this.props;
|
|
350
|
+
if(isEmpty(sceneId)){
|
|
351
|
+
console.log("dropDownList",this.state.dropDownList)
|
|
352
|
+
// 单独组件情况
|
|
353
|
+
if(isRefreshWords){
|
|
354
|
+
this.setState({ dropDownList: defaultList })
|
|
355
|
+
}
|
|
356
|
+
this.getCurrentFlowHistory(flowId)
|
|
355
357
|
}else{
|
|
356
|
-
this.
|
|
357
|
-
|
|
358
|
+
const currentScene = sceneData||this.state.sceneInfo;
|
|
359
|
+
const currentFlow = currentScene.flows[0];
|
|
360
|
+
const dropDownList = this.getDropDownList(currentFlow.welcome_words);
|
|
361
|
+
if(!isEmpty(sceneData)){
|
|
362
|
+
this.setState({ currentFlow, dropDownList })
|
|
363
|
+
}else if(isEmpty(this.state.sceneInfo)){
|
|
364
|
+
this.setState({ dropDownList:defaultList })
|
|
365
|
+
}
|
|
366
|
+
this.getCurrentFlowHistory(currentFlow.id)
|
|
358
367
|
}
|
|
359
|
-
this.getCurrentFlowHistory(realFlowId)
|
|
360
368
|
};
|
|
361
369
|
|
|
362
370
|
getSceneInfo = async ()=>{
|
|
@@ -466,7 +474,7 @@ export class ToolDialog extends React.Component {
|
|
|
466
474
|
/>
|
|
467
475
|
</div>
|
|
468
476
|
{
|
|
469
|
-
isShowSideRight&&
|
|
477
|
+
isShowSideRight &&
|
|
470
478
|
<div className={"p_toolRightToRight"}>
|
|
471
479
|
<div className={"rightInnerContainer"}>
|
|
472
480
|
<div>
|
|
@@ -474,42 +482,69 @@ export class ToolDialog extends React.Component {
|
|
|
474
482
|
<img width={15} src={self_skills}/>
|
|
475
483
|
<span style={{ color: "#333333" }}>专项技能</span>
|
|
476
484
|
</h3>
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
485
|
+
{
|
|
486
|
+
isEmpty(flows) ?
|
|
487
|
+
<Skeleton
|
|
488
|
+
title={false}
|
|
489
|
+
active
|
|
490
|
+
paragraph={{ rows: 5, width: '100%' }}
|
|
491
|
+
/>
|
|
492
|
+
:
|
|
493
|
+
<div className={"rightSkillContainer"}>
|
|
494
|
+
<div className={"rightSkillList"}>
|
|
495
|
+
{flows.slice(0, 12).map((item) => (
|
|
496
|
+
<div className={"rightSkillItem"} key={item.id} onClick={() => {
|
|
497
|
+
// 右侧点击一个技能,更新sessionId,切换当前flow信息,重新查询历史记录
|
|
498
|
+
this.setState({
|
|
499
|
+
sessionId: uuidv4(),
|
|
500
|
+
currentFlow: item,
|
|
501
|
+
dropDownList: this.getDropDownList(item.welcome_words)
|
|
502
|
+
});
|
|
503
|
+
this.getCurrentFlowHistory(item.id);
|
|
504
|
+
}}>
|
|
505
|
+
<img
|
|
506
|
+
src={item.icon}
|
|
507
|
+
alt={item.name}/>
|
|
508
|
+
<p>{item.name}</p>
|
|
509
|
+
</div>
|
|
510
|
+
))}
|
|
493
511
|
</div>
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
</div>
|
|
512
|
+
</div>
|
|
513
|
+
}
|
|
497
514
|
</div>
|
|
498
515
|
<div>
|
|
499
516
|
<h3 className={"rightKnowledgeTitle"}>
|
|
500
517
|
<img width={15} src={self_knowledge}/>
|
|
501
518
|
<span style={{ color: "#333333" }}>个人知识库</span>
|
|
502
519
|
</h3>
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
520
|
+
{
|
|
521
|
+
isEmpty(currentFlow) ?
|
|
522
|
+
<Skeleton
|
|
523
|
+
title={false}
|
|
524
|
+
active
|
|
525
|
+
paragraph={{ rows: 5, width: '100%' }}
|
|
526
|
+
/> :
|
|
527
|
+
<div className={"rightKnowledgeContainer"}>
|
|
528
|
+
<img src={moreBg}/>
|
|
529
|
+
<div style={{ position: 'absolute', top: '40px', left: '16px' }}>
|
|
530
|
+
<div>文件总数<span style={{
|
|
531
|
+
padding: 8,
|
|
532
|
+
fontSize: '20px',
|
|
533
|
+
fontWeight: 700
|
|
534
|
+
}}>{currentFlow.k_count || 0}</span>个
|
|
535
|
+
</div>
|
|
536
|
+
<div style={{ marginTop: 10 }}>文件总量<span style={{
|
|
537
|
+
padding: 8,
|
|
538
|
+
fontSize: '20px',
|
|
539
|
+
fontWeight: 700
|
|
540
|
+
}}>{formatFileSize(currentFlow.k_size).formattedSize}</span>{formatFileSize(currentFlow.k_size).unit}
|
|
541
|
+
</div>
|
|
542
|
+
</div>
|
|
543
|
+
<div className={"rightMoreButton"}>
|
|
544
|
+
<div className={"rightMoreTitle"} onClick={() => messageTip.info("敬请期待")}>训练你的专属知识库</div>
|
|
545
|
+
</div>
|
|
546
|
+
</div>
|
|
547
|
+
}
|
|
513
548
|
</div>
|
|
514
549
|
</div>
|
|
515
550
|
</div>
|