@ai-sdk/xai 3.0.90 → 3.0.92
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.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +22 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/responses/xai-responses-language-model.ts +11 -9
- package/src/xai-error.ts +13 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/xai",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.92",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/openai-compatible": "2.0.
|
|
32
|
+
"@ai-sdk/openai-compatible": "2.0.48",
|
|
33
33
|
"@ai-sdk/provider": "3.0.10",
|
|
34
34
|
"@ai-sdk/provider-utils": "4.0.27"
|
|
35
35
|
},
|
|
@@ -516,16 +516,18 @@ export class XaiResponsesLanguageModel implements LanguageModelV3 {
|
|
|
516
516
|
if (event.type === 'response.reasoning_summary_part.added') {
|
|
517
517
|
const blockId = `reasoning-${event.item_id}`;
|
|
518
518
|
|
|
519
|
-
activeReasoning[event.item_id]
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
519
|
+
if (activeReasoning[event.item_id] == null) {
|
|
520
|
+
activeReasoning[event.item_id] = {};
|
|
521
|
+
controller.enqueue({
|
|
522
|
+
type: 'reasoning-start',
|
|
523
|
+
id: blockId,
|
|
524
|
+
providerMetadata: {
|
|
525
|
+
xai: {
|
|
526
|
+
itemId: event.item_id,
|
|
527
|
+
},
|
|
526
528
|
},
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
529
531
|
}
|
|
530
532
|
|
|
531
533
|
if (event.type === 'response.reasoning_summary_text.delta') {
|
package/src/xai-error.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
export const xaiErrorDataSchema = z.object({
|
|
4
|
+
const chatCompletionsErrorSchema = z.object({
|
|
6
5
|
error: z.object({
|
|
7
6
|
message: z.string(),
|
|
8
7
|
type: z.string().nullish(),
|
|
@@ -11,9 +10,20 @@ export const xaiErrorDataSchema = z.object({
|
|
|
11
10
|
}),
|
|
12
11
|
});
|
|
13
12
|
|
|
13
|
+
const responsesErrorSchema = z.object({
|
|
14
|
+
code: z.string(),
|
|
15
|
+
error: z.string(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const xaiErrorDataSchema = z.union([
|
|
19
|
+
chatCompletionsErrorSchema,
|
|
20
|
+
responsesErrorSchema,
|
|
21
|
+
]);
|
|
22
|
+
|
|
14
23
|
export type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
15
24
|
|
|
16
25
|
export const xaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
17
26
|
errorSchema: xaiErrorDataSchema,
|
|
18
|
-
errorToMessage: data =>
|
|
27
|
+
errorToMessage: data =>
|
|
28
|
+
'code' in data ? `${data.code}: ${data.error}` : data.error.message,
|
|
19
29
|
});
|