Skip to content

Commit

Permalink
fix(browser-client): ignore any messages not from assistant role
Browse files Browse the repository at this point in the history
  • Loading branch information
waylaidwanderer committed Feb 27, 2023
1 parent bb32168 commit aafdb30
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ChatGPTBrowserClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ export default class ChatGPTBrowserClient {
return;
}
try {
const lastMessage = lastEvent ? lastEvent.message.content.parts[0] : '';
const data = JSON.parse(message.data);
// ignore any messages that are not from the assistant
if (data.message?.author?.role !== 'assistant') {
return;
}
const lastMessage = lastEvent ? lastEvent.message.content.parts[0] : '';
const newMessage = data.message.content.parts[0];
// get the difference between the current text and the previous text
const difference = newMessage.substring(lastMessage.length);
Expand Down

0 comments on commit aafdb30

Please sign in to comment.