@ai-sdk/xai 3.0.54 → 3.0.56
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 +14 -0
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/convert-xai-chat-usage.ts +8 -2
- package/src/responses/convert-xai-responses-usage.ts +8 -2
package/dist/index.mjs
CHANGED
|
@@ -143,10 +143,11 @@ function convertXaiChatUsage(usage) {
|
|
|
143
143
|
var _a, _b, _c, _d;
|
|
144
144
|
const cacheReadTokens = (_b = (_a = usage.prompt_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0;
|
|
145
145
|
const reasoningTokens = (_d = (_c = usage.completion_tokens_details) == null ? void 0 : _c.reasoning_tokens) != null ? _d : 0;
|
|
146
|
+
const promptTokensIncludesCached = cacheReadTokens <= usage.prompt_tokens;
|
|
146
147
|
return {
|
|
147
148
|
inputTokens: {
|
|
148
|
-
total: usage.prompt_tokens,
|
|
149
|
-
noCache: usage.prompt_tokens - cacheReadTokens,
|
|
149
|
+
total: promptTokensIncludesCached ? usage.prompt_tokens : usage.prompt_tokens + cacheReadTokens,
|
|
150
|
+
noCache: promptTokensIncludesCached ? usage.prompt_tokens - cacheReadTokens : usage.prompt_tokens,
|
|
150
151
|
cacheRead: cacheReadTokens,
|
|
151
152
|
cacheWrite: void 0
|
|
152
153
|
},
|
|
@@ -1189,10 +1190,11 @@ function convertXaiResponsesUsage(usage) {
|
|
|
1189
1190
|
var _a, _b, _c, _d;
|
|
1190
1191
|
const cacheReadTokens = (_b = (_a = usage.input_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0;
|
|
1191
1192
|
const reasoningTokens = (_d = (_c = usage.output_tokens_details) == null ? void 0 : _c.reasoning_tokens) != null ? _d : 0;
|
|
1193
|
+
const inputTokensIncludesCached = cacheReadTokens <= usage.input_tokens;
|
|
1192
1194
|
return {
|
|
1193
1195
|
inputTokens: {
|
|
1194
|
-
total: usage.input_tokens,
|
|
1195
|
-
noCache: usage.input_tokens - cacheReadTokens,
|
|
1196
|
+
total: inputTokensIncludesCached ? usage.input_tokens : usage.input_tokens + cacheReadTokens,
|
|
1197
|
+
noCache: inputTokensIncludesCached ? usage.input_tokens - cacheReadTokens : usage.input_tokens,
|
|
1196
1198
|
cacheRead: cacheReadTokens,
|
|
1197
1199
|
cacheWrite: void 0
|
|
1198
1200
|
},
|
|
@@ -2711,7 +2713,7 @@ var xaiTools = {
|
|
|
2711
2713
|
};
|
|
2712
2714
|
|
|
2713
2715
|
// src/version.ts
|
|
2714
|
-
var VERSION = true ? "3.0.
|
|
2716
|
+
var VERSION = true ? "3.0.56" : "0.0.0-test";
|
|
2715
2717
|
|
|
2716
2718
|
// src/xai-provider.ts
|
|
2717
2719
|
function createXai(options = {}) {
|