增强检测

pull/1269/head
foxplaying 2025-09-28 13:37:06 +08:00 committed by GitHub
parent 2009ee3b5e
commit 8cad5bb45d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -244,8 +244,11 @@ def _build_stream_api_resp(
# 检查是否因为 max_tokens 截断 # 检查是否因为 max_tokens 截断
reason = None reason = None
if last_resp and getattr(last_resp, "candidates", None): if last_resp and getattr(last_resp, "candidates", None):
c0 = last_resp.candidates[0] for c in last_resp.candidates:
reason = getattr(c0, "finish_reason", None) or getattr(c0, "finishReason", None) fr = getattr(c, "finish_reason", None) or getattr(c, "finishReason", None)
if fr:
reason = str(fr)
break
if str(reason).endswith("MAX_TOKENS"): if str(reason).endswith("MAX_TOKENS"):
has_visible_output = bool(resp.content and resp.content.strip()) has_visible_output = bool(resp.content and resp.content.strip())