- [Gemini Native Stream Interruption Root-Cause Transparency & Premature EOF Diagnostics] (Fixes #3813):
- Official Standard finishMessage Diagnostic Forwarding: Resolved the issue where native Gemini streams encountering connection drops (e.g.
error reading a body from connectionor idle timeouts) after partial output emitted a synthesized recovery chunk with only a hardcodedMAX_TOKENS, masking the true network failure and misleading downstream clients into diagnosing an output token limit exceeded; integrated the error report into candidate frames using Google's official standardfinishMessagealongside structuredgatewayErrorandgatewayInterrupted: trueflags, preserving all generated content cleanly under the zero content tampering contract while exposing exact interruption details. (Fixes #3813) - Incomplete Premature EOF Fallback: Fixed an issue where streams emitting content but closed prematurely by upstream without an official
finishReason: "STOP"resulted in a silent EOF without completion metadata; added an incomplete stream guard in the finalize hook to automatically emit a diagnostic chunk explaining the premature EOF, while preserving silent EOF when valid completion markers are present to protect trailing usage metadata chunks. (Fixes #3813)
- Official Standard finishMessage Diagnostic Forwarding: Resolved the issue where native Gemini streams encountering connection drops (e.g.
- [Token Stats Dual-Perspective Redesign, Multi-Dashboard TTFT Integration, and Minimalist Control Bar Upgrade] (Fixes #3810):
- Dual-Perspective Model Breakdown: Resolved the issue where token statistics recorded only the client's original requested model, masking heavy consumption by routed premium models (e.g., Fable 5, Opus); introduced
effective_model()onProxyRequestLogto split token tracking into "Routed Model" (actual quota/cost consumption) and "Requested Model" (original client call) perspectives; User Token tracking is aligned with the effective model simultaneously. (Fixes #3810) - Multi-Dashboard Time to First Token (TTFT) Integration: Added
ttft_ms REALtotoken_usagetable to accurately capture millisecond-precision response latency for both streaming首包 and non-streaming responses; seamlessly integrated into all dashboards: Cyber Cockpit View displays real-time global TTFT on the efficiency dial and model TTFT tags on model rank cards; Apple Bento View shows average TTFT on cache efficiency cards and top models list; Classic View introduces a dedicated "TTFT" metric card and an "TTFT" column in the detailed model statistics table. - Backward-Compatible DB Schema & Aggregation API: Dynamically added
requested_modelandttft_msfields with dedicated indexes to thetoken_usagetable; extendedget_token_stats_by_modeland model trend endpoints with theview_modeparameter, leveraging dynamicCOALESCE(NULLIF(requested_model, ''), model)aggregation to keep both perspectives clean and fully backward compatible. (Fixes #3810) - Historical Data Inference Migration & Discrepancy Notice: Runs an automatic one-time migration upon startup for historical records lacking
requested_model, backfilling the calculated routed target intomodeland preserving the legacy record asrequested_model. Note: Because raw request logs are periodically rotated, historical records are migrated by inferring routing targets from current default routing rules; past requests that utilized customized overrides or multi-stage fallback rotations may reflect minor attribution discrepancies, whereas newly dispatched requests are tracked with real-time exactness. (Fixes #3810) - Daily Stats Window Alignment & Data Clarity: Fixed an issue where the "Day" filter internally defaulted to a 14-day window, mistakenly blending historical older usage into daily counts; aligned "Day" strictly with the last 24 hours / today, paired with contextual tooltips on all time ranges to prevent period mismatch and data confusion.
- Minimalist Control Bar Redesign & Vertical Space Recovery: Removed the redundant, oversized "Token Usage Statistics" header to eliminate visual duplication with the active global nav tab and reclaim substantial vertical screen real estate; seamlessly embedded minute-level granular switches (
1h / 24h) directly inside the "Minute" pill button; neatly grouped dashboard view toggles, model perspectives, time spans, custom pricing, and refresh actions into a unified single-line control bar without awkward multi-row wrapping. - Full 12-Locale Multi-Language Localization: Completed translations and tooltips across all 12 supported system languages covering routed/requested perspectives, TTFT latency, and time-range descriptors. (Fixes #3810)
- Dual-Perspective Model Breakdown: Resolved the issue where token statistics recorded only the client's original requested model, masking heavy consumption by routed premium models (e.g., Fable 5, Opus); introduced
- [Gemini 原生流中断真实原因透传与异常 EOF 诊断完善] (Fixes #3813):
- 透传官方标准 finishMessage 诊断: 解决此前 Gemini 原生流在输出部分内容后发生连接中断(如
error reading a body from connection或超时)时,合成收尾帧直接写死MAX_TOKENS、掩盖真实错误导致下游客户端与用户误判为达到模型输出上限的问题;在接入错误报告后,在候选帧中注入 Google 官方标准字段finishMessage及结构化gatewayError/gatewayInterrupted: true,在遵守零正文篡改契约、保全截断前生成内容的同时,如实告知中断类型与错误原文。(Fixes #3813) - 未下发 finishReason 异常提前 EOF 兜底: 修复上游产生正文但未经正常
finishReason: "STOP"下发即直接遭遇连接 EOF 导致下游静默断流、缺少完成标记的缺陷;在正常收尾钩子中增加未完成判定并自动补发带有明确提前截断提示的收尾诊断帧,若正常下发过完成标记则严格保持静默 EOF,不破坏尾部用量帧与多 candidate 兼容性。(Fixes #3813)
- 透传官方标准 finishMessage 诊断: 解决此前 Gemini 原生流在输出部分内容后发生连接中断(如
- [Token 统计双视角重构、首字耗时 (TTFT) 全看板集成与控制栏极简体验升级] (Fixes #3810):
- 分模型统计双视角支持: 解决分模型统计仅记录客户端原始模型导致昂贵路由模型(如 Fable 5、Opus 等)消耗被掩盖的问题;在
ProxyRequestLog中引入effective_model(),将 Token 统计划分为「实际路由模型」(真实配额/成本消耗)与「请求模型」(原始客户端调用)两个独立视角,User Token 用量同步对齐实际生效模型。(Fixes #3810) - 多看板首字耗时 (TTFT) 统计集成: 在
token_usage表引入ttft_ms REAL首字延迟字段,在网关响应首包或非流式完成时精准捕获毫秒级延迟;全面集成至所有统计视图:总览看板(Cyber Cockpit) 效能仪表展示实时全局 TTFT、模型榜单标注各模型首字响应速度;深度洞察看板(Apple Bento) 缓存效能卡片与主力模型榜展示平均首字延迟;经典看板独立指标卡片增加「首字延迟」卡片,并在底部分模型详细统计表格中增加「首字耗时」列。 - 数据库与聚合接口向下兼容: 在
token_usage表动态新增requested_model与ttft_ms字段并建立专用索引;为后端get_token_stats_by_model及模型趋势接口扩充view_mode参数,采用COALESCE(NULLIF(requested_model, ''), model)动态聚合,保证两套维度互不干扰且完美兼容既有调用。(Fixes #3810) - 历史数据自动推断迁移与误差注意事项: 应用启动时对旧版本未包含
requested_model的历史记录执行一次性自动迁移;迁移时根据网关当前的统一路由规则将真实路由模型回填到model,将原始记录模型留存至requested_model。注意:由于历史调用日志随时间滚动清理,旧数据的路由目标依据当前默认规则反推迁移,对于曾经自定义修改过映射规则或经历过复杂降级轮询的历史请求,迁移后可能存在微小归属偏差;新产生的请求则全程由网关实时精准记录。(Fixes #3810) - 「日」分类周期校正与数据防混淆: 修复此前「日」分类底层写死按 14 天统计导致历史旧数据被误合并呈现的缺陷,精确校准为按近 24 小时 / 当天进行精准日汇总;为各时间维度补充明确的 Tooltip 浮窗提示,彻底消除不同模块周期脱节与脏数据疑虑。
- 极简控制栏重构与空间释放 (Minimalist UI): 移除页面顶部与全局导航 Tab 重叠冗余的「Token 消费统计」大标题区域,释放大量垂直空间;将原本独立平铺导致多行折断的分钟粒度(
1h / 24h)无缝内联嵌入至「分钟」胶囊内部;将看板切换、模型视角、时间跨度、单价配置与刷新按功能分组收敛至同一平整控制栏,彻底消除常规窗口下的孤立断行与拥挤感。 - 全量 12 语种国际化支持: 同步补齐全部 12 种系统语言关于实际路由/请求模型、首字延迟 (TTFT) 以及各时间范围 Tooltip 提示的词条与上下文指引。(Fixes #3810)
- 分模型统计双视角支持: 解决分模型统计仅记录客户端原始模型导致昂贵路由模型(如 Fable 5、Opus 等)消耗被掩盖的问题;在
Full Changelog: v5.0.2-beta.6...v5.0.2-beta.7