feat(logs): 实时日志展开显示单笔 token 用量与缓存命中率
- calllog 新增 peek_tokens(rid):只读不消耗,供实时日志展示(落库仍由 _row pop) - AccessLog.add 把 token 挂到条目 tokens 字段 - 实时日志展开新增「Token 用量」块:输入/输出/缓存命中/推理 + 命中率(cached÷prompt) - 调用日志详情弹窗补同样一行 token(数据取自 tok_* 列) - 版本 2.9.3 → 2.9.4
This commit is contained in:
1 parent
b54dc303f9
commit
6457a92314
8 files changed
+90
-1
No files matched your search
@@ -273,6 +273,15 @@ class AccessLog:
|
||||
snip = BODY_BY_RID.pop(rid, None)
|
||||
if snip:
|
||||
entry["body"] = snip
|
||||
# 2026-10-23:把这次请求的 token 用量挂到日志条目上(实时页展开即可看到
|
||||
# prompt/completion/cached/reasoning 与缓存命中率)。
|
||||
try:
|
||||
from app import calllog as _calllog
|
||||
_tk = _calllog.peek_tokens(str(rid))
|
||||
if _tk:
|
||||
entry["tokens"] = dict(_tk)
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
with self._lock:
|
||||
self._buf.append(entry)
|
||||
# 调用日志落地(2026-10-23):交给 app/calllog.py —— 它与请求中间件的响应元数据
|
||||
|
||||
Reference in new issue
Block a user