mirror of
https://github.com/langgenius/webapp-conversation.git
synced 2025-12-24 00:26:39 +08:00
feat: api add eventtype pong message to avoid api return too slow and frontend ignore it
This commit is contained in:
@ -62,9 +62,12 @@ const handleStream = (response: any, onData: IOnData, onCompleted?: IOnCompleted
|
||||
const lines = buffer.split('\n')
|
||||
try {
|
||||
lines.forEach((message) => {
|
||||
if (!message)
|
||||
if (!message || !message.startsWith('data: '))
|
||||
return
|
||||
bufferObj = JSON.parse(message.substring(6)) // remove data: and parse as json
|
||||
if (bufferObj.event !== 'message')
|
||||
return
|
||||
|
||||
onData(unicodeToChar(bufferObj.answer), isFirstMessage, {
|
||||
conversationId: bufferObj.conversation_id,
|
||||
messageId: bufferObj.id,
|
||||
|
||||
Reference in New Issue
Block a user