修复火山部分流式输出没有finish_reason导致的报错

pull/245/head
Pliosauroidea 2025-03-12 07:58:27 +08:00
parent 90d169f740
commit 126c9af70e
1 changed files with 1 additions and 1 deletions

View File

@ -235,7 +235,7 @@ class LLM_request:
delta_content = "" delta_content = ""
accumulated_content += delta_content accumulated_content += delta_content
# 检测流式输出文本是否结束 # 检测流式输出文本是否结束
finish_reason = chunk["choices"][0]["finish_reason"] finish_reason = chunk["choices"][0].get("finish_reason")
if finish_reason == "stop": if finish_reason == "stop":
usage = chunk.get("usage", None) usage = chunk.get("usage", None)
if usage: if usage: