dsh-recent-usage-metrics 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/client/client.js +29 -38
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## 0.3.2
|
|
2
|
+
|
|
3
|
+
- 修复:速度列的悬浮提示常常拿不到模型名,或显示成别的模型。
|
|
4
|
+
原来从统计折叠的 `request/header` 事件推断,但那种事件只在模型或工具集变化时才写——
|
|
5
|
+
真实会话里 3139 次请求只对应 24 条,覆盖率约 1%,其余步骤只能借用几小时前的旧值。
|
|
6
|
+
- 改为读轨迹域的 assistant 节点:它把 `assistant/message.source` 原样复制成
|
|
7
|
+
`providerMetadata`,每步都有,是客户端半能拿到的唯一逐步事实。
|
|
8
|
+
- 没有轨迹节点的步骤保持空值,不再借用旧 header 猜测。
|
|
9
|
+
|
|
10
|
+
## 0.3.1
|
|
11
|
+
|
|
12
|
+
- 修复:切换模型后的第一步,抽屉速度列的悬浮提示显示了上一个模型。
|
|
13
|
+
`request/header` 写在它自己的 `step/start` 之后约 4 毫秒,只按「早于该步开始的最近一条」
|
|
14
|
+
匹配会漏掉它,退回上一次请求的模型。现在先在该步到下一起点之间找,找不到才回退。
|
|
15
|
+
在 3119 步的真实日志上,旧规则命中 99.8%,新规则 100%。
|
|
16
|
+
|
|
17
|
+
- 说明:`trae` 等 provider 不单独上报 `cacheReadTokens`,而是并入 `inputTokens`。
|
|
18
|
+
这类行没有缓存命中率可算,输出 Token 列的提示会显示破折号——这是数据源缺失,不是漏算。
|
|
19
|
+
|
|
1
20
|
# 更新记录
|
|
2
21
|
|
|
3
22
|
## 0.3.0
|
package/client/client.js
CHANGED
|
@@ -1172,42 +1172,31 @@ window.__ModuleLoader__.load({
|
|
|
1172
1172
|
/**
|
|
1173
1173
|
* Which model answered each step, keyed `turn:step`.
|
|
1174
1174
|
*
|
|
1175
|
-
*
|
|
1176
|
-
*
|
|
1177
|
-
*
|
|
1178
|
-
* is attributed to the newest header that precedes it.
|
|
1175
|
+
* Read from the Trajectory domain's assistant nodes, which carry `providerMetadata` copied
|
|
1176
|
+
* straight from `assistant/message.source`. That is the only per-step source of truth the
|
|
1177
|
+
* client half can reach:
|
|
1179
1178
|
*
|
|
1180
|
-
*
|
|
1181
|
-
*
|
|
1182
|
-
*
|
|
1179
|
+
* - The statistics fold puts no provider/model on a step, and its `request-header` rows are
|
|
1180
|
+
* written only when the routed model or tool set CHANGES — 24 of them for 3139 requests in
|
|
1181
|
+
* a real session, so they describe about 1% of steps and mislabel the rest.
|
|
1182
|
+
* - The Chat snapshot's assistant nodes drop the source entirely.
|
|
1183
|
+
*
|
|
1184
|
+
* A compaction is not covered here: it has its own `compaction.model`.
|
|
1183
1185
|
*/
|
|
1184
|
-
function
|
|
1185
|
-
const turns = statsSnapshot?.turns
|
|
1186
|
+
function modelIndexFromTrajectory(trajectorySnapshot) {
|
|
1186
1187
|
const index = new Map()
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
if (
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
}
|
|
1199
|
-
if (headers.length === 0) continue
|
|
1200
|
-
for (const step of turn.steps) {
|
|
1201
|
-
const at = numberOrNull(step.startTime)
|
|
1202
|
-
if (at === null || typeof step.step !== 'number') continue
|
|
1203
|
-
let chosen = null
|
|
1204
|
-
for (const header of headers) {
|
|
1205
|
-
if (header.time <= at) chosen = header
|
|
1206
|
-
else break
|
|
1207
|
-
}
|
|
1208
|
-
if (chosen === null) continue
|
|
1209
|
-
index.set(`${turn.turn}:${step.step}`, chosen)
|
|
1210
|
-
}
|
|
1188
|
+
const nodes = trajectorySnapshot?.eventNodes
|
|
1189
|
+
if (!Array.isArray(nodes)) return index
|
|
1190
|
+
for (const node of nodes) {
|
|
1191
|
+
if (node === null || typeof node !== 'object') continue
|
|
1192
|
+
if (node.kind !== 'assistant') continue
|
|
1193
|
+
const meta = node.providerMetadata
|
|
1194
|
+
if (meta === null || typeof meta !== 'object') continue
|
|
1195
|
+
const model = typeof meta.model === 'string' && meta.model !== '' ? meta.model : null
|
|
1196
|
+
const provider = typeof meta.provider === 'string' && meta.provider !== '' ? meta.provider : null
|
|
1197
|
+
if (model === null && provider === null) continue
|
|
1198
|
+
if (typeof node.turn !== 'number' || typeof node.step !== 'number') continue
|
|
1199
|
+
index.set(`${node.turn}:${node.step}`, { provider, model })
|
|
1211
1200
|
}
|
|
1212
1201
|
return index
|
|
1213
1202
|
}
|
|
@@ -1265,9 +1254,8 @@ window.__ModuleLoader__.load({
|
|
|
1265
1254
|
* *after* selection: capping here at ten and then dropping the live step left the drawer
|
|
1266
1255
|
* showing nine rows for as long as a request was streaming.
|
|
1267
1256
|
*/
|
|
1268
|
-
function historyFromStats(statsSnapshot) {
|
|
1257
|
+
function historyFromStats(statsSnapshot, models) {
|
|
1269
1258
|
const steps = statsSteps(statsSnapshot)
|
|
1270
|
-
const models = modelIndexFromStats(statsSnapshot)
|
|
1271
1259
|
const rows = []
|
|
1272
1260
|
for (const entry of steps) {
|
|
1273
1261
|
// A step only has a row once it has started; `step/start` is what supplies this.
|
|
@@ -1275,7 +1263,7 @@ window.__ModuleLoader__.load({
|
|
|
1275
1263
|
if (!statsStepHasFigures(entry.metrics)) continue
|
|
1276
1264
|
const row = readingOfStatsStep(entry)
|
|
1277
1265
|
// Attribute the request to the model that served it, for the speed column's tooltip.
|
|
1278
|
-
const owner = models.get(row.key)
|
|
1266
|
+
const owner = models === undefined ? undefined : models.get(row.key)
|
|
1279
1267
|
if (owner !== undefined) {
|
|
1280
1268
|
row.model = owner.model
|
|
1281
1269
|
row.provider = owner.provider
|
|
@@ -2969,8 +2957,11 @@ window.__ModuleLoader__.load({
|
|
|
2969
2957
|
* what made the drawer lag the log.
|
|
2970
2958
|
*/
|
|
2971
2959
|
const statsRows = useMemo(
|
|
2972
|
-
() =>
|
|
2973
|
-
|
|
2960
|
+
() =>
|
|
2961
|
+
sessionStats === undefined
|
|
2962
|
+
? undefined
|
|
2963
|
+
: historyFromStats(sessionStats, modelIndexFromTrajectory(trajectory)),
|
|
2964
|
+
[sessionStats, trajectory],
|
|
2974
2965
|
)
|
|
2975
2966
|
/*
|
|
2976
2967
|
* Fallback for a composition without the statistics target: derive rows from the Chat
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-recent-usage-metrics",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Geek level for the Performance & usage setting: a live reading of the newest request (first-token latency, speed, tokens, total, amortised) plus a drawer listing the last ten, all derived from the shipped Statistics view data",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|