@ai-sdk/xai 2.0.42 → 2.0.44
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 +16 -0
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 2.0.44
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 08bffe4: feat (provider/xai): include cached input token metrics in responses api usage
|
|
8
|
+
|
|
9
|
+
## 2.0.43
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 526fe8d: fix: trigger new release for `@ai-v5` dist-tag
|
|
14
|
+
- Updated dependencies [526fe8d]
|
|
15
|
+
- @ai-sdk/openai-compatible@1.0.30
|
|
16
|
+
- @ai-sdk/provider@2.0.1
|
|
17
|
+
- @ai-sdk/provider-utils@3.0.20
|
|
18
|
+
|
|
3
19
|
## 2.0.42
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1560,7 +1560,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1560
1560
|
};
|
|
1561
1561
|
}
|
|
1562
1562
|
async doGenerate(options) {
|
|
1563
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1563
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1564
1564
|
const {
|
|
1565
1565
|
args: body,
|
|
1566
1566
|
warnings,
|
|
@@ -1661,7 +1661,8 @@ var XaiResponsesLanguageModel = class {
|
|
|
1661
1661
|
inputTokens: response.usage.input_tokens,
|
|
1662
1662
|
outputTokens: response.usage.output_tokens,
|
|
1663
1663
|
totalTokens: response.usage.total_tokens,
|
|
1664
|
-
reasoningTokens: (_h = response.usage.output_tokens_details) == null ? void 0 : _h.reasoning_tokens
|
|
1664
|
+
reasoningTokens: (_h = response.usage.output_tokens_details) == null ? void 0 : _h.reasoning_tokens,
|
|
1665
|
+
cachedInputTokens: (_i = response.usage.input_tokens_details) == null ? void 0 : _i.cached_tokens
|
|
1665
1666
|
},
|
|
1666
1667
|
request: { body },
|
|
1667
1668
|
response: {
|
|
@@ -1713,7 +1714,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1713
1714
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1714
1715
|
},
|
|
1715
1716
|
transform(chunk, controller) {
|
|
1716
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1717
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1717
1718
|
if (options.includeRawChunks) {
|
|
1718
1719
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1719
1720
|
}
|
|
@@ -1804,9 +1805,10 @@ var XaiResponsesLanguageModel = class {
|
|
|
1804
1805
|
const response2 = event.response;
|
|
1805
1806
|
if (response2.usage) {
|
|
1806
1807
|
usage.inputTokens = response2.usage.input_tokens;
|
|
1808
|
+
usage.cachedInputTokens = (_c = response2.usage.input_tokens_details) == null ? void 0 : _c.cached_tokens;
|
|
1807
1809
|
usage.outputTokens = response2.usage.output_tokens;
|
|
1808
1810
|
usage.totalTokens = response2.usage.total_tokens;
|
|
1809
|
-
usage.reasoningTokens = (
|
|
1811
|
+
usage.reasoningTokens = (_d = response2.usage.output_tokens_details) == null ? void 0 : _d.reasoning_tokens;
|
|
1810
1812
|
}
|
|
1811
1813
|
if (response2.status) {
|
|
1812
1814
|
finishReason = mapXaiResponsesFinishReason(response2.status);
|
|
@@ -1829,15 +1831,15 @@ var XaiResponsesLanguageModel = class {
|
|
|
1829
1831
|
"x_semantic_search",
|
|
1830
1832
|
"x_thread_fetch"
|
|
1831
1833
|
];
|
|
1832
|
-
let toolName = (
|
|
1833
|
-
if (webSearchSubTools.includes((
|
|
1834
|
+
let toolName = (_e = part.name) != null ? _e : "";
|
|
1835
|
+
if (webSearchSubTools.includes((_f = part.name) != null ? _f : "")) {
|
|
1834
1836
|
toolName = webSearchToolName != null ? webSearchToolName : "web_search";
|
|
1835
|
-
} else if (xSearchSubTools.includes((
|
|
1837
|
+
} else if (xSearchSubTools.includes((_g = part.name) != null ? _g : "")) {
|
|
1836
1838
|
toolName = xSearchToolName != null ? xSearchToolName : "x_search";
|
|
1837
1839
|
} else if (part.name === "code_execution") {
|
|
1838
1840
|
toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
|
|
1839
1841
|
}
|
|
1840
|
-
const toolInput = part.type === "custom_tool_call" ? (
|
|
1842
|
+
const toolInput = part.type === "custom_tool_call" ? (_h = part.input) != null ? _h : "" : (_i = part.arguments) != null ? _i : "";
|
|
1841
1843
|
controller.enqueue({
|
|
1842
1844
|
type: "tool-input-start",
|
|
1843
1845
|
id: part.id,
|
|
@@ -1887,7 +1889,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1887
1889
|
sourceType: "url",
|
|
1888
1890
|
id: self.config.generateId(),
|
|
1889
1891
|
url: annotation.url,
|
|
1890
|
-
title: (
|
|
1892
|
+
title: (_j = annotation.title) != null ? _j : annotation.url
|
|
1891
1893
|
});
|
|
1892
1894
|
}
|
|
1893
1895
|
}
|
|
@@ -1995,7 +1997,7 @@ var xaiTools = {
|
|
|
1995
1997
|
};
|
|
1996
1998
|
|
|
1997
1999
|
// src/version.ts
|
|
1998
|
-
var VERSION = true ? "2.0.
|
|
2000
|
+
var VERSION = true ? "2.0.44" : "0.0.0-test";
|
|
1999
2001
|
|
|
2000
2002
|
// src/xai-provider.ts
|
|
2001
2003
|
var xaiErrorStructure = {
|