@ai-sdk/xai 3.0.32 → 3.0.34
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 +18 -0
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -5
- package/src/responses/xai-responses-api.ts +1 -1
- package/src/responses/xai-responses-language-model.ts +6 -1
- package/src/convert-to-xai-chat-messages.test.ts +0 -243
- package/src/convert-xai-chat-usage.test.ts +0 -240
- package/src/responses/__fixtures__/xai-code-execution-tool.1.json +0 -68
- package/src/responses/__fixtures__/xai-text-streaming.1.chunks.txt +0 -698
- package/src/responses/__fixtures__/xai-text-with-reasoning-streaming-store-false.1.chunks.txt +0 -655
- package/src/responses/__fixtures__/xai-text-with-reasoning-streaming.1.chunks.txt +0 -679
- package/src/responses/__fixtures__/xai-web-search-tool.1.chunks.txt +0 -274
- package/src/responses/__fixtures__/xai-web-search-tool.1.json +0 -90
- package/src/responses/__fixtures__/xai-x-search-tool.1.json +0 -149
- package/src/responses/__fixtures__/xai-x-search-tool.chunks.txt +0 -1757
- package/src/responses/__snapshots__/xai-responses-language-model.test.ts.snap +0 -21929
- package/src/responses/convert-to-xai-responses-input.test.ts +0 -463
- package/src/responses/xai-responses-language-model.test.ts +0 -1803
- package/src/responses/xai-responses-prepare-tools.test.ts +0 -620
- package/src/xai-chat-language-model.test.ts +0 -1805
- package/src/xai-provider.test.ts +0 -167
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 3.0.34
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 648c8f3: fix(xai): make usage nullable in responses schema for streaming compatibility
|
|
8
|
+
|
|
9
|
+
xAI sends `usage: null` in early streaming events (`response.created`, `response.in_progress`) because token counts aren't available until the stream completes. This change makes the `usage` field nullish in `xaiResponsesResponseSchema` to accept these values without validation errors.
|
|
10
|
+
|
|
11
|
+
## 3.0.33
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 4de5a1d: chore: excluded tests from src folder in npm package
|
|
16
|
+
- Updated dependencies [4de5a1d]
|
|
17
|
+
- @ai-sdk/openai-compatible@2.0.18
|
|
18
|
+
- @ai-sdk/provider@3.0.5
|
|
19
|
+
- @ai-sdk/provider-utils@4.0.9
|
|
20
|
+
|
|
3
21
|
## 3.0.32
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1174,7 +1174,7 @@ var xaiResponsesResponseSchema = import_v44.z.object({
|
|
|
1174
1174
|
model: import_v44.z.string().nullish(),
|
|
1175
1175
|
object: import_v44.z.literal("response"),
|
|
1176
1176
|
output: import_v44.z.array(outputItemSchema),
|
|
1177
|
-
usage: xaiResponsesUsageSchema,
|
|
1177
|
+
usage: xaiResponsesUsageSchema.nullish(),
|
|
1178
1178
|
status: import_v44.z.string()
|
|
1179
1179
|
});
|
|
1180
1180
|
var xaiResponsesChunkSchema = import_v44.z.union([
|
|
@@ -1964,7 +1964,10 @@ var XaiResponsesLanguageModel = class {
|
|
|
1964
1964
|
unified: mapXaiResponsesFinishReason(response.status),
|
|
1965
1965
|
raw: (_j = response.status) != null ? _j : void 0
|
|
1966
1966
|
},
|
|
1967
|
-
usage: convertXaiResponsesUsage(response.usage)
|
|
1967
|
+
usage: response.usage ? convertXaiResponsesUsage(response.usage) : {
|
|
1968
|
+
inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
|
|
1969
|
+
outputTokens: { total: 0, text: 0, reasoning: 0 }
|
|
1970
|
+
},
|
|
1968
1971
|
request: { body },
|
|
1969
1972
|
response: {
|
|
1970
1973
|
...getResponseMetadata(response),
|
|
@@ -2326,7 +2329,7 @@ var xaiTools = {
|
|
|
2326
2329
|
};
|
|
2327
2330
|
|
|
2328
2331
|
// src/version.ts
|
|
2329
|
-
var VERSION = true ? "3.0.
|
|
2332
|
+
var VERSION = true ? "3.0.34" : "0.0.0-test";
|
|
2330
2333
|
|
|
2331
2334
|
// src/xai-provider.ts
|
|
2332
2335
|
var xaiErrorStructure = {
|