You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To fix the bug in the _process_chunk method that causes the first chunk to be duplicated, you need to ensure that the complete_message is only updated with the chunk content after the initial message has been sent. The duplication occurs because the complete_message is updated with the chunk content before the initial message is sent in the first chunk. Here's the corrected code:
asyncdef_process_chunk(
self, chunk: str, complete_message: str, message_id: str, message: Message, *, first_chunk: bool=False
) ->str:
ifself._event_manager:
iffirst_chunk:
# Send the initial message only on the first chunkmsg_copy=message.model_copy()
msg_copy.text=complete_message+chunkawaitself._send_message_event(msg_copy, id_=message_id)
awaitasyncio.to_thread(
self._event_manager.on_token,
data={
"chunk": chunk,
"id": str(message_id),
},
)
complete_message+=chunkreturncomplete_message
In this corrected version, the complete_message is updated with the chunk after the initial message is sent, preventing the duplication of the first chunk [1].
Bug Description
The first chunk content is
今天
,will send two eventsadd_message
andtoken
with same content今天
.Reproduction
This bug can be reproduced when the llm response first message chunk content is not empty
Expected behavior
Expected output:
今天是2024年12月19日,星期四,农历是二零二四年十一月十九。
Who can help?
@anovazzi1
Operating System
mac
Langflow Version
v1.1.1
Python Version
3.12
Screenshot
No response
Flow File
No response
The text was updated successfully, but these errors were encountered: