@ai-sdk/xai 2.0.70 → 2.0.71
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 +12 -0
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 2.0.71
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c10963d: feat(provider/xai): support non-image file parts (PDF, text, CSV) in the Responses API via `input_file` + `file_url`
|
|
8
|
+
|
|
9
|
+
The xAI Responses API accepts `{ type: 'input_file', file_url }` for non-image documents (see https://docs.x.ai/docs/guides/chat-with-files), but the AI SDK xAI Responses provider previously threw `UnsupportedFunctionalityError` for any file part whose `mediaType` did not start with `image/`.
|
|
10
|
+
|
|
11
|
+
When a file part is passed with `data: URL` and a non-image media type, the provider now emits `{ type: 'input_file', file_url }`. `application/pdf` and `text/*` are also added to `supportedUrls` so the SDK does not download them to bytes before reaching the converter.
|
|
12
|
+
|
|
13
|
+
Inline-byte (base64) inputs for non-image media types continue to throw, since xAI's Responses API requires either a public URL or a pre-uploaded `file_id` for non-image documents.
|
|
14
|
+
|
|
3
15
|
## 2.0.70
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1312,9 +1312,14 @@ async function convertToXaiResponsesInput({
|
|
|
1312
1312
|
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
1313
1313
|
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils4.convertToBase64)(block.data)}`;
|
|
1314
1314
|
contentParts.push({ type: "input_image", image_url: imageUrl });
|
|
1315
|
+
} else if (block.data instanceof URL) {
|
|
1316
|
+
contentParts.push({
|
|
1317
|
+
type: "input_file",
|
|
1318
|
+
file_url: block.data.toString()
|
|
1319
|
+
});
|
|
1315
1320
|
} else {
|
|
1316
1321
|
throw new import_provider4.UnsupportedFunctionalityError({
|
|
1317
|
-
functionality: `file part media type ${block.mediaType}`
|
|
1322
|
+
functionality: `file part media type ${block.mediaType} as inline data (xAI Responses requires a URL or a Files API reference for non-image files)`
|
|
1318
1323
|
});
|
|
1319
1324
|
}
|
|
1320
1325
|
break;
|
|
@@ -1682,7 +1687,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
1682
1687
|
constructor(modelId, config) {
|
|
1683
1688
|
this.specificationVersion = "v2";
|
|
1684
1689
|
this.supportedUrls = {
|
|
1685
|
-
"image/*": [/^https?:\/\/.*$/]
|
|
1690
|
+
"image/*": [/^https?:\/\/.*$/],
|
|
1691
|
+
// xAI's Responses API accepts non-image documents (PDF, plain text, CSV, etc.) as
|
|
1692
|
+
// `{ type: 'input_file', file_url }`. Keeping these URLs intact here lets them pass
|
|
1693
|
+
// through to the converter instead of being downloaded to bytes by the SDK.
|
|
1694
|
+
"application/pdf": [/^https?:\/\/.*$/],
|
|
1695
|
+
"text/*": [/^https?:\/\/.*$/]
|
|
1686
1696
|
};
|
|
1687
1697
|
this.modelId = modelId;
|
|
1688
1698
|
this.config = config;
|
|
@@ -2347,7 +2357,7 @@ var xaiTools = {
|
|
|
2347
2357
|
};
|
|
2348
2358
|
|
|
2349
2359
|
// src/version.ts
|
|
2350
|
-
var VERSION = true ? "2.0.
|
|
2360
|
+
var VERSION = true ? "2.0.71" : "0.0.0-test";
|
|
2351
2361
|
|
|
2352
2362
|
// src/xai-provider.ts
|
|
2353
2363
|
var xaiErrorStructure = {
|