@revojs/ai 0.2.46 → 0.2.48
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.
|
@@ -296,6 +296,9 @@ async function* readParts(response, warnings) {
|
|
|
296
296
|
if (chunk.type === "message_delta") {
|
|
297
297
|
if (typeof chunk.delta?.stop_reason === "string") stopReason = chunk.delta.stop_reason;
|
|
298
298
|
if (typeof chunk.usage?.output_tokens === "number") outputTokens = chunk.usage.output_tokens;
|
|
299
|
+
if (chunk.usage?.input_tokens) inputTokens = chunk.usage.input_tokens;
|
|
300
|
+
if (chunk.usage?.cache_read_input_tokens) cacheRead = chunk.usage.cache_read_input_tokens;
|
|
301
|
+
if (chunk.usage?.cache_creation_input_tokens) cacheWrite = chunk.usage.cache_creation_input_tokens;
|
|
299
302
|
}
|
|
300
303
|
}
|
|
301
304
|
for (const record of active.values()) if (record.kind === "tool_use") yield {
|
|
@@ -115,11 +115,13 @@ function toBody(config, options, stream) {
|
|
|
115
115
|
];
|
|
116
116
|
}
|
|
117
117
|
function toUsage(chunk) {
|
|
118
|
+
const input = chunk?.prompt_tokens;
|
|
119
|
+
const cached = chunk?.prompt_tokens_details?.cached_tokens ?? chunk?.prompt_cache_hit_tokens;
|
|
118
120
|
return {
|
|
119
121
|
inputTokens: {
|
|
120
|
-
total:
|
|
121
|
-
noCache:
|
|
122
|
-
cacheRead:
|
|
122
|
+
total: input,
|
|
123
|
+
noCache: input !== void 0 && cached !== void 0 ? Math.max(0, input - cached) : input,
|
|
124
|
+
cacheRead: cached,
|
|
123
125
|
cacheWrite: void 0
|
|
124
126
|
},
|
|
125
127
|
outputTokens: {
|