@ai-sdk/xai
Advanced tools
+3
-3
| { | ||
| "name": "@ai-sdk/xai", | ||
| "version": "4.0.15", | ||
| "version": "4.0.16", | ||
| "type": "module", | ||
@@ -32,5 +32,5 @@ "license": "Apache-2.0", | ||
| "dependencies": { | ||
| "@ai-sdk/openai-compatible": "3.0.11", | ||
| "@ai-sdk/openai-compatible": "3.0.12", | ||
| "@ai-sdk/provider": "4.0.3", | ||
| "@ai-sdk/provider-utils": "5.0.10" | ||
| "@ai-sdk/provider-utils": "5.0.11" | ||
| }, | ||
@@ -37,0 +37,0 @@ "devDependencies": { |
@@ -15,2 +15,3 @@ import { | ||
| import type { | ||
| XaiResponsesFunctionCallOutput, | ||
| XaiResponsesInput, | ||
@@ -245,3 +246,3 @@ XaiResponsesUserMessageContentPart, | ||
| let outputValue: string; | ||
| let outputValue: XaiResponsesFunctionCallOutput['output']; | ||
| switch (output.type) { | ||
@@ -260,10 +261,35 @@ case 'text': | ||
| case 'content': | ||
| outputValue = output.value | ||
| .map(item => { | ||
| if (item.type === 'text') { | ||
| return item.text; | ||
| outputValue = []; | ||
| for (const item of output.value) { | ||
| switch (item.type) { | ||
| case 'text': { | ||
| outputValue.push({ | ||
| type: 'input_text', | ||
| text: item.text, | ||
| }); | ||
| break; | ||
| } | ||
| return ''; | ||
| }) | ||
| .join(''); | ||
| case 'file': { | ||
| if ( | ||
| getTopLevelMediaType(item.mediaType) === 'image' && | ||
| (item.data.type === 'data' || item.data.type === 'url') | ||
| ) { | ||
| outputValue.push({ | ||
| type: 'input_image', | ||
| image_url: | ||
| item.data.type === 'url' | ||
| ? item.data.url.toString() | ||
| : `data:${resolveFullMediaType({ part: item })};base64,${convertToBase64(item.data.data)}`, | ||
| }); | ||
| } | ||
| break; | ||
| } | ||
| case 'custom': { | ||
| break; | ||
| } | ||
| default: { | ||
| const _exhaustiveCheck: never = item; | ||
| } | ||
| } | ||
| } | ||
| break; | ||
@@ -270,0 +296,0 @@ default: { |
@@ -51,3 +51,14 @@ import { z } from 'zod/v4'; | ||
| call_id: string; | ||
| output: string; | ||
| output: | ||
| | string | ||
| | Array< | ||
| | { | ||
| type: 'input_text'; | ||
| text: string; | ||
| } | ||
| | { | ||
| type: 'input_image'; | ||
| image_url: string; | ||
| } | ||
| >; | ||
| }; | ||
@@ -54,0 +65,0 @@ |
@@ -8,2 +8,3 @@ import { | ||
| import { | ||
| cancelResponseBody, | ||
| combineHeaders, | ||
@@ -13,2 +14,3 @@ convertUint8ArrayToBase64, | ||
| delay, | ||
| extractResponseHeaders, | ||
| getFromApi, | ||
@@ -19,2 +21,3 @@ getTopLevelMediaType, | ||
| type FetchFunction, | ||
| type ResponseHandler, | ||
| } from '@ai-sdk/provider-utils'; | ||
@@ -441,5 +444,3 @@ import { z } from 'zod/v4'; | ||
| headers: combineHeaders(this.config.headers(), options.headers), | ||
| successfulResponseHandler: createJsonResponseHandler( | ||
| xaiVideoStatusResponseSchema, | ||
| ), | ||
| successfulResponseHandler: xaiVideoStatusResponseHandler, | ||
| failedResponseHandler: xaiFailedResponseHandler, | ||
@@ -550,1 +551,21 @@ abortSignal: options.abortSignal, | ||
| }); | ||
| const xaiVideoStatusJsonResponseHandler = createJsonResponseHandler( | ||
| xaiVideoStatusResponseSchema, | ||
| ); | ||
| const xaiVideoStatusResponseHandler: ResponseHandler< | ||
| z.infer<typeof xaiVideoStatusResponseSchema> | ||
| > = async options => { | ||
| if (options.response.status === 202) { | ||
| const responseHeaders = extractResponseHeaders(options.response); | ||
| await cancelResponseBody(options.response); | ||
| return { | ||
| responseHeaders, | ||
| value: { status: 'pending' }, | ||
| }; | ||
| } | ||
| return xaiVideoStatusJsonResponseHandler(options); | ||
| }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
804559
0.76%11486
0.78%+ Added
+ Added
- Removed
- Removed