@ai-sdk/xai 3.0.84 → 3.0.86
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 +26 -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 +5 -5
- package/src/convert-to-xai-chat-messages.ts +3 -3
- package/src/convert-xai-chat-usage.ts +2 -2
- package/src/map-xai-finish-reason.ts +1 -1
- package/src/responses/convert-to-xai-responses-input.ts +14 -4
- package/src/responses/convert-xai-responses-usage.ts +2 -2
- package/src/responses/map-xai-responses-finish-reason.ts +1 -1
- package/src/responses/xai-responses-api.ts +2 -1
- package/src/responses/xai-responses-language-model.ts +11 -6
- package/src/responses/xai-responses-prepare-tools.ts +3 -3
- package/src/xai-chat-language-model.ts +12 -12
- package/src/xai-image-model.ts +3 -3
- package/src/xai-prepare-tools.ts +3 -3
- package/src/xai-provider.ts +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 3.0.86
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [7beadf0]
|
|
8
|
+
- @ai-sdk/provider-utils@4.0.26
|
|
9
|
+
- @ai-sdk/openai-compatible@2.0.44
|
|
10
|
+
|
|
11
|
+
## 3.0.85
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- a727da4: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
16
|
+
- fa6e62b: feat(provider/xai): support non-image file parts (PDF, text, CSV) in the Responses API via `input_file` + `file_url`
|
|
17
|
+
|
|
18
|
+
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/`.
|
|
19
|
+
|
|
20
|
+
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.
|
|
21
|
+
|
|
22
|
+
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.
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [a727da4]
|
|
25
|
+
- @ai-sdk/openai-compatible@2.0.43
|
|
26
|
+
- @ai-sdk/provider-utils@4.0.25
|
|
27
|
+
- @ai-sdk/provider@3.0.10
|
|
28
|
+
|
|
3
29
|
## 3.0.84
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1077,9 +1077,14 @@ async function convertToXaiResponsesInput({
|
|
|
1077
1077
|
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
1078
1078
|
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils5.convertToBase64)(block.data)}`;
|
|
1079
1079
|
contentParts.push({ type: "input_image", image_url: imageUrl });
|
|
1080
|
+
} else if (block.data instanceof URL) {
|
|
1081
|
+
contentParts.push({
|
|
1082
|
+
type: "input_file",
|
|
1083
|
+
file_url: block.data.toString()
|
|
1084
|
+
});
|
|
1080
1085
|
} else {
|
|
1081
1086
|
throw new import_provider4.UnsupportedFunctionalityError({
|
|
1082
|
-
functionality: `file part media type ${block.mediaType}`
|
|
1087
|
+
functionality: `file part media type ${block.mediaType} as inline data (xAI Responses requires a URL or a Files API reference for non-image files)`
|
|
1083
1088
|
});
|
|
1084
1089
|
}
|
|
1085
1090
|
break;
|
|
@@ -2016,7 +2021,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
2016
2021
|
constructor(modelId, config) {
|
|
2017
2022
|
this.specificationVersion = "v3";
|
|
2018
2023
|
this.supportedUrls = {
|
|
2019
|
-
"image/*": [/^https?:\/\/.*$/]
|
|
2024
|
+
"image/*": [/^https?:\/\/.*$/],
|
|
2025
|
+
// xAI's Responses API accepts non-image documents (PDF, plain text, CSV, etc.) as
|
|
2026
|
+
// `{ type: 'input_file', file_url }`. Keeping these URLs intact here lets them pass
|
|
2027
|
+
// through to the converter instead of being downloaded to bytes by the SDK.
|
|
2028
|
+
"application/pdf": [/^https?:\/\/.*$/],
|
|
2029
|
+
"text/*": [/^https?:\/\/.*$/]
|
|
2020
2030
|
};
|
|
2021
2031
|
this.modelId = modelId;
|
|
2022
2032
|
this.config = config;
|
|
@@ -2790,7 +2800,7 @@ var xaiTools = {
|
|
|
2790
2800
|
};
|
|
2791
2801
|
|
|
2792
2802
|
// src/version.ts
|
|
2793
|
-
var VERSION = true ? "3.0.
|
|
2803
|
+
var VERSION = true ? "3.0.86" : "0.0.0-test";
|
|
2794
2804
|
|
|
2795
2805
|
// src/xai-video-model.ts
|
|
2796
2806
|
var import_provider6 = require("@ai-sdk/provider");
|