@ai-sdk/xai 2.0.0-alpha.9 → 2.0.0-beta.1
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 +83 -0
- package/dist/index.js +156 -124
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -122
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [742b7be]
|
|
8
|
+
- Updated dependencies [7cddb72]
|
|
9
|
+
- Updated dependencies [ccce59b]
|
|
10
|
+
- Updated dependencies [e2b9e4b]
|
|
11
|
+
- Updated dependencies [45c1ea2]
|
|
12
|
+
- Updated dependencies [e025824]
|
|
13
|
+
- Updated dependencies [0d06df6]
|
|
14
|
+
- Updated dependencies [472524a]
|
|
15
|
+
- Updated dependencies [dd3ff01]
|
|
16
|
+
- Updated dependencies [7435eb5]
|
|
17
|
+
- Updated dependencies [cb68df0]
|
|
18
|
+
- Updated dependencies [bfdca8d]
|
|
19
|
+
- Updated dependencies [44f4aba]
|
|
20
|
+
- Updated dependencies [023ba40]
|
|
21
|
+
- Updated dependencies [5e57fae]
|
|
22
|
+
- Updated dependencies [71f938d]
|
|
23
|
+
- Updated dependencies [28a5ed5]
|
|
24
|
+
- @ai-sdk/provider@2.0.0-beta.1
|
|
25
|
+
- @ai-sdk/provider-utils@3.0.0-beta.1
|
|
26
|
+
- @ai-sdk/openai-compatible@1.0.0-beta.1
|
|
27
|
+
|
|
28
|
+
## 2.0.0-alpha.15
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [48d257a]
|
|
33
|
+
- Updated dependencies [8ba77a7]
|
|
34
|
+
- @ai-sdk/provider@2.0.0-alpha.15
|
|
35
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.15
|
|
36
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.15
|
|
37
|
+
|
|
38
|
+
## 2.0.0-alpha.14
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [b5da06a]
|
|
43
|
+
- Updated dependencies [63f9e9b]
|
|
44
|
+
- Updated dependencies [2e13791]
|
|
45
|
+
- @ai-sdk/provider@2.0.0-alpha.14
|
|
46
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.14
|
|
47
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.14
|
|
48
|
+
|
|
49
|
+
## 2.0.0-alpha.13
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [68ecf2f]
|
|
54
|
+
- @ai-sdk/provider@2.0.0-alpha.13
|
|
55
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.13
|
|
56
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.13
|
|
57
|
+
|
|
58
|
+
## 2.0.0-alpha.12
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- e2aceaf: feat: add raw chunk support
|
|
63
|
+
- Updated dependencies [e2aceaf]
|
|
64
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.12
|
|
65
|
+
- @ai-sdk/provider@2.0.0-alpha.12
|
|
66
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.12
|
|
67
|
+
|
|
68
|
+
## 2.0.0-alpha.11
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- Updated dependencies [c1e6647]
|
|
73
|
+
- @ai-sdk/provider@2.0.0-alpha.11
|
|
74
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.11
|
|
75
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.11
|
|
76
|
+
|
|
77
|
+
## 2.0.0-alpha.10
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- Updated dependencies [c4df419]
|
|
82
|
+
- @ai-sdk/provider@2.0.0-alpha.10
|
|
83
|
+
- @ai-sdk/openai-compatible@1.0.0-alpha.10
|
|
84
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.10
|
|
85
|
+
|
|
3
86
|
## 2.0.0-alpha.9
|
|
4
87
|
|
|
5
88
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -30,117 +30,13 @@ var import_openai_compatible = require("@ai-sdk/openai-compatible");
|
|
|
30
30
|
var import_provider3 = require("@ai-sdk/provider");
|
|
31
31
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
32
32
|
|
|
33
|
-
// src/xai-chat-options.ts
|
|
34
|
-
var import_zod = require("zod");
|
|
35
|
-
function supportsStructuredOutputs(modelId) {
|
|
36
|
-
return [
|
|
37
|
-
"grok-3",
|
|
38
|
-
"grok-3-beta",
|
|
39
|
-
"grok-3-latest",
|
|
40
|
-
"grok-3-fast",
|
|
41
|
-
"grok-3-fast-beta",
|
|
42
|
-
"grok-3-fast-latest",
|
|
43
|
-
"grok-3-mini",
|
|
44
|
-
"grok-3-mini-beta",
|
|
45
|
-
"grok-3-mini-latest",
|
|
46
|
-
"grok-3-mini-fast",
|
|
47
|
-
"grok-3-mini-fast-beta",
|
|
48
|
-
"grok-3-mini-fast-latest",
|
|
49
|
-
"grok-2-1212",
|
|
50
|
-
"grok-2-vision-1212"
|
|
51
|
-
].includes(modelId);
|
|
52
|
-
}
|
|
53
|
-
var webSourceSchema = import_zod.z.object({
|
|
54
|
-
type: import_zod.z.literal("web"),
|
|
55
|
-
country: import_zod.z.string().length(2).optional(),
|
|
56
|
-
excludedWebsites: import_zod.z.array(import_zod.z.string()).max(5).optional(),
|
|
57
|
-
allowedWebsites: import_zod.z.array(import_zod.z.string()).max(5).optional(),
|
|
58
|
-
safeSearch: import_zod.z.boolean().optional()
|
|
59
|
-
});
|
|
60
|
-
var xSourceSchema = import_zod.z.object({
|
|
61
|
-
type: import_zod.z.literal("x"),
|
|
62
|
-
xHandles: import_zod.z.array(import_zod.z.string()).optional()
|
|
63
|
-
});
|
|
64
|
-
var newsSourceSchema = import_zod.z.object({
|
|
65
|
-
type: import_zod.z.literal("news"),
|
|
66
|
-
country: import_zod.z.string().length(2).optional(),
|
|
67
|
-
excludedWebsites: import_zod.z.array(import_zod.z.string()).max(5).optional(),
|
|
68
|
-
safeSearch: import_zod.z.boolean().optional()
|
|
69
|
-
});
|
|
70
|
-
var rssSourceSchema = import_zod.z.object({
|
|
71
|
-
type: import_zod.z.literal("rss"),
|
|
72
|
-
links: import_zod.z.array(import_zod.z.string().url()).max(1)
|
|
73
|
-
// currently only supports one RSS link
|
|
74
|
-
});
|
|
75
|
-
var searchSourceSchema = import_zod.z.discriminatedUnion("type", [
|
|
76
|
-
webSourceSchema,
|
|
77
|
-
xSourceSchema,
|
|
78
|
-
newsSourceSchema,
|
|
79
|
-
rssSourceSchema
|
|
80
|
-
]);
|
|
81
|
-
var xaiProviderOptions = import_zod.z.object({
|
|
82
|
-
/**
|
|
83
|
-
* reasoning effort for reasoning models
|
|
84
|
-
* only supported by grok-3-mini and grok-3-mini-fast models
|
|
85
|
-
*/
|
|
86
|
-
reasoningEffort: import_zod.z.enum(["low", "high"]).optional(),
|
|
87
|
-
searchParameters: import_zod.z.object({
|
|
88
|
-
/**
|
|
89
|
-
* search mode preference
|
|
90
|
-
* - "off": disables search completely
|
|
91
|
-
* - "auto": model decides whether to search (default)
|
|
92
|
-
* - "on": always enables search
|
|
93
|
-
*/
|
|
94
|
-
mode: import_zod.z.enum(["off", "auto", "on"]),
|
|
95
|
-
/**
|
|
96
|
-
* whether to return citations in the response
|
|
97
|
-
* defaults to true
|
|
98
|
-
*/
|
|
99
|
-
returnCitations: import_zod.z.boolean().optional(),
|
|
100
|
-
/**
|
|
101
|
-
* start date for search data (ISO8601 format: YYYY-MM-DD)
|
|
102
|
-
*/
|
|
103
|
-
fromDate: import_zod.z.string().optional(),
|
|
104
|
-
/**
|
|
105
|
-
* end date for search data (ISO8601 format: YYYY-MM-DD)
|
|
106
|
-
*/
|
|
107
|
-
toDate: import_zod.z.string().optional(),
|
|
108
|
-
/**
|
|
109
|
-
* maximum number of search results to consider
|
|
110
|
-
* defaults to 20
|
|
111
|
-
*/
|
|
112
|
-
maxSearchResults: import_zod.z.number().min(1).max(50).optional(),
|
|
113
|
-
/**
|
|
114
|
-
* data sources to search from
|
|
115
|
-
* defaults to ["web", "x"] if not specified
|
|
116
|
-
*/
|
|
117
|
-
sources: import_zod.z.array(searchSourceSchema).optional()
|
|
118
|
-
}).optional()
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// src/xai-error.ts
|
|
122
|
-
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
123
|
-
var import_zod2 = require("zod");
|
|
124
|
-
var xaiErrorDataSchema = import_zod2.z.object({
|
|
125
|
-
error: import_zod2.z.object({
|
|
126
|
-
message: import_zod2.z.string(),
|
|
127
|
-
type: import_zod2.z.string().nullish(),
|
|
128
|
-
param: import_zod2.z.any().nullish(),
|
|
129
|
-
code: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]).nullish()
|
|
130
|
-
})
|
|
131
|
-
});
|
|
132
|
-
var xaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
133
|
-
errorSchema: xaiErrorDataSchema,
|
|
134
|
-
errorToMessage: (data) => data.error.message
|
|
135
|
-
});
|
|
136
|
-
|
|
137
33
|
// src/xai-chat-language-model.ts
|
|
138
34
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
139
35
|
var import_zod3 = require("zod");
|
|
140
36
|
|
|
141
37
|
// src/convert-to-xai-chat-messages.ts
|
|
142
38
|
var import_provider = require("@ai-sdk/provider");
|
|
143
|
-
var
|
|
39
|
+
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
144
40
|
function convertToXaiChatMessages(prompt) {
|
|
145
41
|
const messages = [];
|
|
146
42
|
const warnings = [];
|
|
@@ -168,7 +64,7 @@ function convertToXaiChatMessages(prompt) {
|
|
|
168
64
|
return {
|
|
169
65
|
type: "image_url",
|
|
170
66
|
image_url: {
|
|
171
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0,
|
|
67
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils.convertToBase64)(part.data)}`
|
|
172
68
|
}
|
|
173
69
|
};
|
|
174
70
|
} else {
|
|
@@ -197,7 +93,7 @@ function convertToXaiChatMessages(prompt) {
|
|
|
197
93
|
type: "function",
|
|
198
94
|
function: {
|
|
199
95
|
name: part.toolName,
|
|
200
|
-
arguments: JSON.stringify(part.
|
|
96
|
+
arguments: JSON.stringify(part.input)
|
|
201
97
|
}
|
|
202
98
|
});
|
|
203
99
|
break;
|
|
@@ -213,10 +109,23 @@ function convertToXaiChatMessages(prompt) {
|
|
|
213
109
|
}
|
|
214
110
|
case "tool": {
|
|
215
111
|
for (const toolResponse of content) {
|
|
112
|
+
const output = toolResponse.output;
|
|
113
|
+
let contentValue;
|
|
114
|
+
switch (output.type) {
|
|
115
|
+
case "text":
|
|
116
|
+
case "error-text":
|
|
117
|
+
contentValue = output.value;
|
|
118
|
+
break;
|
|
119
|
+
case "content":
|
|
120
|
+
case "json":
|
|
121
|
+
case "error-json":
|
|
122
|
+
contentValue = JSON.stringify(output.value);
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
216
125
|
messages.push({
|
|
217
126
|
role: "tool",
|
|
218
127
|
tool_call_id: toolResponse.toolCallId,
|
|
219
|
-
content:
|
|
128
|
+
content: contentValue
|
|
220
129
|
});
|
|
221
130
|
}
|
|
222
131
|
break;
|
|
@@ -260,6 +169,92 @@ function mapXaiFinishReason(finishReason) {
|
|
|
260
169
|
}
|
|
261
170
|
}
|
|
262
171
|
|
|
172
|
+
// src/xai-chat-options.ts
|
|
173
|
+
var import_zod = require("zod");
|
|
174
|
+
var webSourceSchema = import_zod.z.object({
|
|
175
|
+
type: import_zod.z.literal("web"),
|
|
176
|
+
country: import_zod.z.string().length(2).optional(),
|
|
177
|
+
excludedWebsites: import_zod.z.array(import_zod.z.string()).max(5).optional(),
|
|
178
|
+
allowedWebsites: import_zod.z.array(import_zod.z.string()).max(5).optional(),
|
|
179
|
+
safeSearch: import_zod.z.boolean().optional()
|
|
180
|
+
});
|
|
181
|
+
var xSourceSchema = import_zod.z.object({
|
|
182
|
+
type: import_zod.z.literal("x"),
|
|
183
|
+
xHandles: import_zod.z.array(import_zod.z.string()).optional()
|
|
184
|
+
});
|
|
185
|
+
var newsSourceSchema = import_zod.z.object({
|
|
186
|
+
type: import_zod.z.literal("news"),
|
|
187
|
+
country: import_zod.z.string().length(2).optional(),
|
|
188
|
+
excludedWebsites: import_zod.z.array(import_zod.z.string()).max(5).optional(),
|
|
189
|
+
safeSearch: import_zod.z.boolean().optional()
|
|
190
|
+
});
|
|
191
|
+
var rssSourceSchema = import_zod.z.object({
|
|
192
|
+
type: import_zod.z.literal("rss"),
|
|
193
|
+
links: import_zod.z.array(import_zod.z.string().url()).max(1)
|
|
194
|
+
// currently only supports one RSS link
|
|
195
|
+
});
|
|
196
|
+
var searchSourceSchema = import_zod.z.discriminatedUnion("type", [
|
|
197
|
+
webSourceSchema,
|
|
198
|
+
xSourceSchema,
|
|
199
|
+
newsSourceSchema,
|
|
200
|
+
rssSourceSchema
|
|
201
|
+
]);
|
|
202
|
+
var xaiProviderOptions = import_zod.z.object({
|
|
203
|
+
/**
|
|
204
|
+
* reasoning effort for reasoning models
|
|
205
|
+
* only supported by grok-3-mini and grok-3-mini-fast models
|
|
206
|
+
*/
|
|
207
|
+
reasoningEffort: import_zod.z.enum(["low", "high"]).optional(),
|
|
208
|
+
searchParameters: import_zod.z.object({
|
|
209
|
+
/**
|
|
210
|
+
* search mode preference
|
|
211
|
+
* - "off": disables search completely
|
|
212
|
+
* - "auto": model decides whether to search (default)
|
|
213
|
+
* - "on": always enables search
|
|
214
|
+
*/
|
|
215
|
+
mode: import_zod.z.enum(["off", "auto", "on"]),
|
|
216
|
+
/**
|
|
217
|
+
* whether to return citations in the response
|
|
218
|
+
* defaults to true
|
|
219
|
+
*/
|
|
220
|
+
returnCitations: import_zod.z.boolean().optional(),
|
|
221
|
+
/**
|
|
222
|
+
* start date for search data (ISO8601 format: YYYY-MM-DD)
|
|
223
|
+
*/
|
|
224
|
+
fromDate: import_zod.z.string().optional(),
|
|
225
|
+
/**
|
|
226
|
+
* end date for search data (ISO8601 format: YYYY-MM-DD)
|
|
227
|
+
*/
|
|
228
|
+
toDate: import_zod.z.string().optional(),
|
|
229
|
+
/**
|
|
230
|
+
* maximum number of search results to consider
|
|
231
|
+
* defaults to 20
|
|
232
|
+
*/
|
|
233
|
+
maxSearchResults: import_zod.z.number().min(1).max(50).optional(),
|
|
234
|
+
/**
|
|
235
|
+
* data sources to search from
|
|
236
|
+
* defaults to ["web", "x"] if not specified
|
|
237
|
+
*/
|
|
238
|
+
sources: import_zod.z.array(searchSourceSchema).optional()
|
|
239
|
+
}).optional()
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// src/xai-error.ts
|
|
243
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
244
|
+
var import_zod2 = require("zod");
|
|
245
|
+
var xaiErrorDataSchema = import_zod2.z.object({
|
|
246
|
+
error: import_zod2.z.object({
|
|
247
|
+
message: import_zod2.z.string(),
|
|
248
|
+
type: import_zod2.z.string().nullish(),
|
|
249
|
+
param: import_zod2.z.any().nullish(),
|
|
250
|
+
code: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]).nullish()
|
|
251
|
+
})
|
|
252
|
+
});
|
|
253
|
+
var xaiFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
|
|
254
|
+
errorSchema: xaiErrorDataSchema,
|
|
255
|
+
errorToMessage: (data) => data.error.message
|
|
256
|
+
});
|
|
257
|
+
|
|
263
258
|
// src/xai-prepare-tools.ts
|
|
264
259
|
var import_provider2 = require("@ai-sdk/provider");
|
|
265
260
|
function prepareTools({
|
|
@@ -281,7 +276,7 @@ function prepareTools({
|
|
|
281
276
|
function: {
|
|
282
277
|
name: tool.name,
|
|
283
278
|
description: tool.description,
|
|
284
|
-
parameters: tool.
|
|
279
|
+
parameters: tool.inputSchema
|
|
285
280
|
}
|
|
286
281
|
});
|
|
287
282
|
}
|
|
@@ -488,10 +483,9 @@ var XaiChatLanguageModel = class {
|
|
|
488
483
|
for (const toolCall of choice.message.tool_calls) {
|
|
489
484
|
content.push({
|
|
490
485
|
type: "tool-call",
|
|
491
|
-
toolCallType: "function",
|
|
492
486
|
toolCallId: toolCall.id,
|
|
493
487
|
toolName: toolCall.function.name,
|
|
494
|
-
|
|
488
|
+
input: toolCall.function.arguments
|
|
495
489
|
});
|
|
496
490
|
}
|
|
497
491
|
}
|
|
@@ -549,6 +543,7 @@ var XaiChatLanguageModel = class {
|
|
|
549
543
|
totalTokens: void 0
|
|
550
544
|
};
|
|
551
545
|
let isFirstChunk = true;
|
|
546
|
+
const contentBlocks = {};
|
|
552
547
|
const self = this;
|
|
553
548
|
return {
|
|
554
549
|
stream: response.pipeThrough(
|
|
@@ -558,6 +553,9 @@ var XaiChatLanguageModel = class {
|
|
|
558
553
|
},
|
|
559
554
|
transform(chunk, controller) {
|
|
560
555
|
var _a2, _b;
|
|
556
|
+
if (options.includeRawChunks) {
|
|
557
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
558
|
+
}
|
|
561
559
|
if (!chunk.success) {
|
|
562
560
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
563
561
|
return;
|
|
@@ -594,40 +592,75 @@ var XaiChatLanguageModel = class {
|
|
|
594
592
|
return;
|
|
595
593
|
}
|
|
596
594
|
const delta = choice.delta;
|
|
595
|
+
const choiceIndex = choice.index;
|
|
597
596
|
if (delta.content != null && delta.content.length > 0) {
|
|
598
|
-
|
|
597
|
+
const textContent = delta.content;
|
|
599
598
|
const lastMessage = body.messages[body.messages.length - 1];
|
|
600
599
|
if ((lastMessage == null ? void 0 : lastMessage.role) === "assistant" && textContent === lastMessage.content) {
|
|
601
600
|
return;
|
|
602
601
|
}
|
|
603
|
-
|
|
602
|
+
const blockId = `text-${value.id || choiceIndex}`;
|
|
603
|
+
if (contentBlocks[blockId] == null) {
|
|
604
|
+
contentBlocks[blockId] = { type: "text" };
|
|
605
|
+
controller.enqueue({
|
|
606
|
+
type: "text-start",
|
|
607
|
+
id: blockId
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
controller.enqueue({
|
|
611
|
+
type: "text-delta",
|
|
612
|
+
id: blockId,
|
|
613
|
+
delta: textContent
|
|
614
|
+
});
|
|
604
615
|
}
|
|
605
616
|
if (delta.reasoning_content != null && delta.reasoning_content.length > 0) {
|
|
617
|
+
const blockId = `reasoning-${value.id || choiceIndex}`;
|
|
618
|
+
if (contentBlocks[blockId] == null) {
|
|
619
|
+
contentBlocks[blockId] = { type: "reasoning" };
|
|
620
|
+
controller.enqueue({
|
|
621
|
+
type: "reasoning-start",
|
|
622
|
+
id: blockId
|
|
623
|
+
});
|
|
624
|
+
}
|
|
606
625
|
controller.enqueue({
|
|
607
|
-
type: "reasoning",
|
|
608
|
-
|
|
626
|
+
type: "reasoning-delta",
|
|
627
|
+
id: blockId,
|
|
628
|
+
delta: delta.reasoning_content
|
|
609
629
|
});
|
|
610
630
|
}
|
|
611
631
|
if (delta.tool_calls != null) {
|
|
612
632
|
for (const toolCall of delta.tool_calls) {
|
|
633
|
+
const toolCallId = toolCall.id;
|
|
613
634
|
controller.enqueue({
|
|
614
|
-
type: "tool-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
635
|
+
type: "tool-input-start",
|
|
636
|
+
id: toolCallId,
|
|
637
|
+
toolName: toolCall.function.name
|
|
638
|
+
});
|
|
639
|
+
controller.enqueue({
|
|
640
|
+
type: "tool-input-delta",
|
|
641
|
+
id: toolCallId,
|
|
642
|
+
delta: toolCall.function.arguments
|
|
643
|
+
});
|
|
644
|
+
controller.enqueue({
|
|
645
|
+
type: "tool-input-end",
|
|
646
|
+
id: toolCallId
|
|
619
647
|
});
|
|
620
648
|
controller.enqueue({
|
|
621
649
|
type: "tool-call",
|
|
622
|
-
|
|
623
|
-
toolCallId: toolCall.id,
|
|
650
|
+
toolCallId,
|
|
624
651
|
toolName: toolCall.function.name,
|
|
625
|
-
|
|
652
|
+
input: toolCall.function.arguments
|
|
626
653
|
});
|
|
627
654
|
}
|
|
628
655
|
}
|
|
629
656
|
},
|
|
630
657
|
flush(controller) {
|
|
658
|
+
for (const [blockId, block] of Object.entries(contentBlocks)) {
|
|
659
|
+
controller.enqueue({
|
|
660
|
+
type: block.type === "text" ? "text-end" : "reasoning-end",
|
|
661
|
+
id: blockId
|
|
662
|
+
});
|
|
663
|
+
}
|
|
631
664
|
controller.enqueue({ type: "finish", finishReason, usage });
|
|
632
665
|
}
|
|
633
666
|
})
|
|
@@ -722,7 +755,6 @@ function createXai(options = {}) {
|
|
|
722
755
|
...options.headers
|
|
723
756
|
});
|
|
724
757
|
const createLanguageModel = (modelId) => {
|
|
725
|
-
const structuredOutputs = supportsStructuredOutputs(modelId);
|
|
726
758
|
return new XaiChatLanguageModel(modelId, {
|
|
727
759
|
provider: "xai.chat",
|
|
728
760
|
baseURL,
|