Skip to content

Commit 5004f3a

Browse files
authored
Merge branch 'AstrBotDevs:master' into cmd_suggestion
2 parents 13aa8a8 + ff28eca commit 5004f3a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

astrbot/core/provider/sources/openai_source.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,9 @@ async def _query_stream(
672672
# 跳过 delta=None 的 chunk,避免 SDK 内部 _convert_initial_chunk_into_snapshot
673673
# 第 747 行 choice.delta.to_dict() 抛出 NoneType 错误。
674674
# refs: AstrBot#6689 / openai-python#5069 / #5047
675-
if delta is not None:
675+
# 例外:流末尾的 usage chunk(choices=[],delta=None 但有 usage 数据)
676+
# 需要传给 state,否则最终 completion 会丢失 usage 信息
677+
if delta is not None or chunk.usage:
676678
try:
677679
state.handle_chunk(chunk)
678680
except Exception as e:

0 commit comments

Comments
 (0)