We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 13aa8a8 + ff28eca commit 5004f3aCopy full SHA for 5004f3a
1 file changed
astrbot/core/provider/sources/openai_source.py
@@ -672,7 +672,9 @@ async def _query_stream(
672
# 跳过 delta=None 的 chunk,避免 SDK 内部 _convert_initial_chunk_into_snapshot
673
# 第 747 行 choice.delta.to_dict() 抛出 NoneType 错误。
674
# refs: AstrBot#6689 / openai-python#5069 / #5047
675
- if delta is not None:
+ # 例外:流末尾的 usage chunk(choices=[],delta=None 但有 usage 数据)
676
+ # 需要传给 state,否则最终 completion 会丢失 usage 信息
677
+ if delta is not None or chunk.usage:
678
try:
679
state.handle_chunk(chunk)
680
except Exception as e:
0 commit comments