@ai-sdk/xai 3.0.82 → 3.0.84
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 +17 -0
- package/dist/index.js +45 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -6
- package/src/responses/convert-to-xai-responses-input.ts +41 -1
- package/src/responses/xai-responses-language-model.ts +12 -14
- package/src/responses/xai-responses-options.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 3.0.84
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a7f3c72: trigger release for all packages after provenance setup
|
|
8
|
+
- Updated dependencies [a7f3c72]
|
|
9
|
+
- Updated dependencies [408a2ad]
|
|
10
|
+
- @ai-sdk/openai-compatible@2.0.42
|
|
11
|
+
- @ai-sdk/provider@3.0.9
|
|
12
|
+
- @ai-sdk/provider-utils@4.0.24
|
|
13
|
+
|
|
14
|
+
## 3.0.83
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- b937f3e: fix(xai): support encrypted reasoning round-trip for ZDR
|
|
19
|
+
|
|
3
20
|
## 3.0.82
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1052,7 +1052,7 @@ var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
|
1052
1052
|
async function convertToXaiResponsesInput({
|
|
1053
1053
|
prompt
|
|
1054
1054
|
}) {
|
|
1055
|
-
var _a, _b, _c, _d, _e;
|
|
1055
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1056
1056
|
const input = [];
|
|
1057
1057
|
const inputWarnings = [];
|
|
1058
1058
|
for (const message of prompt) {
|
|
@@ -1129,7 +1129,34 @@ async function convertToXaiResponsesInput({
|
|
|
1129
1129
|
case "tool-result": {
|
|
1130
1130
|
break;
|
|
1131
1131
|
}
|
|
1132
|
-
case "reasoning":
|
|
1132
|
+
case "reasoning": {
|
|
1133
|
+
const itemId = typeof ((_f = (_e = part.providerOptions) == null ? void 0 : _e.xai) == null ? void 0 : _f.itemId) === "string" ? part.providerOptions.xai.itemId : void 0;
|
|
1134
|
+
const encryptedContent = typeof ((_h = (_g = part.providerOptions) == null ? void 0 : _g.xai) == null ? void 0 : _h.reasoningEncryptedContent) === "string" ? part.providerOptions.xai.reasoningEncryptedContent : void 0;
|
|
1135
|
+
if (itemId != null || encryptedContent != null) {
|
|
1136
|
+
const summaryParts = [];
|
|
1137
|
+
if (part.text.length > 0) {
|
|
1138
|
+
summaryParts.push({
|
|
1139
|
+
type: "summary_text",
|
|
1140
|
+
text: part.text
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
input.push({
|
|
1144
|
+
type: "reasoning",
|
|
1145
|
+
id: itemId != null ? itemId : "",
|
|
1146
|
+
summary: summaryParts,
|
|
1147
|
+
status: "completed",
|
|
1148
|
+
...encryptedContent != null && {
|
|
1149
|
+
encrypted_content: encryptedContent
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
} else {
|
|
1153
|
+
inputWarnings.push({
|
|
1154
|
+
type: "other",
|
|
1155
|
+
message: "Reasoning parts without itemId or encrypted content cannot be sent back to xAI. Skipping."
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
break;
|
|
1159
|
+
}
|
|
1133
1160
|
case "file": {
|
|
1134
1161
|
inputWarnings.push({
|
|
1135
1162
|
type: "other",
|
|
@@ -1161,7 +1188,7 @@ async function convertToXaiResponsesInput({
|
|
|
1161
1188
|
outputValue = output.value;
|
|
1162
1189
|
break;
|
|
1163
1190
|
case "execution-denied":
|
|
1164
|
-
outputValue = (
|
|
1191
|
+
outputValue = (_i = output.reason) != null ? _i : "tool execution denied";
|
|
1165
1192
|
break;
|
|
1166
1193
|
case "json":
|
|
1167
1194
|
case "error-json":
|
|
@@ -1680,6 +1707,8 @@ var xaiLanguageModelResponsesOptions = import_v47.z.object({
|
|
|
1680
1707
|
topLogprobs: import_v47.z.number().int().min(0).max(8).optional(),
|
|
1681
1708
|
/**
|
|
1682
1709
|
* Whether to store the input message(s) and model response for later retrieval.
|
|
1710
|
+
* Must be set to `false` for teams with Zero Data Retention (ZDR) enabled,
|
|
1711
|
+
* otherwise the API will return an error.
|
|
1683
1712
|
* @default true
|
|
1684
1713
|
*/
|
|
1685
1714
|
store: import_v47.z.boolean().optional(),
|
|
@@ -2007,7 +2036,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2007
2036
|
tools,
|
|
2008
2037
|
toolChoice
|
|
2009
2038
|
}) {
|
|
2010
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2039
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2011
2040
|
const warnings = [];
|
|
2012
2041
|
const options = (_a = await (0, import_provider_utils11.parseProviderOptions)({
|
|
2013
2042
|
provider: "xai",
|
|
@@ -2034,7 +2063,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2034
2063
|
)) == null ? void 0 : _f.name;
|
|
2035
2064
|
const { input, inputWarnings } = await convertToXaiResponsesInput({
|
|
2036
2065
|
prompt,
|
|
2037
|
-
store: true
|
|
2066
|
+
store: (_g = options.store) != null ? _g : true
|
|
2038
2067
|
});
|
|
2039
2068
|
warnings.push(...inputWarnings);
|
|
2040
2069
|
const {
|
|
@@ -2068,7 +2097,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2068
2097
|
format: responseFormat.schema != null ? {
|
|
2069
2098
|
type: "json_schema",
|
|
2070
2099
|
strict: true,
|
|
2071
|
-
name: (
|
|
2100
|
+
name: (_h = responseFormat.name) != null ? _h : "response",
|
|
2072
2101
|
description: responseFormat.description,
|
|
2073
2102
|
schema: responseFormat.schema
|
|
2074
2103
|
} : { type: "json_object" }
|
|
@@ -2226,12 +2255,13 @@ var XaiResponsesLanguageModel = class {
|
|
|
2226
2255
|
}
|
|
2227
2256
|
case "reasoning": {
|
|
2228
2257
|
const summaryTexts = part.summary.map((s) => s.text).filter((text) => text && text.length > 0);
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2258
|
+
const reasoningText = summaryTexts.join("");
|
|
2259
|
+
if (reasoningText || part.encrypted_content) {
|
|
2260
|
+
const hasMetadata = part.encrypted_content || part.id;
|
|
2261
|
+
content.push({
|
|
2262
|
+
type: "reasoning",
|
|
2263
|
+
text: reasoningText,
|
|
2264
|
+
...hasMetadata && {
|
|
2235
2265
|
providerMetadata: {
|
|
2236
2266
|
xai: {
|
|
2237
2267
|
...part.encrypted_content && {
|
|
@@ -2240,13 +2270,8 @@ var XaiResponsesLanguageModel = class {
|
|
|
2240
2270
|
...part.id && { itemId: part.id }
|
|
2241
2271
|
}
|
|
2242
2272
|
}
|
|
2243
|
-
}
|
|
2244
|
-
}
|
|
2245
|
-
content.push({
|
|
2246
|
-
type: "reasoning",
|
|
2247
|
-
text: reasoningText
|
|
2248
|
-
});
|
|
2249
|
-
}
|
|
2273
|
+
}
|
|
2274
|
+
});
|
|
2250
2275
|
}
|
|
2251
2276
|
break;
|
|
2252
2277
|
}
|
|
@@ -2765,7 +2790,7 @@ var xaiTools = {
|
|
|
2765
2790
|
};
|
|
2766
2791
|
|
|
2767
2792
|
// src/version.ts
|
|
2768
|
-
var VERSION = true ? "3.0.
|
|
2793
|
+
var VERSION = true ? "3.0.84" : "0.0.0-test";
|
|
2769
2794
|
|
|
2770
2795
|
// src/xai-video-model.ts
|
|
2771
2796
|
var import_provider6 = require("@ai-sdk/provider");
|