[mirotalksfu] - add chatGPT-OpenAI

هذا الالتزام موجود في:
Miroslav Pejic
2023-04-14 19:54:56 +02:00
الأصل 618e7b03cb
التزام f8d4f001fb
8 ملفات معدلة مع 117 إضافات و10 حذوفات

عرض الملف

@@ -93,6 +93,7 @@ let isParticipantsListOpen = false;
let isVideoControlsOn = false;
let isChatPasteTxt = false;
let isChatMarkdownOn = false;
let isChatGPTOn = false;
let joinRoomWithoutAudioVideo = true;
let joinRoomWithScreen = false;
let initAudioButton = null;
@@ -181,6 +182,7 @@ function initClient() {
setTippy('chatSpeechStopButton', 'Stop speech recognition', 'top');
setTippy('chatEmojiButton', 'Emoji', 'top');
setTippy('chatMarkdownButton', 'Markdown', 'top');
setTippy('chatGPTButton', 'ChatGPT', 'top');
setTippy('chatShareFileButton', 'Share file', 'top');
setTippy('chatCleanButton', 'Clean', 'bottom');
setTippy('chatSaveButton', 'Save', 'bottom');
@@ -743,6 +745,7 @@ function roomIsReady() {
!BUTTONS.chat.chatSaveButton && hide(chatSaveButton);
BUTTONS.chat.chatEmojiButton && show(chatEmojiButton);
BUTTONS.chat.chatMarkdownButton && show(chatMarkdownButton);
BUTTONS.chat.chatGPTButton && show(chatGPTButton);
BUTTONS.chat.chatShareFileButton && show(chatShareFileButton);
if (isWebkitSpeechRecognitionSupported && BUTTONS.chat.chatSpeechStartButton) {
show(chatSpeechStartButton);
@@ -953,6 +956,10 @@ function handleButtons() {
isChatMarkdownOn = !isChatMarkdownOn;
setColor(chatMarkdownButton, isChatMarkdownOn ? 'lime' : 'white');
};
chatGPTButton.onclick = () => {
isChatGPTOn = !isChatGPTOn;
setColor(chatGPTButton, isChatGPTOn ? 'lime' : 'white');
};
chatShareFileButton.onclick = () => {
fileShareButton.click();
};

عرض الملف

@@ -2701,7 +2701,7 @@ class RoomClient {
}
sendMessage() {
if (!this.thereIsParticipants()) {
if (!this.thereIsParticipants() && !isChatGPTOn) {
this.cleanMessage();
isChatPasteTxt = false;
return this.userLog('info', 'No participants in the room', 'top-end');
@@ -2711,14 +2711,39 @@ class RoomClient {
return this.cleanMessage();
}
this.peer_name = filterXSS(this.peer_name);
let data = {
peer_name: this.peer_name,
peer_id: this.peer_id,
to_peer_id: 'all',
peer_msg: peer_msg,
};
console.log('Send message:', data);
this.socket.emit('message', data);
if (isChatGPTOn) {
this.socket
.request('getChatGPT', { prompt: peer_msg })
.then(
function (completion) {
console.log('Receive message:', completion);
this.setMsgAvatar('left', 'ChatGPT');
this.appendMessage(
'left',
this.leftMsgAvatar,
'ChatGPT',
this.peer_id,
completion,
this.peer_id,
this.peer_name,
);
this.cleanMessage();
this.sound('message');
}.bind(this),
)
.catch((err) => {
console.log('ChatGPT error:', err);
});
} else {
let data = {
peer_name: this.peer_name,
peer_id: this.peer_id,
to_peer_id: 'all',
peer_msg: peer_msg,
};
console.log('Send message:', data);
this.socket.emit('message', data);
}
this.setMsgAvatar('right', this.peer_name);
this.appendMessage('right', this.rightMsgAvatar, this.peer_name, this.peer_id, peer_msg, 'all', 'all');
this.cleanMessage();

عرض الملف

@@ -58,6 +58,7 @@ const BUTTONS = {
chatSaveButton: true,
chatEmojiButton: true,
chatMarkdownButton: true,
chatGPTButton: true,
chatShareFileButton: true,
chatSpeechStartButton: true,
},

عرض الملف

@@ -23,6 +23,8 @@ const commands = {
chatOn: 'open the chat',
chatSend: 'send',
chatOff: 'close the chat',
chatGPTOn: 'open chatGPT',
chatGPTOff: 'close chatGPT',
whiteboardOn: 'open the whiteboard',
whiteboardOff: 'close the whiteboard',
recordingOn: 'start the recording',
@@ -189,6 +191,14 @@ function execVoiceCommands(transcript) {
printCommand(commands.whiteboardOn);
whiteboardButton.click();
break;
case commands.chatGPTOn:
printCommand(commands.chatGPTOn);
chatGPTButton.click();
break;
case commands.chatGPTOff:
printCommand(commands.chatGPTOff);
chatGPTButton.click();
break;
case commands.whiteboardOff:
printCommand(commands.whiteboardOff);
whiteboardCloseBtn.click();

عرض الملف

@@ -26,7 +26,7 @@
/>
<meta
name="keywords"
content="webrtc, miro, mediasoup, mediasoup-client, self hosted, voip, sip, real-time communications, chat, messaging, meet, webrtc stun, webrtc turn, webrtc p2p, webrtc sfu, video meeting, video chat, video conference, multi video chat, multi video conference, peer to peer, p2p, sfu, rtc, alternative to, zoom, microsoft teams, google meet, jitsi, meeting"
content="webrtc, chatGPT, miro, mediasoup, mediasoup-client, self hosted, voip, sip, real-time communications, chat, messaging, meet, webrtc stun, webrtc turn, webrtc p2p, webrtc sfu, video meeting, video chat, video conference, multi video chat, multi video conference, peer to peer, p2p, sfu, rtc, alternative to, zoom, microsoft teams, google meet, jitsi, meeting"
/>
<!-- https://ogp.me -->
@@ -477,6 +477,9 @@ access to use this app.
<button id="chatMarkdownButton" class="hidden">
<i class="fab fa-markdown"></i>
</button>
<button id="chatGPTButton" class="hidden">
<i class="fas fa-robot"></i>
</button>
<button id="chatShareFileButton" class="hidden">
<i class="fas fa-paperclip"></i>
</button>