forked from tuvn86/webapp-conversation
feat: api add eventtype pong message to avoid api return too slow and frontend ignore it
This commit is contained in:
parent
d32faf12f2
commit
3d0958584c
1 changed files with 4 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue