@ai-sdk/xai 3.0.110 → 3.0.111
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 +6 -0
- package/dist/index.js +36 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/responses/convert-to-xai-responses-input.ts +37 -8
- package/src/responses/xai-responses-api.ts +12 -1
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import { convertToBase64, parseProviderOptions } from '@ai-sdk/provider-utils';
|
|
7
7
|
import { xaiFilePartProviderOptions } from '../xai-file-part-options';
|
|
8
8
|
import type {
|
|
9
|
+
XaiResponsesFunctionCallOutput,
|
|
9
10
|
XaiResponsesInput,
|
|
10
11
|
XaiResponsesUserMessageContentPart,
|
|
11
12
|
} from './xai-responses-api';
|
|
@@ -216,7 +217,7 @@ export async function convertToXaiResponsesInput({
|
|
|
216
217
|
}
|
|
217
218
|
const output = part.output;
|
|
218
219
|
|
|
219
|
-
let outputValue:
|
|
220
|
+
let outputValue: XaiResponsesFunctionCallOutput['output'];
|
|
220
221
|
switch (output.type) {
|
|
221
222
|
case 'text':
|
|
222
223
|
case 'error-text':
|
|
@@ -230,14 +231,42 @@ export async function convertToXaiResponsesInput({
|
|
|
230
231
|
outputValue = JSON.stringify(output.value);
|
|
231
232
|
break;
|
|
232
233
|
case 'content':
|
|
233
|
-
outputValue =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
outputValue = [];
|
|
235
|
+
for (const item of output.value) {
|
|
236
|
+
switch (item.type) {
|
|
237
|
+
case 'text': {
|
|
238
|
+
outputValue.push({
|
|
239
|
+
type: 'input_text',
|
|
240
|
+
text: item.text,
|
|
241
|
+
});
|
|
242
|
+
break;
|
|
237
243
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
244
|
+
case 'image-data': {
|
|
245
|
+
outputValue.push({
|
|
246
|
+
type: 'input_image',
|
|
247
|
+
image_url: `data:${item.mediaType};base64,${item.data}`,
|
|
248
|
+
});
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
case 'image-url': {
|
|
252
|
+
outputValue.push({
|
|
253
|
+
type: 'input_image',
|
|
254
|
+
image_url: item.url,
|
|
255
|
+
});
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
case 'file-data':
|
|
259
|
+
case 'file-url':
|
|
260
|
+
case 'file-id':
|
|
261
|
+
case 'image-file-id':
|
|
262
|
+
case 'custom': {
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
default: {
|
|
266
|
+
const _exhaustiveCheck: never = item;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
241
270
|
break;
|
|
242
271
|
default: {
|
|
243
272
|
const _exhaustiveCheck: never = output;
|
|
@@ -47,7 +47,18 @@ export type XaiResponsesAssistantMessage = {
|
|
|
47
47
|
export type XaiResponsesFunctionCallOutput = {
|
|
48
48
|
type: 'function_call_output';
|
|
49
49
|
call_id: string;
|
|
50
|
-
output:
|
|
50
|
+
output:
|
|
51
|
+
| string
|
|
52
|
+
| Array<
|
|
53
|
+
| {
|
|
54
|
+
type: 'input_text';
|
|
55
|
+
text: string;
|
|
56
|
+
}
|
|
57
|
+
| {
|
|
58
|
+
type: 'input_image';
|
|
59
|
+
image_url: string;
|
|
60
|
+
}
|
|
61
|
+
>;
|
|
51
62
|
};
|
|
52
63
|
|
|
53
64
|
export type XaiResponsesReasoning = {
|