fix(calllog): 翻译键移回顶层 + 内容上限 2000→8000
- calllogs.* 的 i18n 段此前被插进 upload 段内部,导致新面板全部显示原始键名; 已移到 logs 之后作为顶层键,zh/en 结构复核一致 - 请求体摘要 raw[:2000]→8000、回复文本 _logsafe(...,2000)→8000(5 处), 实测 6000 字提示词可完整落库
This commit is contained in:
1 parent
09b79c1306
commit
bb4c9281f7
4 files changed
+71
-66
No files matched your search
@@ -38,6 +38,13 @@
|
||||
- 新组件 `CallLogs.vue`:日期范围、账号、模型、仅成功/仅失败、关键词(内容/rid/IP/UA)筛选;
|
||||
列表显示时间/账号/模型/耗时/状态/流式/UA;点击行弹出详情看**完整提示词与回复**;CSV 导出。
|
||||
|
||||
### 2026-10-23 补丁:翻译键位置 + 内容上限
|
||||
- **修**:`calllogs.*` 的 i18n 段首次插入时被放进了 `upload` 段内部(嵌套层级错),
|
||||
导致新面板全部显示原始键名(`calllogs.title` 之类)。已移为**顶层键**(`logs` 之后),
|
||||
并复核 zh/en 两份文件的顶层键数量与层级一致。
|
||||
- **提上限**:请求体摘要 `raw[:2000]` → `8000`,回复文本 `_logsafe(..., 2000)` → `8000`(5 处)。
|
||||
实测 6000 字的提示词已能完整落库(此前会被截在 2000)。
|
||||
|
||||
### 现状说明
|
||||
- `/metrics` 仍是内存态(重启清零),本次没动它;**调用日志是持久化的**,
|
||||
需要历史统计时可以基于 `api_calls` 做(二期可把 Dashboard 数据源切过来)。
|
||||
|
||||
+6
-6
@@ -498,7 +498,7 @@ async def in_flight_tracker(request: Request, call_next):
|
||||
if rid:
|
||||
try:
|
||||
raw = await request.body()
|
||||
BODY_BY_RID[rid] = raw[:2000].decode("utf-8", "replace")
|
||||
BODY_BY_RID[rid] = raw[:8000].decode("utf-8", "replace")
|
||||
if len(BODY_BY_RID) > 2 * _BODY_MAX:
|
||||
BODY_BY_RID.clear()
|
||||
except Exception:
|
||||
@@ -1639,7 +1639,7 @@ async def _passthrough(request: Request, protocol: str):
|
||||
"model": model_in, "served": model_in, "provider": pkey,
|
||||
"caller": caller, "ok": ok, "stream": False,
|
||||
"response": _logsafe(_resp_text(data) if ok else _upstream_detail(
|
||||
json.dumps(data, ensure_ascii=False) if isinstance(data, dict) else str(data)), 2000)})
|
||||
json.dumps(data, ensure_ascii=False) if isinstance(data, dict) else str(data)), 8000)})
|
||||
|
||||
if not ok:
|
||||
# 直传口径:上游的错误体**原样**回给客户端(错误文案也不翻译),只加一个
|
||||
@@ -1684,7 +1684,7 @@ async def _passthrough_stream(request, rid, caller, protocol, adapter, cb,
|
||||
_access.add({"method": "POST", "kind": "chat", "path": f"/v1/{protocol}", "rid": rid,
|
||||
"model": model_in, "served": model_in, "provider": pkey, "caller": caller,
|
||||
"ok": False, "stream": True,
|
||||
"response": _logsafe(_upstream_detail(raw.decode("utf-8", "replace")), 2000)})
|
||||
"response": _logsafe(_upstream_detail(raw.decode("utf-8", "replace")), 8000)})
|
||||
return Response(content=raw, status_code=resp.status_code, media_type=ctype, headers=headers)
|
||||
|
||||
scanner = _UsageScanner(protocol)
|
||||
@@ -2039,7 +2039,7 @@ async def _chat_once(cfg, rid, caller, request, req, model_id, messages, tools):
|
||||
_access.add({"method": "POST", "kind": "chat", "path": "/v1/chat/completions", "rid": rid,
|
||||
"model": req.model, "served": model_id, "provider": pkey,
|
||||
"caller": caller, "ok": True, "stream": False,
|
||||
"response": _logsafe(_resp_text(result), 2000)})
|
||||
"response": _logsafe(_resp_text(result), 8000)})
|
||||
resp = {
|
||||
"id": result.get("id", "") or f"chatcmpl-{rid}", "object": "chat.completion",
|
||||
"created": int(time.time()), "model": req.model,
|
||||
@@ -2167,7 +2167,7 @@ def _stream_response(request, req, model_id, messages, tools):
|
||||
_access.add({"method": "POST", "kind": "chat", "path": "/v1/chat/completions", "rid": rid,
|
||||
"model": req.model, "served": model_id, "provider": pkey,
|
||||
"caller": caller, "ok": True, "stream": True,
|
||||
"response": _logsafe(_stream_log_text(resp_parts, reason_parts), 2000)})
|
||||
"response": _logsafe(_stream_log_text(resp_parts, reason_parts), 8000)})
|
||||
# 功能 8: 流式末尾发一个 usage 块(累计自上游 chunks 的 usage,若有)
|
||||
if stream_usage:
|
||||
uf = {'id': f'chatcmpl-{rid}', 'object': 'chat.completion.chunk', 'created': int(time.time()),
|
||||
@@ -2185,7 +2185,7 @@ def _stream_response(request, req, model_id, messages, tools):
|
||||
_access.add({"method": "POST", "kind": "chat", "path": "/v1/chat/completions", "rid": rid,
|
||||
"model": req.model, "served": model_id, "provider": pkey,
|
||||
"caller": caller, "ok": False, "stream": True, "error": str(e)[:200],
|
||||
"response": _logsafe(_stream_log_text(resp_parts, reason_parts), 2000)})
|
||||
"response": _logsafe(_stream_log_text(resp_parts, reason_parts), 8000)})
|
||||
# 第六轮: 已向客户端输出过 content 时本来就无法回退(第二十七轮起更没有下一个
|
||||
# 模型可退),统一发错误帧 + [DONE] 收尾,避免破坏已输出的 SSE 流。
|
||||
yield f"data: {json.dumps({'error': str(e), 'served_model': model_id}, ensure_ascii=False)}\n\n"
|
||||
|
||||
+29
-30
@@ -203,6 +203,34 @@ export default {
|
||||
streaming: 'Streaming',
|
||||
loadErr: 'Failed to load logs',
|
||||
},
|
||||
calllogs: {
|
||||
title: 'Call log (persisted)',
|
||||
count: '{n} rows',
|
||||
failN: '{n} failed',
|
||||
avgMs: 'avg {n}ms',
|
||||
startDate: 'Start',
|
||||
endDate: 'End',
|
||||
account: 'Account',
|
||||
model: 'Model',
|
||||
result: 'Result',
|
||||
onlyOk: 'OK only',
|
||||
onlyFail: 'Failed only',
|
||||
keyword: 'Keyword (content/rid/IP/UA)',
|
||||
colTime: 'Time',
|
||||
colAccount: 'Account',
|
||||
colModel: 'Model',
|
||||
colLatency: 'Latency',
|
||||
colStatus: 'Status',
|
||||
colStream: 'Stream',
|
||||
colUa: 'UA',
|
||||
yes: 'yes',
|
||||
no: 'no',
|
||||
detailTitle: 'Call detail',
|
||||
prompt: 'Prompt (request body, truncated)',
|
||||
completion: 'Completion (truncated)',
|
||||
loading: 'Loading…',
|
||||
},
|
||||
|
||||
users: {
|
||||
viewLogs: 'View logs',
|
||||
viewActivity: 'Activity',
|
||||
@@ -819,34 +847,5 @@ export default {
|
||||
errNotAudio: '{name} is not an audio file (supported: {ext})',
|
||||
errAudioTooBig: '{name} is {size}, over the reference-audio limit of {max} (please trim or compress it)',
|
||||
errBodyBudget: 'This request body is about {size}, over the gateway upload limit (~{max}).',
|
||||
errBodyBudgetTip: 'Please use fewer materials, or smaller images/audio files.',
|
||||
calllogs: {
|
||||
title: 'Call log (persisted)',
|
||||
count: '{n} rows',
|
||||
failN: '{n} failed',
|
||||
avgMs: 'avg {n}ms',
|
||||
startDate: 'Start',
|
||||
endDate: 'End',
|
||||
account: 'Account',
|
||||
model: 'Model',
|
||||
result: 'Result',
|
||||
onlyOk: 'OK only',
|
||||
onlyFail: 'Failed only',
|
||||
keyword: 'Keyword (content/rid/IP/UA)',
|
||||
colTime: 'Time',
|
||||
colAccount: 'Account',
|
||||
colModel: 'Model',
|
||||
colLatency: 'Latency',
|
||||
colStatus: 'Status',
|
||||
colStream: 'Stream',
|
||||
colUa: 'UA',
|
||||
yes: 'yes',
|
||||
no: 'no',
|
||||
detailTitle: 'Call detail',
|
||||
prompt: 'Prompt (request body, truncated)',
|
||||
completion: 'Completion (truncated)',
|
||||
loading: 'Loading…',
|
||||
},
|
||||
|
||||
},
|
||||
errBodyBudgetTip: 'Please use fewer materials, or smaller images/audio files.', },
|
||||
}
|
||||
+29
-30
@@ -203,6 +203,34 @@ export default {
|
||||
streaming: '流式',
|
||||
loadErr: '加载日志失败',
|
||||
},
|
||||
calllogs: {
|
||||
title: '调用日志(持久化)',
|
||||
count: '共 {n} 条',
|
||||
failN: '失败 {n}',
|
||||
avgMs: '平均 {n}ms',
|
||||
startDate: '开始日期',
|
||||
endDate: '结束日期',
|
||||
account: '账号',
|
||||
model: '模型',
|
||||
result: '结果',
|
||||
onlyOk: '仅成功',
|
||||
onlyFail: '仅失败',
|
||||
keyword: '关键词(内容/rid/IP/UA)',
|
||||
colTime: '时间',
|
||||
colAccount: '账号',
|
||||
colModel: '模型',
|
||||
colLatency: '耗时',
|
||||
colStatus: '状态',
|
||||
colStream: '流式',
|
||||
colUa: 'UA',
|
||||
yes: '是',
|
||||
no: '否',
|
||||
detailTitle: '调用详情',
|
||||
prompt: '提示词(请求体,截断记录)',
|
||||
completion: '回复(截断记录)',
|
||||
loading: '加载中…',
|
||||
},
|
||||
|
||||
users: {
|
||||
viewLogs: '查看日志',
|
||||
viewActivity: '查看活动',
|
||||
@@ -818,34 +846,5 @@ export default {
|
||||
errNotAudio: '{name} 不是音频文件(支持 {ext})',
|
||||
errAudioTooBig: '{name} 有 {size},超过参考音频上限 {max}(请裁剪或压缩后再传)',
|
||||
errBodyBudget: '本次请求体约 {size},超过网关上送上限(约 {max})。',
|
||||
errBodyBudgetTip: '请减少素材数量,或换体积更小的图片/音频。',
|
||||
calllogs: {
|
||||
title: '调用日志(持久化)',
|
||||
count: '共 {n} 条',
|
||||
failN: '失败 {n}',
|
||||
avgMs: '平均 {n}ms',
|
||||
startDate: '开始日期',
|
||||
endDate: '结束日期',
|
||||
account: '账号',
|
||||
model: '模型',
|
||||
result: '结果',
|
||||
onlyOk: '仅成功',
|
||||
onlyFail: '仅失败',
|
||||
keyword: '关键词(内容/rid/IP/UA)',
|
||||
colTime: '时间',
|
||||
colAccount: '账号',
|
||||
colModel: '模型',
|
||||
colLatency: '耗时',
|
||||
colStatus: '状态',
|
||||
colStream: '流式',
|
||||
colUa: 'UA',
|
||||
yes: '是',
|
||||
no: '否',
|
||||
detailTitle: '调用详情',
|
||||
prompt: '提示词(请求体,截断记录)',
|
||||
completion: '回复(截断记录)',
|
||||
loading: '加载中…',
|
||||
},
|
||||
|
||||
},
|
||||
errBodyBudgetTip: '请减少素材数量,或换体积更小的图片/音频。', },
|
||||
}
|
||||
Reference in new issue
Block a user