fix(api): 同步 chat_handler_base 使用 aiter_bytes 支持自动解压

This commit is contained in:
fawney19
2025-12-24 01:13:35 +08:00
parent e38cd6819b
commit 03eb7203ec

View File

@@ -484,9 +484,8 @@ class ChatHandlerBase(BaseMessageHandler, ABC):
stream_response.raise_for_status() stream_response.raise_for_status()
# 使用字节流迭代器(避免 aiter_lines 的性能问题) # 使用字节流迭代器(避免 aiter_lines 的性能问题, aiter_bytes 会自动解压 gzip/deflate
# aiter_raw() 返回原始数据块,无缓冲,实现真正的流式传输 byte_iterator = stream_response.aiter_bytes()
byte_iterator = stream_response.aiter_raw()
# 预读检测嵌套错误 # 预读检测嵌套错误
prefetched_chunks = await stream_processor.prefetch_and_check_error( prefetched_chunks = await stream_processor.prefetch_and_check_error(