yt-chat-components 1.1.8 → 1.1.9
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/src/YtChatView/chatWidget/chatWindow/callInterface/index.tsx +29 -18
- package/src/YtChatView/chatWidget/chatWindow/index.tsx +4 -1
- package/src/YtChatView/previewDialog/index.jsx +1 -1
- package/src/assets/aicenter/ai_call_thinking.png +0 -0
- package/src/assets/aicenter/ai_call_working.gif +0 -0
package/package.json
CHANGED
|
@@ -6,7 +6,10 @@ import { ChatMessageType } from '../../chatWindow/types/chatWidget';
|
|
|
6
6
|
import Recorder from 'recorder-core'
|
|
7
7
|
import 'recorder-core/src/engine/mp3'
|
|
8
8
|
import 'recorder-core/src/engine/mp3-engine'
|
|
9
|
-
import 'recorder-core/src/extensions/waveview'
|
|
9
|
+
// import 'recorder-core/src/extensions/waveview'
|
|
10
|
+
import ai_call_thinking from '../../../../assets/aicenter/ai_call_thinking.png'
|
|
11
|
+
import ai_call_working from '../../../../assets/aicenter/ai_call_working.gif'
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
interface CallInterfaceProps {
|
|
12
15
|
onHangup: () => void;
|
|
@@ -17,6 +20,9 @@ interface CallInterfaceProps {
|
|
|
17
20
|
sessionId: React.MutableRefObject<string>;
|
|
18
21
|
hostUrl: string;
|
|
19
22
|
addMessage: (message: ChatMessageType) => void;
|
|
23
|
+
userInfo: {
|
|
24
|
+
code: string;
|
|
25
|
+
};
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
const CallInterface: React.FC<CallInterfaceProps> = ({
|
|
@@ -27,7 +33,8 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
|
|
|
27
33
|
flowId,
|
|
28
34
|
sessionId,
|
|
29
35
|
hostUrl,
|
|
30
|
-
addMessage
|
|
36
|
+
addMessage,
|
|
37
|
+
userInfo,
|
|
31
38
|
}) => {
|
|
32
39
|
const [callDuration, setCallDuration] = useState(0);
|
|
33
40
|
const [callStatus, setCallStatus] = useState<'connecting' | 'connected'>('connecting');
|
|
@@ -46,7 +53,7 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
|
|
|
46
53
|
const remoteStreamRef = useRef<MediaStream | null>(null);
|
|
47
54
|
const remoteAudioRef = useRef<HTMLAudioElement>(null);
|
|
48
55
|
let responseAudio: any = null;
|
|
49
|
-
let wave: any = null;
|
|
56
|
+
// let wave: any = null;
|
|
50
57
|
const wsRef = useRef<WebSocket | null>(null);
|
|
51
58
|
|
|
52
59
|
// VAD相关引用
|
|
@@ -135,10 +142,11 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
|
|
|
135
142
|
]
|
|
136
143
|
});
|
|
137
144
|
peerConnectionRef.current = peerConnection;
|
|
138
|
-
|
|
145
|
+
const {code} = userInfo;
|
|
146
|
+
const opeartorId = code || sessionId;
|
|
139
147
|
// 创建WebSocket连接
|
|
140
148
|
console.log('开始连接WebSocket', flowId, sessionId, api_key);
|
|
141
|
-
const ws = new WebSocket(`${hostUrl.replace('http', 'ws')}/api/v1/ws/webrtc?flow_id=${flowId}&session_id=${sessionId}&api_key=${api_key}&operator_id
|
|
149
|
+
const ws = new WebSocket(`${hostUrl.replace('http', 'ws')}/api/v1/ws/webrtc?flow_id=${flowId}&session_id=${sessionId}&api_key=${api_key}&operator_id=${opeartorId}`);
|
|
142
150
|
wsRef.current = ws;
|
|
143
151
|
|
|
144
152
|
// 添加连接超时处理
|
|
@@ -236,16 +244,16 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
|
|
|
236
244
|
//可实时上传(发送)数据,配合Recorder.SampleData方法,将buffers中的新数据连续的转换成pcm上传,或使用mock方法将新数据连续的转码成其他格式上传,可以参考文档里面的:Demo片段列表 -> 实时转码并上传-通用版;基于本功能可以做到:实时转发数据、实时保存数据、实时语音识别(ASR)等
|
|
237
245
|
|
|
238
246
|
//可实时绘制波形(extensions目录内的waveview.js、wavesurfer.view.js、frequency.histogram.view.js插件功能)
|
|
239
|
-
if(workStatus === '正在聆听'){
|
|
240
|
-
|
|
241
|
-
}
|
|
247
|
+
// if(workStatus === '正在聆听'){
|
|
248
|
+
// wave && wave.input(buffers[buffers.length - 1], powerLevel, bufferSampleRate);
|
|
249
|
+
// }
|
|
242
250
|
}
|
|
243
251
|
});
|
|
244
252
|
recorderRef.current = recorder;
|
|
245
253
|
recorder.open(() => {
|
|
246
|
-
if(Recorder.WaveView){
|
|
247
|
-
|
|
248
|
-
}
|
|
254
|
+
// if(Recorder.WaveView){
|
|
255
|
+
// wave = Recorder.WaveView({elem: ".recwave"});
|
|
256
|
+
// }
|
|
249
257
|
});
|
|
250
258
|
recorder.start();
|
|
251
259
|
}
|
|
@@ -299,11 +307,11 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
|
|
|
299
307
|
}
|
|
300
308
|
};
|
|
301
309
|
|
|
302
|
-
wave = null
|
|
310
|
+
// wave = null
|
|
303
311
|
recorderRef.current = null;
|
|
304
312
|
},(msg: any)=> {
|
|
305
313
|
console.log("录音失败:"+msg);
|
|
306
|
-
wave = null
|
|
314
|
+
// wave = null
|
|
307
315
|
recorderRef.current.close();//可以通过stop方法的第3个参数来自动调用close
|
|
308
316
|
recorderRef.current=null;
|
|
309
317
|
});
|
|
@@ -507,11 +515,14 @@ const CallInterface: React.FC<CallInterfaceProps> = ({
|
|
|
507
515
|
{
|
|
508
516
|
callStatus === 'connected' &&
|
|
509
517
|
<div style={{display: 'flex', flexDirection:'column', justifyContent: 'center', alignItems: 'center'}}>
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
518
|
+
{/*<div style={{width: 120, height: 50, position: 'relative'}}>*/}
|
|
519
|
+
{/* {*/}
|
|
520
|
+
{/* <div className='recwave' style={{width: 120, height: 50, display: workStatus === '正在聆听' ? 'block' : 'none'}}></div>*/}
|
|
521
|
+
{/* }*/}
|
|
522
|
+
{/*</div>*/}
|
|
523
|
+
<div className='recwave' style={{width: 120, height: 50}}>{
|
|
524
|
+
workStatus === '正在聆听'|| workStatus === '正在回复' ? <img src={ai_call_working}/>:<img src={ai_call_thinking}/>
|
|
525
|
+
}</div>
|
|
515
526
|
<p className="call-status">
|
|
516
527
|
{workStatus}
|
|
517
528
|
</p>
|
|
@@ -452,6 +452,7 @@ export default function ChatWindow({
|
|
|
452
452
|
});
|
|
453
453
|
setDropDownList(undefined);
|
|
454
454
|
}
|
|
455
|
+
inputRef.current.value=''
|
|
455
456
|
}
|
|
456
457
|
|
|
457
458
|
// 处理打电话按钮点击
|
|
@@ -1011,7 +1012,7 @@ export default function ChatWindow({
|
|
|
1011
1012
|
<div className="w_inputBox" style={{height: inputContainerHeight}}>
|
|
1012
1013
|
<textarea
|
|
1013
1014
|
onFocus={()=>setInputContainerHeight('120px')}
|
|
1014
|
-
onBlur={()=>setInputContainerHeight('50px')}
|
|
1015
|
+
onBlur={() => setTimeout(() => setInputContainerHeight('50px'), 200)}
|
|
1015
1016
|
// value={inputValue}
|
|
1016
1017
|
onChange={(e) => setValue(e.target.value)}
|
|
1017
1018
|
onKeyDown={(e) => {
|
|
@@ -1072,6 +1073,7 @@ export default function ChatWindow({
|
|
|
1072
1073
|
style={{ ...(sendingMessage ? { cursor: 'pointer' } : {}), padding: '0 13px', background:'transparent', display:'flex', alignItems:'center', justifyContent:'center' }}
|
|
1073
1074
|
onClick={() => {
|
|
1074
1075
|
if(sendingMessage){
|
|
1076
|
+
// 如果正在发送消息,此时点击则为取消发送
|
|
1075
1077
|
const output = {
|
|
1076
1078
|
message:nowAIContent,
|
|
1077
1079
|
type:'text'
|
|
@@ -1114,6 +1116,7 @@ export default function ChatWindow({
|
|
|
1114
1116
|
sessionId={sessionId}
|
|
1115
1117
|
hostUrl={hostUrl}
|
|
1116
1118
|
onMessage={addMessage}
|
|
1119
|
+
userInfo={userInfo}
|
|
1117
1120
|
/>
|
|
1118
1121
|
:
|
|
1119
1122
|
<div className="cl-middle-container">
|
|
@@ -350,7 +350,7 @@ export class ToolDialog extends React.Component {
|
|
|
350
350
|
|
|
351
351
|
// 获取历史对话列表
|
|
352
352
|
getHistoryList = (sceneData, isRefreshWords) => {
|
|
353
|
-
const { sceneId, appId: flowId, isShowSideLeft } = this.props;
|
|
353
|
+
const { sceneId, appId: flowId, isShowSideLeft = true } = this.props;
|
|
354
354
|
if(isEmpty(sceneId)){
|
|
355
355
|
// 单独组件情况
|
|
356
356
|
if(isRefreshWords){
|
|
Binary file
|
|
Binary file
|