@ai-sdk/xai 2.0.58 → 2.0.59
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 +10 -0
- package/dist/index.js +36 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 2.0.59
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 93fff75: Add support for `response.function_call_arguments.delta` and `response.function_call_arguments.done` streaming events in the xAI Responses API provider.
|
|
8
|
+
|
|
9
|
+
Previously, xAI Grok models using function tools via the Responses API would fail with `AI_TypeValidationError` because these standard Responses API events were missing from the Zod schema and stream handler. Function call arguments are now streamed incrementally via `tool-input-delta` events, and the final `tool-call` is emitted only after all arguments are received.
|
|
10
|
+
|
|
11
|
+
Includes unit test for function call argument streaming and an example at `examples/ai-core/src/stream-text/xai-responses-function-call.ts`.
|
|
12
|
+
|
|
3
13
|
## 2.0.58
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1156,6 +1156,19 @@ var xaiResponsesChunkSchema = import_v44.z.union([
|
|
|
1156
1156
|
output_index: import_v44.z.number(),
|
|
1157
1157
|
code: import_v44.z.string()
|
|
1158
1158
|
}),
|
|
1159
|
+
// Function call arguments streaming events (standard function tools)
|
|
1160
|
+
import_v44.z.object({
|
|
1161
|
+
type: import_v44.z.literal("response.function_call_arguments.delta"),
|
|
1162
|
+
item_id: import_v44.z.string(),
|
|
1163
|
+
output_index: import_v44.z.number(),
|
|
1164
|
+
delta: import_v44.z.string()
|
|
1165
|
+
}),
|
|
1166
|
+
import_v44.z.object({
|
|
1167
|
+
type: import_v44.z.literal("response.function_call_arguments.done"),
|
|
1168
|
+
item_id: import_v44.z.string(),
|
|
1169
|
+
output_index: import_v44.z.number(),
|
|
1170
|
+
arguments: import_v44.z.string()
|
|
1171
|
+
}),
|
|
1159
1172
|
import_v44.z.object({
|
|
1160
1173
|
type: import_v44.z.literal("response.done"),
|
|
1161
1174
|
response: xaiResponsesResponseSchema
|
|
@@ -1880,6 +1893,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1880
1893
|
let isFirstChunk = true;
|
|
1881
1894
|
const contentBlocks = {};
|
|
1882
1895
|
const seenToolCalls = /* @__PURE__ */ new Set();
|
|
1896
|
+
const ongoingToolCalls = {};
|
|
1883
1897
|
const activeReasoning = {};
|
|
1884
1898
|
const self = this;
|
|
1885
1899
|
return {
|
|
@@ -2025,6 +2039,20 @@ var XaiResponsesLanguageModel = class {
|
|
|
2025
2039
|
}
|
|
2026
2040
|
return;
|
|
2027
2041
|
}
|
|
2042
|
+
if (event.type === "response.function_call_arguments.delta") {
|
|
2043
|
+
const toolCall = ongoingToolCalls[event.output_index];
|
|
2044
|
+
if (toolCall != null) {
|
|
2045
|
+
controller.enqueue({
|
|
2046
|
+
type: "tool-input-delta",
|
|
2047
|
+
id: toolCall.toolCallId,
|
|
2048
|
+
delta: event.delta
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
return;
|
|
2052
|
+
}
|
|
2053
|
+
if (event.type === "response.function_call_arguments.done") {
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2028
2056
|
if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
|
|
2029
2057
|
const part = event.item;
|
|
2030
2058
|
if (part.type === "reasoning") {
|
|
@@ -2136,18 +2164,18 @@ var XaiResponsesLanguageModel = class {
|
|
|
2136
2164
|
}
|
|
2137
2165
|
}
|
|
2138
2166
|
} else if (part.type === "function_call") {
|
|
2139
|
-
if (
|
|
2140
|
-
|
|
2167
|
+
if (event.type === "response.output_item.added") {
|
|
2168
|
+
ongoingToolCalls[event.output_index] = {
|
|
2169
|
+
toolName: part.name,
|
|
2170
|
+
toolCallId: part.call_id
|
|
2171
|
+
};
|
|
2141
2172
|
controller.enqueue({
|
|
2142
2173
|
type: "tool-input-start",
|
|
2143
2174
|
id: part.call_id,
|
|
2144
2175
|
toolName: part.name
|
|
2145
2176
|
});
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
id: part.call_id,
|
|
2149
|
-
delta: part.arguments
|
|
2150
|
-
});
|
|
2177
|
+
} else if (event.type === "response.output_item.done") {
|
|
2178
|
+
ongoingToolCalls[event.output_index] = void 0;
|
|
2151
2179
|
controller.enqueue({
|
|
2152
2180
|
type: "tool-input-end",
|
|
2153
2181
|
id: part.call_id
|
|
@@ -2237,7 +2265,7 @@ var xaiTools = {
|
|
|
2237
2265
|
};
|
|
2238
2266
|
|
|
2239
2267
|
// src/version.ts
|
|
2240
|
-
var VERSION = true ? "2.0.
|
|
2268
|
+
var VERSION = true ? "2.0.59" : "0.0.0-test";
|
|
2241
2269
|
|
|
2242
2270
|
// src/xai-provider.ts
|
|
2243
2271
|
var xaiErrorStructure = {
|