@revojs/ai 0.2.46 → 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: chunk?.prompt_tokens,
121
- noCache: chunk?.prompt_tokens,
122
- cacheRead: void 0,
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: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revojs/ai",
3
- "version": "0.2.46",
3
+ "version": "0.2.47",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",