@revojs/ai 0.2.45 → 0.2.47
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.
|
@@ -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: {
|