Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JYC0413 committed Jan 16, 2024
1 parent b201b78 commit cf6c747
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,20 @@ export const Chat = memo(({stopConversationRef}: Props) => {
let chunkValue = decoder.decode(value);
const regex = /}(?={)/g;
const parts = chunkValue.split(regex);
const objects = parts.map(part => {
let objects: any[] = []
parts.forEach(part => {
part = part.trim();
if (!part.startsWith('{')) {
part = '{' + part;
}
if (!part.endsWith('}')) {
part = part + '}';
}
return JSON.parse(part);
try {
objects.push(JSON.parse(part));
}catch (e) {
console.log("error JSON",part);
}
});

objects.forEach(obj => {
Expand Down

0 comments on commit cf6c747

Please sign in to comment.