@ai-sdk/xai 2.0.50 → 2.0.52
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 +74 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -937,7 +937,8 @@ var outputItemSchema = z4.discriminatedUnion("type", [
|
|
|
937
937
|
type: z4.literal("reasoning"),
|
|
938
938
|
id: z4.string(),
|
|
939
939
|
summary: z4.array(reasoningSummaryPartSchema),
|
|
940
|
-
status: z4.string()
|
|
940
|
+
status: z4.string(),
|
|
941
|
+
encrypted_content: z4.string().nullish()
|
|
941
942
|
})
|
|
942
943
|
]);
|
|
943
944
|
var xaiResponsesUsageSchema = z4.object({
|
|
@@ -1602,11 +1603,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
1602
1603
|
topP,
|
|
1603
1604
|
stopSequences,
|
|
1604
1605
|
seed,
|
|
1606
|
+
responseFormat,
|
|
1605
1607
|
providerOptions,
|
|
1606
1608
|
tools,
|
|
1607
1609
|
toolChoice
|
|
1608
1610
|
}) {
|
|
1609
|
-
var _a, _b, _c, _d;
|
|
1611
|
+
var _a, _b, _c, _d, _e;
|
|
1610
1612
|
const warnings = [];
|
|
1611
1613
|
const options = (_a = await parseProviderOptions2({
|
|
1612
1614
|
provider: "xai",
|
|
@@ -1649,6 +1651,17 @@ var XaiResponsesLanguageModel = class {
|
|
|
1649
1651
|
temperature,
|
|
1650
1652
|
top_p: topP,
|
|
1651
1653
|
seed,
|
|
1654
|
+
...(responseFormat == null ? void 0 : responseFormat.type) === "json" && {
|
|
1655
|
+
text: {
|
|
1656
|
+
format: responseFormat.schema != null ? {
|
|
1657
|
+
type: "json_schema",
|
|
1658
|
+
strict: true,
|
|
1659
|
+
name: (_e = responseFormat.name) != null ? _e : "response",
|
|
1660
|
+
description: responseFormat.description,
|
|
1661
|
+
schema: responseFormat.schema
|
|
1662
|
+
} : { type: "json_object" }
|
|
1663
|
+
}
|
|
1664
|
+
},
|
|
1652
1665
|
...options.reasoningEffort != null && {
|
|
1653
1666
|
reasoning: { effort: options.reasoningEffort }
|
|
1654
1667
|
},
|
|
@@ -1764,6 +1777,32 @@ var XaiResponsesLanguageModel = class {
|
|
|
1764
1777
|
});
|
|
1765
1778
|
break;
|
|
1766
1779
|
}
|
|
1780
|
+
case "reasoning": {
|
|
1781
|
+
const summaryTexts = part.summary.map((s) => s.text).filter((text) => text && text.length > 0);
|
|
1782
|
+
if (summaryTexts.length > 0) {
|
|
1783
|
+
const reasoningText = summaryTexts.join("");
|
|
1784
|
+
if (part.encrypted_content || part.id) {
|
|
1785
|
+
content.push({
|
|
1786
|
+
type: "reasoning",
|
|
1787
|
+
text: reasoningText,
|
|
1788
|
+
providerMetadata: {
|
|
1789
|
+
xai: {
|
|
1790
|
+
...part.encrypted_content && {
|
|
1791
|
+
reasoningEncryptedContent: part.encrypted_content
|
|
1792
|
+
},
|
|
1793
|
+
...part.id && { itemId: part.id }
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
});
|
|
1797
|
+
} else {
|
|
1798
|
+
content.push({
|
|
1799
|
+
type: "reasoning",
|
|
1800
|
+
text: reasoningText
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
break;
|
|
1805
|
+
}
|
|
1767
1806
|
default: {
|
|
1768
1807
|
break;
|
|
1769
1808
|
}
|
|
@@ -1821,6 +1860,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1821
1860
|
let isFirstChunk = true;
|
|
1822
1861
|
const contentBlocks = {};
|
|
1823
1862
|
const seenToolCalls = /* @__PURE__ */ new Set();
|
|
1863
|
+
const activeReasoning = {};
|
|
1824
1864
|
const self = this;
|
|
1825
1865
|
return {
|
|
1826
1866
|
stream: response.pipeThrough(
|
|
@@ -1852,7 +1892,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
1852
1892
|
const blockId = `reasoning-${event.item_id}`;
|
|
1853
1893
|
controller.enqueue({
|
|
1854
1894
|
type: "reasoning-start",
|
|
1855
|
-
id: blockId
|
|
1895
|
+
id: blockId,
|
|
1896
|
+
providerMetadata: {
|
|
1897
|
+
xai: {
|
|
1898
|
+
itemId: event.item_id
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1856
1901
|
});
|
|
1857
1902
|
}
|
|
1858
1903
|
if (event.type === "response.reasoning_summary_text.delta") {
|
|
@@ -1860,16 +1905,17 @@ var XaiResponsesLanguageModel = class {
|
|
|
1860
1905
|
controller.enqueue({
|
|
1861
1906
|
type: "reasoning-delta",
|
|
1862
1907
|
id: blockId,
|
|
1863
|
-
delta: event.delta
|
|
1908
|
+
delta: event.delta,
|
|
1909
|
+
providerMetadata: {
|
|
1910
|
+
xai: {
|
|
1911
|
+
itemId: event.item_id
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1864
1914
|
});
|
|
1865
1915
|
return;
|
|
1866
1916
|
}
|
|
1867
1917
|
if (event.type === "response.reasoning_summary_text.done") {
|
|
1868
|
-
|
|
1869
|
-
controller.enqueue({
|
|
1870
|
-
type: "reasoning-end",
|
|
1871
|
-
id: blockId
|
|
1872
|
-
});
|
|
1918
|
+
return;
|
|
1873
1919
|
}
|
|
1874
1920
|
if (event.type === "response.output_text.delta") {
|
|
1875
1921
|
const blockId = `text-${event.item_id}`;
|
|
@@ -1932,6 +1978,24 @@ var XaiResponsesLanguageModel = class {
|
|
|
1932
1978
|
}
|
|
1933
1979
|
if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
|
|
1934
1980
|
const part = event.item;
|
|
1981
|
+
if (part.type === "reasoning") {
|
|
1982
|
+
if (event.type === "response.output_item.done") {
|
|
1983
|
+
controller.enqueue({
|
|
1984
|
+
type: "reasoning-end",
|
|
1985
|
+
id: `reasoning-${part.id}`,
|
|
1986
|
+
providerMetadata: {
|
|
1987
|
+
xai: {
|
|
1988
|
+
...part.encrypted_content && {
|
|
1989
|
+
reasoningEncryptedContent: part.encrypted_content
|
|
1990
|
+
},
|
|
1991
|
+
...part.id && { itemId: part.id }
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1995
|
+
delete activeReasoning[part.id];
|
|
1996
|
+
}
|
|
1997
|
+
return;
|
|
1998
|
+
}
|
|
1935
1999
|
if (part.type === "web_search_call" || part.type === "x_search_call" || part.type === "code_interpreter_call" || part.type === "code_execution_call" || part.type === "view_image_call" || part.type === "view_x_video_call" || part.type === "custom_tool_call") {
|
|
1936
2000
|
const webSearchSubTools = [
|
|
1937
2001
|
"web_search",
|
|
@@ -2113,7 +2177,7 @@ var xaiTools = {
|
|
|
2113
2177
|
};
|
|
2114
2178
|
|
|
2115
2179
|
// src/version.ts
|
|
2116
|
-
var VERSION = true ? "2.0.
|
|
2180
|
+
var VERSION = true ? "2.0.52" : "0.0.0-test";
|
|
2117
2181
|
|
|
2118
2182
|
// src/xai-provider.ts
|
|
2119
2183
|
var xaiErrorStructure = {
|