This commit is contained in:
hailin 2025-08-01 09:52:03 +08:00
parent 99a6957d04
commit d4823afc81
1 changed files with 4 additions and 0 deletions

View File

@ -86,6 +86,10 @@ def backend(text, sampling, api_suffix):
msg = choice.get("message", {}) msg = choice.get("message", {})
txt = msg.get("content", "").strip() txt = msg.get("content", "").strip()
# 新增:从 usage 获取 completion_tokens
ctok = data.get("usage", {}).get("completion_tokens")
fr = choice.get("finish_reason") # 如果后续需要 finish reason
log(f"🟢 [{now()}] HTTP {r.status_code} tokens={ctok} finish={fr}\n" log(f"🟢 [{now()}] HTTP {r.status_code} tokens={ctok} finish={fr}\n"
f"🟢 resp800={r.text[:800]!r}") f"🟢 resp800={r.text[:800]!r}")
if r.status_code != 200: if r.status_code != 200: