@ai-sdk/xai 3.0.13 → 3.0.15
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 +78 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1125,7 +1125,8 @@ var outputItemSchema = z4.discriminatedUnion("type", [
|
|
|
1125
1125
|
type: z4.literal("reasoning"),
|
|
1126
1126
|
id: z4.string(),
|
|
1127
1127
|
summary: z4.array(reasoningSummaryPartSchema),
|
|
1128
|
-
status: z4.string()
|
|
1128
|
+
status: z4.string(),
|
|
1129
|
+
encrypted_content: z4.string().nullish()
|
|
1129
1130
|
})
|
|
1130
1131
|
]);
|
|
1131
1132
|
var xaiResponsesUsageSchema = z4.object({
|
|
@@ -1635,11 +1636,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
1635
1636
|
topP,
|
|
1636
1637
|
stopSequences,
|
|
1637
1638
|
seed,
|
|
1639
|
+
responseFormat,
|
|
1638
1640
|
providerOptions,
|
|
1639
1641
|
tools,
|
|
1640
1642
|
toolChoice
|
|
1641
1643
|
}) {
|
|
1642
|
-
var _a, _b, _c, _d;
|
|
1644
|
+
var _a, _b, _c, _d, _e;
|
|
1643
1645
|
const warnings = [];
|
|
1644
1646
|
const options = (_a = await parseProviderOptions2({
|
|
1645
1647
|
provider: "xai",
|
|
@@ -1679,6 +1681,17 @@ var XaiResponsesLanguageModel = class {
|
|
|
1679
1681
|
temperature,
|
|
1680
1682
|
top_p: topP,
|
|
1681
1683
|
seed,
|
|
1684
|
+
...(responseFormat == null ? void 0 : responseFormat.type) === "json" && {
|
|
1685
|
+
text: {
|
|
1686
|
+
format: responseFormat.schema != null ? {
|
|
1687
|
+
type: "json_schema",
|
|
1688
|
+
strict: true,
|
|
1689
|
+
name: (_e = responseFormat.name) != null ? _e : "response",
|
|
1690
|
+
description: responseFormat.description,
|
|
1691
|
+
schema: responseFormat.schema
|
|
1692
|
+
} : { type: "json_object" }
|
|
1693
|
+
}
|
|
1694
|
+
},
|
|
1682
1695
|
...options.reasoningEffort != null && {
|
|
1683
1696
|
reasoning: { effort: options.reasoningEffort }
|
|
1684
1697
|
},
|
|
@@ -1794,6 +1807,32 @@ var XaiResponsesLanguageModel = class {
|
|
|
1794
1807
|
});
|
|
1795
1808
|
break;
|
|
1796
1809
|
}
|
|
1810
|
+
case "reasoning": {
|
|
1811
|
+
const summaryTexts = part.summary.map((s) => s.text).filter((text) => text && text.length > 0);
|
|
1812
|
+
if (summaryTexts.length > 0) {
|
|
1813
|
+
const reasoningText = summaryTexts.join("");
|
|
1814
|
+
if (part.encrypted_content || part.id) {
|
|
1815
|
+
content.push({
|
|
1816
|
+
type: "reasoning",
|
|
1817
|
+
text: reasoningText,
|
|
1818
|
+
providerMetadata: {
|
|
1819
|
+
xai: {
|
|
1820
|
+
...part.encrypted_content && {
|
|
1821
|
+
reasoningEncryptedContent: part.encrypted_content
|
|
1822
|
+
},
|
|
1823
|
+
...part.id && { itemId: part.id }
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
});
|
|
1827
|
+
} else {
|
|
1828
|
+
content.push({
|
|
1829
|
+
type: "reasoning",
|
|
1830
|
+
text: reasoningText
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
break;
|
|
1835
|
+
}
|
|
1797
1836
|
default: {
|
|
1798
1837
|
break;
|
|
1799
1838
|
}
|
|
@@ -1847,6 +1886,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1847
1886
|
let isFirstChunk = true;
|
|
1848
1887
|
const contentBlocks = {};
|
|
1849
1888
|
const seenToolCalls = /* @__PURE__ */ new Set();
|
|
1889
|
+
const activeReasoning = {};
|
|
1850
1890
|
const self = this;
|
|
1851
1891
|
return {
|
|
1852
1892
|
stream: response.pipeThrough(
|
|
@@ -1855,7 +1895,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1855
1895
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1856
1896
|
},
|
|
1857
1897
|
transform(chunk, controller) {
|
|
1858
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
1898
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1859
1899
|
if (options.includeRawChunks) {
|
|
1860
1900
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1861
1901
|
}
|
|
@@ -1878,7 +1918,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
1878
1918
|
const blockId = `reasoning-${event.item_id}`;
|
|
1879
1919
|
controller.enqueue({
|
|
1880
1920
|
type: "reasoning-start",
|
|
1881
|
-
id: blockId
|
|
1921
|
+
id: blockId,
|
|
1922
|
+
providerMetadata: {
|
|
1923
|
+
xai: {
|
|
1924
|
+
itemId: event.item_id
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1882
1927
|
});
|
|
1883
1928
|
}
|
|
1884
1929
|
if (event.type === "response.reasoning_summary_text.delta") {
|
|
@@ -1886,16 +1931,17 @@ var XaiResponsesLanguageModel = class {
|
|
|
1886
1931
|
controller.enqueue({
|
|
1887
1932
|
type: "reasoning-delta",
|
|
1888
1933
|
id: blockId,
|
|
1889
|
-
delta: event.delta
|
|
1934
|
+
delta: event.delta,
|
|
1935
|
+
providerMetadata: {
|
|
1936
|
+
xai: {
|
|
1937
|
+
itemId: event.item_id
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1890
1940
|
});
|
|
1891
1941
|
return;
|
|
1892
1942
|
}
|
|
1893
1943
|
if (event.type === "response.reasoning_summary_text.done") {
|
|
1894
|
-
|
|
1895
|
-
controller.enqueue({
|
|
1896
|
-
type: "reasoning-end",
|
|
1897
|
-
id: blockId
|
|
1898
|
-
});
|
|
1944
|
+
return;
|
|
1899
1945
|
}
|
|
1900
1946
|
if (event.type === "response.output_text.delta") {
|
|
1901
1947
|
const blockId = `text-${event.item_id}`;
|
|
@@ -1957,6 +2003,22 @@ var XaiResponsesLanguageModel = class {
|
|
|
1957
2003
|
}
|
|
1958
2004
|
if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
|
|
1959
2005
|
const part = event.item;
|
|
2006
|
+
if (part.type === "reasoning") {
|
|
2007
|
+
if (event.type === "response.output_item.done") {
|
|
2008
|
+
controller.enqueue({
|
|
2009
|
+
type: "reasoning-end",
|
|
2010
|
+
id: `reasoning-${part.id}`,
|
|
2011
|
+
providerMetadata: {
|
|
2012
|
+
xai: {
|
|
2013
|
+
itemId: part.id,
|
|
2014
|
+
reasoningEncryptedContent: (_c = part.encrypted_content) != null ? _c : null
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
});
|
|
2018
|
+
delete activeReasoning[part.id];
|
|
2019
|
+
}
|
|
2020
|
+
return;
|
|
2021
|
+
}
|
|
1960
2022
|
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") {
|
|
1961
2023
|
const webSearchSubTools = [
|
|
1962
2024
|
"web_search",
|
|
@@ -1969,15 +2031,15 @@ var XaiResponsesLanguageModel = class {
|
|
|
1969
2031
|
"x_semantic_search",
|
|
1970
2032
|
"x_thread_fetch"
|
|
1971
2033
|
];
|
|
1972
|
-
let toolName = (
|
|
1973
|
-
if (webSearchSubTools.includes((
|
|
2034
|
+
let toolName = (_d = part.name) != null ? _d : "";
|
|
2035
|
+
if (webSearchSubTools.includes((_e = part.name) != null ? _e : "") || part.type === "web_search_call") {
|
|
1974
2036
|
toolName = webSearchToolName != null ? webSearchToolName : "web_search";
|
|
1975
|
-
} else if (xSearchSubTools.includes((
|
|
2037
|
+
} else if (xSearchSubTools.includes((_f = part.name) != null ? _f : "") || part.type === "x_search_call") {
|
|
1976
2038
|
toolName = xSearchToolName != null ? xSearchToolName : "x_search";
|
|
1977
2039
|
} else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
|
|
1978
2040
|
toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
|
|
1979
2041
|
}
|
|
1980
|
-
const toolInput = part.type === "custom_tool_call" ? (
|
|
2042
|
+
const toolInput = part.type === "custom_tool_call" ? (_g = part.input) != null ? _g : "" : (_h = part.arguments) != null ? _h : "";
|
|
1981
2043
|
const shouldEmit = part.type === "custom_tool_call" ? event.type === "response.output_item.done" : !seenToolCalls.has(part.id);
|
|
1982
2044
|
if (shouldEmit && !seenToolCalls.has(part.id)) {
|
|
1983
2045
|
seenToolCalls.add(part.id);
|
|
@@ -2030,7 +2092,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2030
2092
|
sourceType: "url",
|
|
2031
2093
|
id: self.config.generateId(),
|
|
2032
2094
|
url: annotation.url,
|
|
2033
|
-
title: (
|
|
2095
|
+
title: (_i = annotation.title) != null ? _i : annotation.url
|
|
2034
2096
|
});
|
|
2035
2097
|
}
|
|
2036
2098
|
}
|
|
@@ -2135,7 +2197,7 @@ var xaiTools = {
|
|
|
2135
2197
|
};
|
|
2136
2198
|
|
|
2137
2199
|
// src/version.ts
|
|
2138
|
-
var VERSION = true ? "3.0.
|
|
2200
|
+
var VERSION = true ? "3.0.15" : "0.0.0-test";
|
|
2139
2201
|
|
|
2140
2202
|
// src/xai-provider.ts
|
|
2141
2203
|
var xaiErrorStructure = {
|