mirror of https://github.com/Mai-with-u/MaiBot.git
增强检测
parent
2009ee3b5e
commit
8cad5bb45d
|
|
@ -244,9 +244,12 @@ 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())
|
||||||
if has_visible_output:
|
if has_visible_output:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue