@ai-sdk/xai 2.0.52 → 2.0.53
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 +56 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1185,6 +1185,10 @@ var xaiResponsesProviderOptions = z5.object({
|
|
|
1185
1185
|
});
|
|
1186
1186
|
|
|
1187
1187
|
// src/responses/convert-to-xai-responses-input.ts
|
|
1188
|
+
import {
|
|
1189
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError3
|
|
1190
|
+
} from "@ai-sdk/provider";
|
|
1191
|
+
import { convertToBase64 as convertToBase642 } from "@ai-sdk/provider-utils";
|
|
1188
1192
|
async function convertToXaiResponsesInput({
|
|
1189
1193
|
prompt
|
|
1190
1194
|
}) {
|
|
@@ -1201,18 +1205,23 @@ async function convertToXaiResponsesInput({
|
|
|
1201
1205
|
break;
|
|
1202
1206
|
}
|
|
1203
1207
|
case "user": {
|
|
1204
|
-
|
|
1208
|
+
const contentParts = [];
|
|
1205
1209
|
for (const block of message.content) {
|
|
1206
1210
|
switch (block.type) {
|
|
1207
1211
|
case "text": {
|
|
1208
|
-
|
|
1212
|
+
contentParts.push({ type: "input_text", text: block.text });
|
|
1209
1213
|
break;
|
|
1210
1214
|
}
|
|
1211
1215
|
case "file": {
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
+
if (block.mediaType.startsWith("image/")) {
|
|
1217
|
+
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
1218
|
+
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${convertToBase642(block.data)}`;
|
|
1219
|
+
contentParts.push({ type: "input_image", image_url: imageUrl });
|
|
1220
|
+
} else {
|
|
1221
|
+
throw new UnsupportedFunctionalityError3({
|
|
1222
|
+
functionality: `file part media type ${block.mediaType}`
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1216
1225
|
break;
|
|
1217
1226
|
}
|
|
1218
1227
|
default: {
|
|
@@ -1226,7 +1235,7 @@ async function convertToXaiResponsesInput({
|
|
|
1226
1235
|
}
|
|
1227
1236
|
input.push({
|
|
1228
1237
|
role: "user",
|
|
1229
|
-
content:
|
|
1238
|
+
content: contentParts
|
|
1230
1239
|
});
|
|
1231
1240
|
break;
|
|
1232
1241
|
}
|
|
@@ -1327,7 +1336,7 @@ async function convertToXaiResponsesInput({
|
|
|
1327
1336
|
|
|
1328
1337
|
// src/responses/xai-responses-prepare-tools.ts
|
|
1329
1338
|
import {
|
|
1330
|
-
UnsupportedFunctionalityError as
|
|
1339
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
1331
1340
|
} from "@ai-sdk/provider";
|
|
1332
1341
|
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
1333
1342
|
|
|
@@ -1576,7 +1585,7 @@ async function prepareResponsesTools({
|
|
|
1576
1585
|
}
|
|
1577
1586
|
default: {
|
|
1578
1587
|
const _exhaustiveCheck = type;
|
|
1579
|
-
throw new
|
|
1588
|
+
throw new UnsupportedFunctionalityError4({
|
|
1580
1589
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1581
1590
|
});
|
|
1582
1591
|
}
|
|
@@ -2177,7 +2186,7 @@ var xaiTools = {
|
|
|
2177
2186
|
};
|
|
2178
2187
|
|
|
2179
2188
|
// src/version.ts
|
|
2180
|
-
var VERSION = true ? "2.0.
|
|
2189
|
+
var VERSION = true ? "2.0.53" : "0.0.0-test";
|
|
2181
2190
|
|
|
2182
2191
|
// src/xai-provider.ts
|
|
2183
2192
|
var xaiErrorStructure = {
|