@ai-sdk/xai 3.0.16 → 3.0.18
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 +13 -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 +2 -2
package/dist/index.mjs
CHANGED
|
@@ -862,6 +862,10 @@ import {
|
|
|
862
862
|
} from "@ai-sdk/provider-utils";
|
|
863
863
|
|
|
864
864
|
// src/responses/convert-to-xai-responses-input.ts
|
|
865
|
+
import {
|
|
866
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError3
|
|
867
|
+
} from "@ai-sdk/provider";
|
|
868
|
+
import { convertToBase64 as convertToBase642 } from "@ai-sdk/provider-utils";
|
|
865
869
|
async function convertToXaiResponsesInput({
|
|
866
870
|
prompt
|
|
867
871
|
}) {
|
|
@@ -878,18 +882,23 @@ async function convertToXaiResponsesInput({
|
|
|
878
882
|
break;
|
|
879
883
|
}
|
|
880
884
|
case "user": {
|
|
881
|
-
|
|
885
|
+
const contentParts = [];
|
|
882
886
|
for (const block of message.content) {
|
|
883
887
|
switch (block.type) {
|
|
884
888
|
case "text": {
|
|
885
|
-
|
|
889
|
+
contentParts.push({ type: "input_text", text: block.text });
|
|
886
890
|
break;
|
|
887
891
|
}
|
|
888
892
|
case "file": {
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
+
if (block.mediaType.startsWith("image/")) {
|
|
894
|
+
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
895
|
+
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${convertToBase642(block.data)}`;
|
|
896
|
+
contentParts.push({ type: "input_image", image_url: imageUrl });
|
|
897
|
+
} else {
|
|
898
|
+
throw new UnsupportedFunctionalityError3({
|
|
899
|
+
functionality: `file part media type ${block.mediaType}`
|
|
900
|
+
});
|
|
901
|
+
}
|
|
893
902
|
break;
|
|
894
903
|
}
|
|
895
904
|
default: {
|
|
@@ -903,7 +912,7 @@ async function convertToXaiResponsesInput({
|
|
|
903
912
|
}
|
|
904
913
|
input.push({
|
|
905
914
|
role: "user",
|
|
906
|
-
content:
|
|
915
|
+
content: contentParts
|
|
907
916
|
});
|
|
908
917
|
break;
|
|
909
918
|
}
|
|
@@ -1356,7 +1365,7 @@ var xaiResponsesProviderOptions = z5.object({
|
|
|
1356
1365
|
|
|
1357
1366
|
// src/responses/xai-responses-prepare-tools.ts
|
|
1358
1367
|
import {
|
|
1359
|
-
UnsupportedFunctionalityError as
|
|
1368
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
1360
1369
|
} from "@ai-sdk/provider";
|
|
1361
1370
|
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
1362
1371
|
|
|
@@ -1609,7 +1618,7 @@ async function prepareResponsesTools({
|
|
|
1609
1618
|
}
|
|
1610
1619
|
default: {
|
|
1611
1620
|
const _exhaustiveCheck = type;
|
|
1612
|
-
throw new
|
|
1621
|
+
throw new UnsupportedFunctionalityError4({
|
|
1613
1622
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1614
1623
|
});
|
|
1615
1624
|
}
|
|
@@ -2199,7 +2208,7 @@ var xaiTools = {
|
|
|
2199
2208
|
};
|
|
2200
2209
|
|
|
2201
2210
|
// src/version.ts
|
|
2202
|
-
var VERSION = true ? "3.0.
|
|
2211
|
+
var VERSION = true ? "3.0.18" : "0.0.0-test";
|
|
2203
2212
|
|
|
2204
2213
|
// src/xai-provider.ts
|
|
2205
2214
|
var xaiErrorStructure = {
|