fix(usage): estimate cache read tokens for cancelled requests

This commit is contained in:
ZheFox
2026-05-17 02:13:13 +08:00
parent 0483d001b4
commit b903f8ff7d
2 changed files with 243 additions and 15 deletions

View File

@@ -451,6 +451,26 @@ mod tests {
.and_then(Value::as_i64),
Some(0)
);
assert_eq!(
event
.data
.request_metadata
.as_ref()
.and_then(|value| value.get("billing_dimensions"))
.and_then(|value| value.get("input_tokens"))
.and_then(Value::as_i64),
Some(900)
);
assert_eq!(
event
.data
.request_metadata
.as_ref()
.and_then(|value| value.get("billing_dimensions"))
.and_then(|value| value.get("cache_read_tokens"))
.and_then(Value::as_i64),
Some(100)
);
}
#[tokio::test]