@ai-sdk/xai 4.0.0-beta.44 → 4.0.0-beta.46
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
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.46
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 78b6433: 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
|
+
|
|
15
|
+
## 4.0.0-beta.45
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
20
|
+
- Updated dependencies [9f0e36c]
|
|
21
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.33
|
|
22
|
+
- @ai-sdk/provider@4.0.0-beta.13
|
|
23
|
+
- @ai-sdk/provider-utils@5.0.0-beta.28
|
|
24
|
+
|
|
3
25
|
## 4.0.0-beta.44
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1149,9 +1149,14 @@ async function convertToXaiResponsesInput({
|
|
|
1149
1149
|
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
1150
1150
|
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${convertToBase642(block.data)}`;
|
|
1151
1151
|
contentParts.push({ type: "input_image", image_url: imageUrl });
|
|
1152
|
+
} else if (block.data instanceof URL) {
|
|
1153
|
+
contentParts.push({
|
|
1154
|
+
type: "input_file",
|
|
1155
|
+
file_url: block.data.toString()
|
|
1156
|
+
});
|
|
1152
1157
|
} else {
|
|
1153
1158
|
throw new UnsupportedFunctionalityError3({
|
|
1154
|
-
functionality: `file part media type ${block.mediaType}`
|
|
1159
|
+
functionality: `file part media type ${block.mediaType} as inline data (xAI Responses requires a URL or a Files API reference for non-image files)`
|
|
1155
1160
|
});
|
|
1156
1161
|
}
|
|
1157
1162
|
break;
|
|
@@ -2111,7 +2116,12 @@ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
|
|
|
2111
2116
|
constructor(modelId, config) {
|
|
2112
2117
|
this.specificationVersion = "v4";
|
|
2113
2118
|
this.supportedUrls = {
|
|
2114
|
-
"image/*": [/^https?:\/\/.*$/]
|
|
2119
|
+
"image/*": [/^https?:\/\/.*$/],
|
|
2120
|
+
// xAI's Responses API accepts non-image documents (PDF, plain text, CSV, etc.) as
|
|
2121
|
+
// `{ type: 'input_file', file_url }`. Keeping these URLs intact here lets them pass
|
|
2122
|
+
// through to the converter instead of being downloaded to bytes by the SDK.
|
|
2123
|
+
"application/pdf": [/^https?:\/\/.*$/],
|
|
2124
|
+
"text/*": [/^https?:\/\/.*$/]
|
|
2115
2125
|
};
|
|
2116
2126
|
this.modelId = modelId;
|
|
2117
2127
|
this.config = config;
|
|
@@ -2929,7 +2939,7 @@ var xaiTools = {
|
|
|
2929
2939
|
};
|
|
2930
2940
|
|
|
2931
2941
|
// src/version.ts
|
|
2932
|
-
var VERSION = true ? "4.0.0-beta.
|
|
2942
|
+
var VERSION = true ? "4.0.0-beta.46" : "0.0.0-test";
|
|
2933
2943
|
|
|
2934
2944
|
// src/files/xai-files.ts
|
|
2935
2945
|
import {
|