mirror of
https://github.com/langgenius/webapp-conversation.git
synced 2025-12-08 17:32:27 +08:00
fix: log message json pares error
This commit is contained in:
@ -64,7 +64,16 @@ const handleStream = (response: any, onData: IOnData, onCompleted?: IOnCompleted
|
|||||||
lines.forEach((message) => {
|
lines.forEach((message) => {
|
||||||
if (!message || !message.startsWith('data: '))
|
if (!message || !message.startsWith('data: '))
|
||||||
return
|
return
|
||||||
|
try {
|
||||||
bufferObj = JSON.parse(message.substring(6)) // remove data: and parse as json
|
bufferObj = JSON.parse(message.substring(6)) // remove data: and parse as json
|
||||||
|
} catch (e) {
|
||||||
|
// mute handle message cut off
|
||||||
|
onData('', isFirstMessage, {
|
||||||
|
conversationId: bufferObj?.conversation_id,
|
||||||
|
messageId: bufferObj?.id,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
if (bufferObj.event !== 'message')
|
if (bufferObj.event !== 'message')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user