@ai-sdk/xai 3.0.109 → 3.0.110
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 +9 -0
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/xai-video-model.ts +24 -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.110",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/openai-compatible": "2.0.
|
|
33
|
-
"@ai-sdk/provider
|
|
34
|
-
"@ai-sdk/provider": "
|
|
32
|
+
"@ai-sdk/openai-compatible": "2.0.62",
|
|
33
|
+
"@ai-sdk/provider": "3.0.14",
|
|
34
|
+
"@ai-sdk/provider-utils": "4.0.40"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "20.17.24",
|
package/src/xai-video-model.ts
CHANGED
|
@@ -5,14 +5,17 @@ import {
|
|
|
5
5
|
type SharedV3Warning,
|
|
6
6
|
} from '@ai-sdk/provider';
|
|
7
7
|
import {
|
|
8
|
+
cancelResponseBody,
|
|
8
9
|
combineHeaders,
|
|
9
10
|
convertUint8ArrayToBase64,
|
|
10
11
|
createJsonResponseHandler,
|
|
11
12
|
delay,
|
|
13
|
+
extractResponseHeaders,
|
|
12
14
|
type FetchFunction,
|
|
13
15
|
getFromApi,
|
|
14
16
|
parseProviderOptions,
|
|
15
17
|
postJsonToApi,
|
|
18
|
+
type ResponseHandler,
|
|
16
19
|
} from '@ai-sdk/provider-utils';
|
|
17
20
|
import { z } from 'zod/v4';
|
|
18
21
|
import { xaiFailedResponseHandler } from './xai-error';
|
|
@@ -438,9 +441,7 @@ export class XaiVideoModel implements Experimental_VideoModelV3 {
|
|
|
438
441
|
await getFromApi({
|
|
439
442
|
url: `${baseURL}/videos/${requestId}`,
|
|
440
443
|
headers: combineHeaders(this.config.headers(), options.headers),
|
|
441
|
-
successfulResponseHandler:
|
|
442
|
-
xaiVideoStatusResponseSchema,
|
|
443
|
-
),
|
|
444
|
+
successfulResponseHandler: xaiVideoStatusResponseHandler,
|
|
444
445
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
445
446
|
abortSignal: options.abortSignal,
|
|
446
447
|
fetch: this.config.fetch,
|
|
@@ -546,3 +547,23 @@ const xaiVideoStatusResponseSchema = z.object({
|
|
|
546
547
|
})
|
|
547
548
|
.nullish(),
|
|
548
549
|
});
|
|
550
|
+
|
|
551
|
+
const xaiVideoStatusJsonResponseHandler = createJsonResponseHandler(
|
|
552
|
+
xaiVideoStatusResponseSchema,
|
|
553
|
+
);
|
|
554
|
+
|
|
555
|
+
const xaiVideoStatusResponseHandler: ResponseHandler<
|
|
556
|
+
z.infer<typeof xaiVideoStatusResponseSchema>
|
|
557
|
+
> = async options => {
|
|
558
|
+
if (options.response.status === 202) {
|
|
559
|
+
const responseHeaders = extractResponseHeaders(options.response);
|
|
560
|
+
await cancelResponseBody(options.response);
|
|
561
|
+
|
|
562
|
+
return {
|
|
563
|
+
responseHeaders,
|
|
564
|
+
value: { status: 'pending' },
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return xaiVideoStatusJsonResponseHandler(options);
|
|
569
|
+
};
|