Skip to content

Commit c1356bb

Browse files
fix(dify): handle CRLF event separators in streaming responses (#10392)
* fix(dify): handle CRLF event separators in streaming responses * Delete tests/test_dify_api_client.py --------- Co-authored-by: Soulter <[email protected]>
1 parent 1c655b3 commit c1356bb

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎astrbot/core/agent/runners/dify/dify_api_client.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ async def _stream_sse(resp: ClientResponse) -> AsyncGenerator[dict, None]:
1313
buffer = ""
1414
async for chunk in resp.content.iter_chunked(8192):
1515
buffer += decoder.decode(chunk)
16+
# Normalize after buffering so CRLF split across chunks is recognized.
17+
buffer = buffer.replace("\r\n", "\n")
1618
while "\n\n" in buffer:
1719
block, buffer = buffer.split("\n\n", 1)
1820
if block.strip().startswith("data:"):

0 commit comments

Comments
 (0)