Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion astrbot/core/utils/dify_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
async def _stream_sse(resp: ClientResponse) -> AsyncGenerator[dict, None]:
decoder = codecs.getincrementaldecoder("utf-8")()
buffer = ""
async for chunk in resp.content.iter_chunked(8192):
# Use iter_any() instead of iter_chunked() to avoid TransferEncodingError
# when handling large responses with chunked transfer encoding
# See: https://github.com/aio-libs/aiohttp/issues/4630
Comment thread
LIghtJUNction marked this conversation as resolved.
Outdated
async for chunk in resp.content.iter_any():
buffer += decoder.decode(chunk)
while "\n\n" in buffer:
block, buffer = buffer.split("\n\n", 1)
Expand Down