@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/dist/index.mjs
CHANGED
|
@@ -1055,7 +1055,7 @@ import { convertToBase64 as convertToBase642 } from "@ai-sdk/provider-utils";
|
|
|
1055
1055
|
async function convertToXaiResponsesInput({
|
|
1056
1056
|
prompt
|
|
1057
1057
|
}) {
|
|
1058
|
-
var _a, _b, _c, _d, _e;
|
|
1058
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1059
1059
|
const input = [];
|
|
1060
1060
|
const inputWarnings = [];
|
|
1061
1061
|
for (const message of prompt) {
|
|
@@ -1132,7 +1132,34 @@ async function convertToXaiResponsesInput({
|
|
|
1132
1132
|
case "tool-result": {
|
|
1133
1133
|
break;
|
|
1134
1134
|
}
|
|
1135
|
-
case "reasoning":
|
|
1135
|
+
case "reasoning": {
|
|
1136
|
+
const itemId = typeof ((_f = (_e = part.providerOptions) == null ? void 0 : _e.xai) == null ? void 0 : _f.itemId) === "string" ? part.providerOptions.xai.itemId : void 0;
|
|
1137
|
+
const encryptedContent = typeof ((_h = (_g = part.providerOptions) == null ? void 0 : _g.xai) == null ? void 0 : _h.reasoningEncryptedContent) === "string" ? part.providerOptions.xai.reasoningEncryptedContent : void 0;
|
|
1138
|
+
if (itemId != null || encryptedContent != null) {
|
|
1139
|
+
const summaryParts = [];
|
|
1140
|
+
if (part.text.length > 0) {
|
|
1141
|
+
summaryParts.push({
|
|
1142
|
+
type: "summary_text",
|
|
1143
|
+
text: part.text
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
input.push({
|
|
1147
|
+
type: "reasoning",
|
|
1148
|
+
id: itemId != null ? itemId : "",
|
|
1149
|
+
summary: summaryParts,
|
|
1150
|
+
status: "completed",
|
|
1151
|
+
...encryptedContent != null && {
|
|
1152
|
+
encrypted_content: encryptedContent
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
} else {
|
|
1156
|
+
inputWarnings.push({
|
|
1157
|
+
type: "other",
|
|
1158
|
+
message: "Reasoning parts without itemId or encrypted content cannot be sent back to xAI. Skipping."
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
break;
|
|
1162
|
+
}
|
|
1136
1163
|
case "file": {
|
|
1137
1164
|
inputWarnings.push({
|
|
1138
1165
|
type: "other",
|
|
@@ -1164,7 +1191,7 @@ async function convertToXaiResponsesInput({
|
|
|
1164
1191
|
outputValue = output.value;
|
|
1165
1192
|
break;
|
|
1166
1193
|
case "execution-denied":
|
|
1167
|
-
outputValue = (
|
|
1194
|
+
outputValue = (_i = output.reason) != null ? _i : "tool execution denied";
|
|
1168
1195
|
break;
|
|
1169
1196
|
case "json":
|
|
1170
1197
|
case "error-json":
|
|
@@ -1683,6 +1710,8 @@ var xaiLanguageModelResponsesOptions = z7.object({
|
|
|
1683
1710
|
topLogprobs: z7.number().int().min(0).max(8).optional(),
|
|
1684
1711
|
/**
|
|
1685
1712
|
* Whether to store the input message(s) and model response for later retrieval.
|
|
1713
|
+
* Must be set to `false` for teams with Zero Data Retention (ZDR) enabled,
|
|
1714
|
+
* otherwise the API will return an error.
|
|
1686
1715
|
* @default true
|
|
1687
1716
|
*/
|
|
1688
1717
|
store: z7.boolean().optional(),
|
|
@@ -2028,7 +2057,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2028
2057
|
tools,
|
|
2029
2058
|
toolChoice
|
|
2030
2059
|
}) {
|
|
2031
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2060
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2032
2061
|
const warnings = [];
|
|
2033
2062
|
const options = (_a = await parseProviderOptions3({
|
|
2034
2063
|
provider: "xai",
|
|
@@ -2055,7 +2084,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2055
2084
|
)) == null ? void 0 : _f.name;
|
|
2056
2085
|
const { input, inputWarnings } = await convertToXaiResponsesInput({
|
|
2057
2086
|
prompt,
|
|
2058
|
-
store: true
|
|
2087
|
+
store: (_g = options.store) != null ? _g : true
|
|
2059
2088
|
});
|
|
2060
2089
|
warnings.push(...inputWarnings);
|
|
2061
2090
|
const {
|
|
@@ -2089,7 +2118,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2089
2118
|
format: responseFormat.schema != null ? {
|
|
2090
2119
|
type: "json_schema",
|
|
2091
2120
|
strict: true,
|
|
2092
|
-
name: (
|
|
2121
|
+
name: (_h = responseFormat.name) != null ? _h : "response",
|
|
2093
2122
|
description: responseFormat.description,
|
|
2094
2123
|
schema: responseFormat.schema
|
|
2095
2124
|
} : { type: "json_object" }
|
|
@@ -2247,12 +2276,13 @@ var XaiResponsesLanguageModel = class {
|
|
|
2247
2276
|
}
|
|
2248
2277
|
case "reasoning": {
|
|
2249
2278
|
const summaryTexts = part.summary.map((s) => s.text).filter((text) => text && text.length > 0);
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2279
|
+
const reasoningText = summaryTexts.join("");
|
|
2280
|
+
if (reasoningText || part.encrypted_content) {
|
|
2281
|
+
const hasMetadata = part.encrypted_content || part.id;
|
|
2282
|
+
content.push({
|
|
2283
|
+
type: "reasoning",
|
|
2284
|
+
text: reasoningText,
|
|
2285
|
+
...hasMetadata && {
|
|
2256
2286
|
providerMetadata: {
|
|
2257
2287
|
xai: {
|
|
2258
2288
|
...part.encrypted_content && {
|
|
@@ -2261,13 +2291,8 @@ var XaiResponsesLanguageModel = class {
|
|
|
2261
2291
|
...part.id && { itemId: part.id }
|
|
2262
2292
|
}
|
|
2263
2293
|
}
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
content.push({
|
|
2267
|
-
type: "reasoning",
|
|
2268
|
-
text: reasoningText
|
|
2269
|
-
});
|
|
2270
|
-
}
|
|
2294
|
+
}
|
|
2295
|
+
});
|
|
2271
2296
|
}
|
|
2272
2297
|
break;
|
|
2273
2298
|
}
|
|
@@ -2786,7 +2811,7 @@ var xaiTools = {
|
|
|
2786
2811
|
};
|
|
2787
2812
|
|
|
2788
2813
|
// src/version.ts
|
|
2789
|
-
var VERSION = true ? "3.0.
|
|
2814
|
+
var VERSION = true ? "3.0.84" : "0.0.0-test";
|
|
2790
2815
|
|
|
2791
2816
|
// src/xai-video-model.ts
|
|
2792
2817
|
import {
|