ai 5.0.0-beta.32 → 5.0.0-beta.34
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 +24 -0
- package/dist/index.d.mts +85 -6
- package/dist/index.d.ts +85 -6
- package/dist/index.js +281 -186
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +242 -151
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -1
- package/dist/internal/index.d.ts +2 -1
- package/dist/internal/index.js +34 -16
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +34 -16
- package/dist/internal/index.mjs.map +1 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test/index.mjs.map +1 -1
- package/package.json +18 -9
- package/dist/bin/ai.min.js +0 -126
package/dist/index.js
CHANGED
@@ -56,7 +56,7 @@ __export(src_exports, {
|
|
56
56
|
UI_MESSAGE_STREAM_HEADERS: () => UI_MESSAGE_STREAM_HEADERS,
|
57
57
|
UnsupportedFunctionalityError: () => import_provider18.UnsupportedFunctionalityError,
|
58
58
|
UnsupportedModelVersionError: () => UnsupportedModelVersionError,
|
59
|
-
asSchema: () =>
|
59
|
+
asSchema: () => import_provider_utils28.asSchema,
|
60
60
|
assistantModelMessageSchema: () => assistantModelMessageSchema,
|
61
61
|
callCompletionApi: () => callCompletionApi,
|
62
62
|
consumeStream: () => consumeStream,
|
@@ -69,14 +69,14 @@ __export(src_exports, {
|
|
69
69
|
coreToolMessageSchema: () => coreToolMessageSchema,
|
70
70
|
coreUserMessageSchema: () => coreUserMessageSchema,
|
71
71
|
cosineSimilarity: () => cosineSimilarity,
|
72
|
-
createIdGenerator: () =>
|
72
|
+
createIdGenerator: () => import_provider_utils28.createIdGenerator,
|
73
73
|
createProviderRegistry: () => createProviderRegistry,
|
74
74
|
createTextStreamResponse: () => createTextStreamResponse,
|
75
75
|
createUIMessageStream: () => createUIMessageStream,
|
76
76
|
createUIMessageStreamResponse: () => createUIMessageStreamResponse,
|
77
77
|
customProvider: () => customProvider,
|
78
78
|
defaultSettingsMiddleware: () => defaultSettingsMiddleware,
|
79
|
-
dynamicTool: () =>
|
79
|
+
dynamicTool: () => import_provider_utils28.dynamicTool,
|
80
80
|
embed: () => embed,
|
81
81
|
embedMany: () => embedMany,
|
82
82
|
experimental_createMCPClient: () => createMCPClient,
|
@@ -86,7 +86,7 @@ __export(src_exports, {
|
|
86
86
|
experimental_generateSpeech: () => generateSpeech,
|
87
87
|
experimental_transcribe: () => transcribe,
|
88
88
|
extractReasoningMiddleware: () => extractReasoningMiddleware,
|
89
|
-
generateId: () =>
|
89
|
+
generateId: () => import_provider_utils28.generateId,
|
90
90
|
generateObject: () => generateObject,
|
91
91
|
generateText: () => generateText,
|
92
92
|
getTextFromDataUrl: () => getTextFromDataUrl,
|
@@ -94,7 +94,7 @@ __export(src_exports, {
|
|
94
94
|
hasToolCall: () => hasToolCall,
|
95
95
|
isDeepEqualData: () => isDeepEqualData,
|
96
96
|
isToolUIPart: () => isToolUIPart,
|
97
|
-
jsonSchema: () =>
|
97
|
+
jsonSchema: () => import_provider_utils28.jsonSchema,
|
98
98
|
lastAssistantMessageIsCompleteWithToolCalls: () => lastAssistantMessageIsCompleteWithToolCalls,
|
99
99
|
modelMessageSchema: () => modelMessageSchema,
|
100
100
|
parsePartialJson: () => parsePartialJson,
|
@@ -108,15 +108,15 @@ __export(src_exports, {
|
|
108
108
|
streamObject: () => streamObject,
|
109
109
|
streamText: () => streamText,
|
110
110
|
systemModelMessageSchema: () => systemModelMessageSchema,
|
111
|
-
tool: () =>
|
111
|
+
tool: () => import_provider_utils28.tool,
|
112
112
|
toolModelMessageSchema: () => toolModelMessageSchema,
|
113
113
|
userModelMessageSchema: () => userModelMessageSchema,
|
114
114
|
wrapLanguageModel: () => wrapLanguageModel,
|
115
115
|
wrapProvider: () => wrapProvider,
|
116
|
-
zodSchema: () =>
|
116
|
+
zodSchema: () => import_provider_utils28.zodSchema
|
117
117
|
});
|
118
118
|
module.exports = __toCommonJS(src_exports);
|
119
|
-
var
|
119
|
+
var import_provider_utils28 = require("@ai-sdk/provider-utils");
|
120
120
|
|
121
121
|
// src/generate-text/generate-text.ts
|
122
122
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
@@ -199,45 +199,51 @@ var RetryError = class extends import_provider3.AISDKError {
|
|
199
199
|
_a3 = symbol3;
|
200
200
|
|
201
201
|
// src/util/retry-with-exponential-backoff.ts
|
202
|
-
function
|
202
|
+
function getRetryDelayInMs({
|
203
|
+
error,
|
204
|
+
exponentialBackoffDelay
|
205
|
+
}) {
|
203
206
|
const headers = error.responseHeaders;
|
204
207
|
if (!headers)
|
205
208
|
return exponentialBackoffDelay;
|
206
|
-
let
|
209
|
+
let ms;
|
207
210
|
const retryAfterMs = headers["retry-after-ms"];
|
208
211
|
if (retryAfterMs) {
|
209
212
|
const timeoutMs = parseFloat(retryAfterMs);
|
210
213
|
if (!Number.isNaN(timeoutMs)) {
|
211
|
-
|
214
|
+
ms = timeoutMs;
|
212
215
|
}
|
213
216
|
}
|
214
217
|
const retryAfter = headers["retry-after"];
|
215
|
-
if (retryAfter &&
|
218
|
+
if (retryAfter && ms === void 0) {
|
216
219
|
const timeoutSeconds = parseFloat(retryAfter);
|
217
220
|
if (!Number.isNaN(timeoutSeconds)) {
|
218
|
-
|
221
|
+
ms = timeoutSeconds * 1e3;
|
219
222
|
} else {
|
220
|
-
|
223
|
+
ms = Date.parse(retryAfter) - Date.now();
|
221
224
|
}
|
222
225
|
}
|
223
|
-
if (
|
224
|
-
return
|
226
|
+
if (ms != null && !Number.isNaN(ms) && 0 <= ms && (ms < 60 * 1e3 || ms < exponentialBackoffDelay)) {
|
227
|
+
return ms;
|
225
228
|
}
|
226
229
|
return exponentialBackoffDelay;
|
227
230
|
}
|
228
231
|
var retryWithExponentialBackoffRespectingRetryHeaders = ({
|
229
232
|
maxRetries = 2,
|
230
233
|
initialDelayInMs = 2e3,
|
231
|
-
backoffFactor = 2
|
234
|
+
backoffFactor = 2,
|
235
|
+
abortSignal
|
232
236
|
} = {}) => async (f) => _retryWithExponentialBackoff(f, {
|
233
237
|
maxRetries,
|
234
238
|
delayInMs: initialDelayInMs,
|
235
|
-
backoffFactor
|
239
|
+
backoffFactor,
|
240
|
+
abortSignal
|
236
241
|
});
|
237
242
|
async function _retryWithExponentialBackoff(f, {
|
238
243
|
maxRetries,
|
239
244
|
delayInMs,
|
240
|
-
backoffFactor
|
245
|
+
backoffFactor,
|
246
|
+
abortSignal
|
241
247
|
}, errors = []) {
|
242
248
|
try {
|
243
249
|
return await f();
|
@@ -259,11 +265,21 @@ async function _retryWithExponentialBackoff(f, {
|
|
259
265
|
});
|
260
266
|
}
|
261
267
|
if (error instanceof Error && import_provider4.APICallError.isInstance(error) && error.isRetryable === true && tryNumber <= maxRetries) {
|
262
|
-
|
263
|
-
|
268
|
+
await (0, import_provider_utils.delay)(
|
269
|
+
getRetryDelayInMs({
|
270
|
+
error,
|
271
|
+
exponentialBackoffDelay: delayInMs
|
272
|
+
}),
|
273
|
+
{ abortSignal }
|
274
|
+
);
|
264
275
|
return _retryWithExponentialBackoff(
|
265
276
|
f,
|
266
|
-
{
|
277
|
+
{
|
278
|
+
maxRetries,
|
279
|
+
delayInMs: backoffFactor * delayInMs,
|
280
|
+
backoffFactor,
|
281
|
+
abortSignal
|
282
|
+
},
|
267
283
|
newErrors
|
268
284
|
);
|
269
285
|
}
|
@@ -280,7 +296,8 @@ async function _retryWithExponentialBackoff(f, {
|
|
280
296
|
|
281
297
|
// src/util/prepare-retries.ts
|
282
298
|
function prepareRetries({
|
283
|
-
maxRetries
|
299
|
+
maxRetries,
|
300
|
+
abortSignal
|
284
301
|
}) {
|
285
302
|
if (maxRetries != null) {
|
286
303
|
if (!Number.isInteger(maxRetries)) {
|
@@ -302,7 +319,8 @@ function prepareRetries({
|
|
302
319
|
return {
|
303
320
|
maxRetries: maxRetriesResult,
|
304
321
|
retry: retryWithExponentialBackoffRespectingRetryHeaders({
|
305
|
-
maxRetries: maxRetriesResult
|
322
|
+
maxRetries: maxRetriesResult,
|
323
|
+
abortSignal
|
306
324
|
})
|
307
325
|
};
|
308
326
|
}
|
@@ -1895,12 +1913,15 @@ function createToolModelOutput({
|
|
1895
1913
|
if (errorMode === "text") {
|
1896
1914
|
return { type: "error-text", value: (0, import_provider21.getErrorMessage)(output) };
|
1897
1915
|
} else if (errorMode === "json") {
|
1898
|
-
return { type: "error-json", value: output };
|
1916
|
+
return { type: "error-json", value: toJSONValue(output) };
|
1899
1917
|
}
|
1900
1918
|
if (tool3 == null ? void 0 : tool3.toModelOutput) {
|
1901
1919
|
return tool3.toModelOutput(output);
|
1902
1920
|
}
|
1903
|
-
return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: output };
|
1921
|
+
return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: toJSONValue(output) };
|
1922
|
+
}
|
1923
|
+
function toJSONValue(value) {
|
1924
|
+
return value === void 0 ? null : value;
|
1904
1925
|
}
|
1905
1926
|
|
1906
1927
|
// src/generate-text/to-response-messages.ts
|
@@ -2026,7 +2047,10 @@ async function generateText({
|
|
2026
2047
|
}) {
|
2027
2048
|
const model = resolveLanguageModel(modelArg);
|
2028
2049
|
const stopConditions = asArray(stopWhen);
|
2029
|
-
const { maxRetries, retry } = prepareRetries({
|
2050
|
+
const { maxRetries, retry } = prepareRetries({
|
2051
|
+
maxRetries: maxRetriesArg,
|
2052
|
+
abortSignal
|
2053
|
+
});
|
2030
2054
|
const callSettings = prepareCallSettings(settings);
|
2031
2055
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
2032
2056
|
model,
|
@@ -4510,7 +4534,8 @@ var DefaultStreamTextResult = class {
|
|
4510
4534
|
}
|
4511
4535
|
this.baseStream = stream.pipeThrough(createOutputTransformStream(output)).pipeThrough(eventProcessor);
|
4512
4536
|
const { maxRetries, retry } = prepareRetries({
|
4513
|
-
maxRetries: maxRetriesArg
|
4537
|
+
maxRetries: maxRetriesArg,
|
4538
|
+
abortSignal
|
4514
4539
|
});
|
4515
4540
|
const tracer = getTracer(telemetry);
|
4516
4541
|
const callSettings = prepareCallSettings(settings);
|
@@ -5386,7 +5411,10 @@ async function embed({
|
|
5386
5411
|
modelId: model.modelId
|
5387
5412
|
});
|
5388
5413
|
}
|
5389
|
-
const { maxRetries, retry } = prepareRetries({
|
5414
|
+
const { maxRetries, retry } = prepareRetries({
|
5415
|
+
maxRetries: maxRetriesArg,
|
5416
|
+
abortSignal
|
5417
|
+
});
|
5390
5418
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
5391
5419
|
model,
|
5392
5420
|
telemetry,
|
@@ -5406,7 +5434,7 @@ async function embed({
|
|
5406
5434
|
}),
|
5407
5435
|
tracer,
|
5408
5436
|
fn: async (span) => {
|
5409
|
-
const { embedding, usage, response } = await retry(
|
5437
|
+
const { embedding, usage, response, providerMetadata } = await retry(
|
5410
5438
|
() => (
|
5411
5439
|
// nested spans to align with the embedMany telemetry data:
|
5412
5440
|
recordSpan({
|
@@ -5450,6 +5478,7 @@ async function embed({
|
|
5450
5478
|
return {
|
5451
5479
|
embedding: embedding2,
|
5452
5480
|
usage: usage2,
|
5481
|
+
providerMetadata: modelResponse.providerMetadata,
|
5453
5482
|
response: modelResponse.response
|
5454
5483
|
};
|
5455
5484
|
}
|
@@ -5469,6 +5498,7 @@ async function embed({
|
|
5469
5498
|
value,
|
5470
5499
|
embedding,
|
5471
5500
|
usage,
|
5501
|
+
providerMetadata,
|
5472
5502
|
response
|
5473
5503
|
});
|
5474
5504
|
}
|
@@ -5479,6 +5509,7 @@ var DefaultEmbedResult = class {
|
|
5479
5509
|
this.value = options.value;
|
5480
5510
|
this.embedding = options.embedding;
|
5481
5511
|
this.usage = options.usage;
|
5512
|
+
this.providerMetadata = options.providerMetadata;
|
5482
5513
|
this.response = options.response;
|
5483
5514
|
}
|
5484
5515
|
};
|
@@ -5513,7 +5544,10 @@ async function embedMany({
|
|
5513
5544
|
modelId: model.modelId
|
5514
5545
|
});
|
5515
5546
|
}
|
5516
|
-
const { maxRetries, retry } = prepareRetries({
|
5547
|
+
const { maxRetries, retry } = prepareRetries({
|
5548
|
+
maxRetries: maxRetriesArg,
|
5549
|
+
abortSignal
|
5550
|
+
});
|
5517
5551
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
5518
5552
|
model,
|
5519
5553
|
telemetry,
|
@@ -5536,58 +5570,64 @@ async function embedMany({
|
|
5536
5570
|
}),
|
5537
5571
|
tracer,
|
5538
5572
|
fn: async (span) => {
|
5573
|
+
var _a16;
|
5539
5574
|
const [maxEmbeddingsPerCall, supportsParallelCalls] = await Promise.all([
|
5540
5575
|
model.maxEmbeddingsPerCall,
|
5541
5576
|
model.supportsParallelCalls
|
5542
5577
|
]);
|
5543
5578
|
if (maxEmbeddingsPerCall == null || maxEmbeddingsPerCall === Infinity) {
|
5544
|
-
const { embeddings: embeddings2, usage, response } = await retry(
|
5545
|
-
|
5546
|
-
|
5547
|
-
|
5548
|
-
|
5549
|
-
|
5550
|
-
|
5551
|
-
|
5552
|
-
|
5553
|
-
|
5554
|
-
|
5555
|
-
|
5556
|
-
|
5557
|
-
|
5579
|
+
const { embeddings: embeddings2, usage, response, providerMetadata: providerMetadata2 } = await retry(
|
5580
|
+
() => {
|
5581
|
+
return recordSpan({
|
5582
|
+
name: "ai.embedMany.doEmbed",
|
5583
|
+
attributes: selectTelemetryAttributes({
|
5584
|
+
telemetry,
|
5585
|
+
attributes: {
|
5586
|
+
...assembleOperationName({
|
5587
|
+
operationId: "ai.embedMany.doEmbed",
|
5588
|
+
telemetry
|
5589
|
+
}),
|
5590
|
+
...baseTelemetryAttributes,
|
5591
|
+
// specific settings that only make sense on the outer level:
|
5592
|
+
"ai.values": {
|
5593
|
+
input: () => values.map((value) => JSON.stringify(value))
|
5594
|
+
}
|
5558
5595
|
}
|
5596
|
+
}),
|
5597
|
+
tracer,
|
5598
|
+
fn: async (doEmbedSpan) => {
|
5599
|
+
var _a17;
|
5600
|
+
const modelResponse = await model.doEmbed({
|
5601
|
+
values,
|
5602
|
+
abortSignal,
|
5603
|
+
headers,
|
5604
|
+
providerOptions
|
5605
|
+
});
|
5606
|
+
const embeddings3 = modelResponse.embeddings;
|
5607
|
+
const usage2 = (_a17 = modelResponse.usage) != null ? _a17 : { tokens: NaN };
|
5608
|
+
doEmbedSpan.setAttributes(
|
5609
|
+
selectTelemetryAttributes({
|
5610
|
+
telemetry,
|
5611
|
+
attributes: {
|
5612
|
+
"ai.embeddings": {
|
5613
|
+
output: () => embeddings3.map(
|
5614
|
+
(embedding) => JSON.stringify(embedding)
|
5615
|
+
)
|
5616
|
+
},
|
5617
|
+
"ai.usage.tokens": usage2.tokens
|
5618
|
+
}
|
5619
|
+
})
|
5620
|
+
);
|
5621
|
+
return {
|
5622
|
+
embeddings: embeddings3,
|
5623
|
+
usage: usage2,
|
5624
|
+
providerMetadata: modelResponse.providerMetadata,
|
5625
|
+
response: modelResponse.response
|
5626
|
+
};
|
5559
5627
|
}
|
5560
|
-
})
|
5561
|
-
|
5562
|
-
|
5563
|
-
var _a16;
|
5564
|
-
const modelResponse = await model.doEmbed({
|
5565
|
-
values,
|
5566
|
-
abortSignal,
|
5567
|
-
headers,
|
5568
|
-
providerOptions
|
5569
|
-
});
|
5570
|
-
const embeddings3 = modelResponse.embeddings;
|
5571
|
-
const usage2 = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };
|
5572
|
-
doEmbedSpan.setAttributes(
|
5573
|
-
selectTelemetryAttributes({
|
5574
|
-
telemetry,
|
5575
|
-
attributes: {
|
5576
|
-
"ai.embeddings": {
|
5577
|
-
output: () => embeddings3.map((embedding) => JSON.stringify(embedding))
|
5578
|
-
},
|
5579
|
-
"ai.usage.tokens": usage2.tokens
|
5580
|
-
}
|
5581
|
-
})
|
5582
|
-
);
|
5583
|
-
return {
|
5584
|
-
embeddings: embeddings3,
|
5585
|
-
usage: usage2,
|
5586
|
-
response: modelResponse.response
|
5587
|
-
};
|
5588
|
-
}
|
5589
|
-
});
|
5590
|
-
});
|
5628
|
+
});
|
5629
|
+
}
|
5630
|
+
);
|
5591
5631
|
span.setAttributes(
|
5592
5632
|
selectTelemetryAttributes({
|
5593
5633
|
telemetry,
|
@@ -5603,6 +5643,7 @@ async function embedMany({
|
|
5603
5643
|
values,
|
5604
5644
|
embeddings: embeddings2,
|
5605
5645
|
usage,
|
5646
|
+
providerMetadata: providerMetadata2,
|
5606
5647
|
responses: [response]
|
5607
5648
|
});
|
5608
5649
|
}
|
@@ -5610,6 +5651,7 @@ async function embedMany({
|
|
5610
5651
|
const embeddings = [];
|
5611
5652
|
const responses = [];
|
5612
5653
|
let tokens = 0;
|
5654
|
+
let providerMetadata;
|
5613
5655
|
const parallelChunks = splitArray(
|
5614
5656
|
valueChunks,
|
5615
5657
|
supportsParallelCalls ? maxParallelCalls : 1
|
@@ -5636,7 +5678,7 @@ async function embedMany({
|
|
5636
5678
|
}),
|
5637
5679
|
tracer,
|
5638
5680
|
fn: async (doEmbedSpan) => {
|
5639
|
-
var
|
5681
|
+
var _a17;
|
5640
5682
|
const modelResponse = await model.doEmbed({
|
5641
5683
|
values: chunk,
|
5642
5684
|
abortSignal,
|
@@ -5644,7 +5686,7 @@ async function embedMany({
|
|
5644
5686
|
providerOptions
|
5645
5687
|
});
|
5646
5688
|
const embeddings2 = modelResponse.embeddings;
|
5647
|
-
const usage = (
|
5689
|
+
const usage = (_a17 = modelResponse.usage) != null ? _a17 : { tokens: NaN };
|
5648
5690
|
doEmbedSpan.setAttributes(
|
5649
5691
|
selectTelemetryAttributes({
|
5650
5692
|
telemetry,
|
@@ -5661,6 +5703,7 @@ async function embedMany({
|
|
5661
5703
|
return {
|
5662
5704
|
embeddings: embeddings2,
|
5663
5705
|
usage,
|
5706
|
+
providerMetadata: modelResponse.providerMetadata,
|
5664
5707
|
response: modelResponse.response
|
5665
5708
|
};
|
5666
5709
|
}
|
@@ -5672,6 +5715,20 @@ async function embedMany({
|
|
5672
5715
|
embeddings.push(...result.embeddings);
|
5673
5716
|
responses.push(result.response);
|
5674
5717
|
tokens += result.usage.tokens;
|
5718
|
+
if (result.providerMetadata) {
|
5719
|
+
if (!providerMetadata) {
|
5720
|
+
providerMetadata = { ...result.providerMetadata };
|
5721
|
+
} else {
|
5722
|
+
for (const [providerName, metadata] of Object.entries(
|
5723
|
+
result.providerMetadata
|
5724
|
+
)) {
|
5725
|
+
providerMetadata[providerName] = {
|
5726
|
+
...(_a16 = providerMetadata[providerName]) != null ? _a16 : {},
|
5727
|
+
...metadata
|
5728
|
+
};
|
5729
|
+
}
|
5730
|
+
}
|
5731
|
+
}
|
5675
5732
|
}
|
5676
5733
|
}
|
5677
5734
|
span.setAttributes(
|
@@ -5689,6 +5746,7 @@ async function embedMany({
|
|
5689
5746
|
values,
|
5690
5747
|
embeddings,
|
5691
5748
|
usage: { tokens },
|
5749
|
+
providerMetadata,
|
5692
5750
|
responses
|
5693
5751
|
});
|
5694
5752
|
}
|
@@ -5699,6 +5757,7 @@ var DefaultEmbedManyResult = class {
|
|
5699
5757
|
this.values = options.values;
|
5700
5758
|
this.embeddings = options.embeddings;
|
5701
5759
|
this.usage = options.usage;
|
5760
|
+
this.providerMetadata = options.providerMetadata;
|
5702
5761
|
this.responses = options.responses;
|
5703
5762
|
}
|
5704
5763
|
};
|
@@ -5725,7 +5784,10 @@ async function generateImage({
|
|
5725
5784
|
modelId: model.modelId
|
5726
5785
|
});
|
5727
5786
|
}
|
5728
|
-
const { retry } = prepareRetries({
|
5787
|
+
const { retry } = prepareRetries({
|
5788
|
+
maxRetries: maxRetriesArg,
|
5789
|
+
abortSignal
|
5790
|
+
});
|
5729
5791
|
const maxImagesPerCallWithDefault = (_a16 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a16 : 1;
|
5730
5792
|
const callCount = Math.ceil(n / maxImagesPerCallWithDefault);
|
5731
5793
|
const callImageCounts = Array.from({ length: callCount }, (_, i) => {
|
@@ -5813,8 +5875,7 @@ async function invokeModelMaxImagesPerCall(model) {
|
|
5813
5875
|
}
|
5814
5876
|
|
5815
5877
|
// src/generate-object/generate-object.ts
|
5816
|
-
var
|
5817
|
-
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
5878
|
+
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
5818
5879
|
|
5819
5880
|
// src/generate-object/output-strategy.ts
|
5820
5881
|
var import_provider23 = require("@ai-sdk/provider");
|
@@ -6192,8 +6253,65 @@ function validateObjectGenerationInput({
|
|
6192
6253
|
}
|
6193
6254
|
}
|
6194
6255
|
|
6256
|
+
// src/generate-object/parse-and-validate-object-result.ts
|
6257
|
+
var import_provider24 = require("@ai-sdk/provider");
|
6258
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
6259
|
+
async function parseAndValidateObjectResult(result, outputStrategy, context) {
|
6260
|
+
const parseResult = await (0, import_provider_utils15.safeParseJSON)({ text: result });
|
6261
|
+
if (!parseResult.success) {
|
6262
|
+
throw new NoObjectGeneratedError({
|
6263
|
+
message: "No object generated: could not parse the response.",
|
6264
|
+
cause: parseResult.error,
|
6265
|
+
text: result,
|
6266
|
+
response: context.response,
|
6267
|
+
usage: context.usage,
|
6268
|
+
finishReason: context.finishReason
|
6269
|
+
});
|
6270
|
+
}
|
6271
|
+
const validationResult = await outputStrategy.validateFinalResult(
|
6272
|
+
parseResult.value,
|
6273
|
+
{
|
6274
|
+
text: result,
|
6275
|
+
response: context.response,
|
6276
|
+
usage: context.usage
|
6277
|
+
}
|
6278
|
+
);
|
6279
|
+
if (!validationResult.success) {
|
6280
|
+
throw new NoObjectGeneratedError({
|
6281
|
+
message: "No object generated: response did not match schema.",
|
6282
|
+
cause: validationResult.error,
|
6283
|
+
text: result,
|
6284
|
+
response: context.response,
|
6285
|
+
usage: context.usage,
|
6286
|
+
finishReason: context.finishReason
|
6287
|
+
});
|
6288
|
+
}
|
6289
|
+
return validationResult.value;
|
6290
|
+
}
|
6291
|
+
async function parseAndValidateObjectResultWithRepair(result, outputStrategy, repairText, context) {
|
6292
|
+
try {
|
6293
|
+
return await parseAndValidateObjectResult(result, outputStrategy, context);
|
6294
|
+
} catch (error) {
|
6295
|
+
if (repairText != null && NoObjectGeneratedError.isInstance(error) && (import_provider24.JSONParseError.isInstance(error.cause) || import_provider24.TypeValidationError.isInstance(error.cause))) {
|
6296
|
+
const repairedText = await repairText({
|
6297
|
+
text: result,
|
6298
|
+
error: error.cause
|
6299
|
+
});
|
6300
|
+
if (repairedText === null) {
|
6301
|
+
throw error;
|
6302
|
+
}
|
6303
|
+
return await parseAndValidateObjectResult(
|
6304
|
+
repairedText,
|
6305
|
+
outputStrategy,
|
6306
|
+
context
|
6307
|
+
);
|
6308
|
+
}
|
6309
|
+
throw error;
|
6310
|
+
}
|
6311
|
+
}
|
6312
|
+
|
6195
6313
|
// src/generate-object/generate-object.ts
|
6196
|
-
var originalGenerateId3 = (0,
|
6314
|
+
var originalGenerateId3 = (0, import_provider_utils16.createIdGenerator)({ prefix: "aiobj", size: 24 });
|
6197
6315
|
async function generateObject(options) {
|
6198
6316
|
const {
|
6199
6317
|
model: modelArg,
|
@@ -6227,7 +6345,10 @@ async function generateObject(options) {
|
|
6227
6345
|
schemaDescription,
|
6228
6346
|
enumValues
|
6229
6347
|
});
|
6230
|
-
const { maxRetries, retry } = prepareRetries({
|
6348
|
+
const { maxRetries, retry } = prepareRetries({
|
6349
|
+
maxRetries: maxRetriesArg,
|
6350
|
+
abortSignal
|
6351
|
+
});
|
6231
6352
|
const outputStrategy = getOutputStrategy({
|
6232
6353
|
output,
|
6233
6354
|
schema: inputSchema,
|
@@ -6373,55 +6494,16 @@ async function generateObject(options) {
|
|
6373
6494
|
resultProviderMetadata = generateResult.providerMetadata;
|
6374
6495
|
request = (_a16 = generateResult.request) != null ? _a16 : {};
|
6375
6496
|
response = generateResult.responseData;
|
6376
|
-
|
6377
|
-
|
6378
|
-
|
6379
|
-
|
6380
|
-
|
6381
|
-
|
6382
|
-
|
6383
|
-
|
6384
|
-
usage,
|
6385
|
-
finishReason
|
6386
|
-
});
|
6387
|
-
}
|
6388
|
-
const validationResult = await outputStrategy.validateFinalResult(
|
6389
|
-
parseResult.value,
|
6390
|
-
{
|
6391
|
-
text: result2,
|
6392
|
-
response,
|
6393
|
-
usage
|
6394
|
-
}
|
6395
|
-
);
|
6396
|
-
if (!validationResult.success) {
|
6397
|
-
throw new NoObjectGeneratedError({
|
6398
|
-
message: "No object generated: response did not match schema.",
|
6399
|
-
cause: validationResult.error,
|
6400
|
-
text: result2,
|
6401
|
-
response,
|
6402
|
-
usage,
|
6403
|
-
finishReason
|
6404
|
-
});
|
6405
|
-
}
|
6406
|
-
return validationResult.value;
|
6407
|
-
}
|
6408
|
-
let object2;
|
6409
|
-
try {
|
6410
|
-
object2 = await processResult(result);
|
6411
|
-
} catch (error) {
|
6412
|
-
if (repairText != null && NoObjectGeneratedError.isInstance(error) && (import_provider24.JSONParseError.isInstance(error.cause) || import_provider24.TypeValidationError.isInstance(error.cause))) {
|
6413
|
-
const repairedText = await repairText({
|
6414
|
-
text: result,
|
6415
|
-
error: error.cause
|
6416
|
-
});
|
6417
|
-
if (repairedText === null) {
|
6418
|
-
throw error;
|
6419
|
-
}
|
6420
|
-
object2 = await processResult(repairedText);
|
6421
|
-
} else {
|
6422
|
-
throw error;
|
6497
|
+
const object2 = await parseAndValidateObjectResultWithRepair(
|
6498
|
+
result,
|
6499
|
+
outputStrategy,
|
6500
|
+
repairText,
|
6501
|
+
{
|
6502
|
+
response,
|
6503
|
+
usage,
|
6504
|
+
finishReason
|
6423
6505
|
}
|
6424
|
-
|
6506
|
+
);
|
6425
6507
|
span.setAttributes(
|
6426
6508
|
selectTelemetryAttributes({
|
6427
6509
|
telemetry,
|
@@ -6476,7 +6558,7 @@ var DefaultGenerateObjectResult = class {
|
|
6476
6558
|
};
|
6477
6559
|
|
6478
6560
|
// src/generate-object/stream-object.ts
|
6479
|
-
var
|
6561
|
+
var import_provider_utils18 = require("@ai-sdk/provider-utils");
|
6480
6562
|
|
6481
6563
|
// src/util/cosine-similarity.ts
|
6482
6564
|
function cosineSimilarity(vector1, vector2) {
|
@@ -6586,7 +6668,7 @@ var SerialJobExecutor = class {
|
|
6586
6668
|
};
|
6587
6669
|
|
6588
6670
|
// src/util/simulate-readable-stream.ts
|
6589
|
-
var
|
6671
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
6590
6672
|
function simulateReadableStream({
|
6591
6673
|
chunks,
|
6592
6674
|
initialDelayInMs = 0,
|
@@ -6594,7 +6676,7 @@ function simulateReadableStream({
|
|
6594
6676
|
_internal
|
6595
6677
|
}) {
|
6596
6678
|
var _a16;
|
6597
|
-
const delay2 = (_a16 = _internal == null ? void 0 : _internal.delay) != null ? _a16 :
|
6679
|
+
const delay2 = (_a16 = _internal == null ? void 0 : _internal.delay) != null ? _a16 : import_provider_utils17.delay;
|
6598
6680
|
let index = 0;
|
6599
6681
|
return new ReadableStream({
|
6600
6682
|
async pull(controller) {
|
@@ -6609,7 +6691,7 @@ function simulateReadableStream({
|
|
6609
6691
|
}
|
6610
6692
|
|
6611
6693
|
// src/generate-object/stream-object.ts
|
6612
|
-
var originalGenerateId4 = (0,
|
6694
|
+
var originalGenerateId4 = (0, import_provider_utils18.createIdGenerator)({ prefix: "aiobj", size: 24 });
|
6613
6695
|
function streamObject(options) {
|
6614
6696
|
const {
|
6615
6697
|
model,
|
@@ -6620,6 +6702,7 @@ function streamObject(options) {
|
|
6620
6702
|
maxRetries,
|
6621
6703
|
abortSignal,
|
6622
6704
|
headers,
|
6705
|
+
experimental_repairText: repairText,
|
6623
6706
|
experimental_telemetry: telemetry,
|
6624
6707
|
providerOptions,
|
6625
6708
|
onError = ({ error }) => {
|
@@ -6665,6 +6748,7 @@ function streamObject(options) {
|
|
6665
6748
|
schemaName,
|
6666
6749
|
schemaDescription,
|
6667
6750
|
providerOptions,
|
6751
|
+
repairText,
|
6668
6752
|
onError,
|
6669
6753
|
onFinish,
|
6670
6754
|
generateId: generateId3,
|
@@ -6687,6 +6771,7 @@ var DefaultStreamObjectResult = class {
|
|
6687
6771
|
schemaName,
|
6688
6772
|
schemaDescription,
|
6689
6773
|
providerOptions,
|
6774
|
+
repairText,
|
6690
6775
|
onError,
|
6691
6776
|
onFinish,
|
6692
6777
|
generateId: generateId3,
|
@@ -6702,7 +6787,8 @@ var DefaultStreamObjectResult = class {
|
|
6702
6787
|
this._finishReason = new DelayedPromise();
|
6703
6788
|
const model = resolveLanguageModel(modelArg);
|
6704
6789
|
const { maxRetries, retry } = prepareRetries({
|
6705
|
-
maxRetries: maxRetriesArg
|
6790
|
+
maxRetries: maxRetriesArg,
|
6791
|
+
abortSignal
|
6706
6792
|
});
|
6707
6793
|
const callSettings = prepareCallSettings(settings);
|
6708
6794
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
@@ -6920,27 +7006,21 @@ var DefaultStreamObjectResult = class {
|
|
6920
7006
|
headers: response == null ? void 0 : response.headers
|
6921
7007
|
});
|
6922
7008
|
self._finishReason.resolve(finishReason != null ? finishReason : "unknown");
|
6923
|
-
|
6924
|
-
|
6925
|
-
|
6926
|
-
|
6927
|
-
|
6928
|
-
|
6929
|
-
|
6930
|
-
|
6931
|
-
|
6932
|
-
|
7009
|
+
try {
|
7010
|
+
object2 = await parseAndValidateObjectResultWithRepair(
|
7011
|
+
accumulatedText,
|
7012
|
+
outputStrategy,
|
7013
|
+
repairText,
|
7014
|
+
{
|
7015
|
+
response: fullResponse,
|
7016
|
+
usage,
|
7017
|
+
finishReason
|
7018
|
+
}
|
7019
|
+
);
|
6933
7020
|
self._object.resolve(object2);
|
6934
|
-
}
|
6935
|
-
error =
|
6936
|
-
|
6937
|
-
cause: validationResult.error,
|
6938
|
-
text: accumulatedText,
|
6939
|
-
response: fullResponse,
|
6940
|
-
usage,
|
6941
|
-
finishReason
|
6942
|
-
});
|
6943
|
-
self._object.reject(error);
|
7021
|
+
} catch (e) {
|
7022
|
+
error = e;
|
7023
|
+
self._object.reject(e);
|
6944
7024
|
}
|
6945
7025
|
break;
|
6946
7026
|
}
|
@@ -7183,7 +7263,10 @@ async function generateSpeech({
|
|
7183
7263
|
modelId: model.modelId
|
7184
7264
|
});
|
7185
7265
|
}
|
7186
|
-
const { retry } = prepareRetries({
|
7266
|
+
const { retry } = prepareRetries({
|
7267
|
+
maxRetries: maxRetriesArg,
|
7268
|
+
abortSignal
|
7269
|
+
});
|
7187
7270
|
const result = await retry(
|
7188
7271
|
() => model.doGenerate({
|
7189
7272
|
text: text2,
|
@@ -7229,7 +7312,7 @@ __export(output_exports, {
|
|
7229
7312
|
object: () => object,
|
7230
7313
|
text: () => text
|
7231
7314
|
});
|
7232
|
-
var
|
7315
|
+
var import_provider_utils19 = require("@ai-sdk/provider-utils");
|
7233
7316
|
var text = () => ({
|
7234
7317
|
type: "text",
|
7235
7318
|
responseFormat: { type: "text" },
|
@@ -7243,7 +7326,7 @@ var text = () => ({
|
|
7243
7326
|
var object = ({
|
7244
7327
|
schema: inputSchema
|
7245
7328
|
}) => {
|
7246
|
-
const schema = (0,
|
7329
|
+
const schema = (0, import_provider_utils19.asSchema)(inputSchema);
|
7247
7330
|
return {
|
7248
7331
|
type: "object",
|
7249
7332
|
responseFormat: {
|
@@ -7269,7 +7352,7 @@ var object = ({
|
|
7269
7352
|
}
|
7270
7353
|
},
|
7271
7354
|
async parseOutput({ text: text2 }, context) {
|
7272
|
-
const parseResult = await (0,
|
7355
|
+
const parseResult = await (0, import_provider_utils19.safeParseJSON)({ text: text2 });
|
7273
7356
|
if (!parseResult.success) {
|
7274
7357
|
throw new NoObjectGeneratedError({
|
7275
7358
|
message: "No object generated: could not parse the response.",
|
@@ -7280,7 +7363,7 @@ var object = ({
|
|
7280
7363
|
finishReason: context.finishReason
|
7281
7364
|
});
|
7282
7365
|
}
|
7283
|
-
const validationResult = await (0,
|
7366
|
+
const validationResult = await (0, import_provider_utils19.safeValidateTypes)({
|
7284
7367
|
value: parseResult.value,
|
7285
7368
|
schema
|
7286
7369
|
});
|
@@ -7300,7 +7383,7 @@ var object = ({
|
|
7300
7383
|
};
|
7301
7384
|
|
7302
7385
|
// src/generate-text/smooth-stream.ts
|
7303
|
-
var
|
7386
|
+
var import_provider_utils20 = require("@ai-sdk/provider-utils");
|
7304
7387
|
var import_provider26 = require("@ai-sdk/provider");
|
7305
7388
|
var CHUNKING_REGEXPS = {
|
7306
7389
|
word: /\S+\s+/m,
|
@@ -7309,7 +7392,7 @@ var CHUNKING_REGEXPS = {
|
|
7309
7392
|
function smoothStream({
|
7310
7393
|
delayInMs = 10,
|
7311
7394
|
chunking = "word",
|
7312
|
-
_internal: { delay: delay2 =
|
7395
|
+
_internal: { delay: delay2 = import_provider_utils20.delay } = {}
|
7313
7396
|
} = {}) {
|
7314
7397
|
let detectChunk;
|
7315
7398
|
if (typeof chunking === "function") {
|
@@ -7893,10 +7976,10 @@ var DefaultProviderRegistry = class {
|
|
7893
7976
|
};
|
7894
7977
|
|
7895
7978
|
// src/tool/mcp/mcp-client.ts
|
7896
|
-
var
|
7979
|
+
var import_provider_utils22 = require("@ai-sdk/provider-utils");
|
7897
7980
|
|
7898
7981
|
// src/tool/mcp/mcp-sse-transport.ts
|
7899
|
-
var
|
7982
|
+
var import_provider_utils21 = require("@ai-sdk/provider-utils");
|
7900
7983
|
|
7901
7984
|
// src/tool/mcp/json-rpc-message.ts
|
7902
7985
|
var import_v49 = require("zod/v4");
|
@@ -8068,7 +8151,7 @@ var SseMCPTransport = class {
|
|
8068
8151
|
(_b = this.onerror) == null ? void 0 : _b.call(this, error);
|
8069
8152
|
return reject(error);
|
8070
8153
|
}
|
8071
|
-
const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new
|
8154
|
+
const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_provider_utils21.EventSourceParserStream());
|
8072
8155
|
const reader = stream.getReader();
|
8073
8156
|
const processEvents = async () => {
|
8074
8157
|
var _a17, _b2, _c2;
|
@@ -8398,15 +8481,15 @@ var DefaultMCPClient = class {
|
|
8398
8481
|
(_a17 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a17.throwIfAborted();
|
8399
8482
|
return self.callTool({ name: name16, args, options });
|
8400
8483
|
};
|
8401
|
-
const toolWithExecute = schemas === "automatic" ? (0,
|
8484
|
+
const toolWithExecute = schemas === "automatic" ? (0, import_provider_utils22.dynamicTool)({
|
8402
8485
|
description,
|
8403
|
-
inputSchema: (0,
|
8486
|
+
inputSchema: (0, import_provider_utils22.jsonSchema)({
|
8404
8487
|
...inputSchema,
|
8405
8488
|
properties: (_a16 = inputSchema.properties) != null ? _a16 : {},
|
8406
8489
|
additionalProperties: false
|
8407
8490
|
}),
|
8408
8491
|
execute
|
8409
|
-
}) : (0,
|
8492
|
+
}) : (0, import_provider_utils22.tool)({
|
8410
8493
|
description,
|
8411
8494
|
inputSchema: schemas[name16].inputSchema,
|
8412
8495
|
execute
|
@@ -8483,7 +8566,10 @@ async function transcribe({
|
|
8483
8566
|
modelId: model.modelId
|
8484
8567
|
});
|
8485
8568
|
}
|
8486
|
-
const { retry } = prepareRetries({
|
8569
|
+
const { retry } = prepareRetries({
|
8570
|
+
maxRetries: maxRetriesArg,
|
8571
|
+
abortSignal
|
8572
|
+
});
|
8487
8573
|
const audioData = audio instanceof URL ? (await download({ url: audio })).data : convertDataContentToUint8Array(audio);
|
8488
8574
|
const result = await retry(
|
8489
8575
|
() => {
|
@@ -8527,7 +8613,7 @@ var DefaultTranscriptionResult = class {
|
|
8527
8613
|
};
|
8528
8614
|
|
8529
8615
|
// src/ui/call-completion-api.ts
|
8530
|
-
var
|
8616
|
+
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
8531
8617
|
|
8532
8618
|
// src/ui/process-text-stream.ts
|
8533
8619
|
async function processTextStream({
|
@@ -8605,7 +8691,7 @@ async function callCompletionApi({
|
|
8605
8691
|
}
|
8606
8692
|
case "data": {
|
8607
8693
|
await consumeStream({
|
8608
|
-
stream: (0,
|
8694
|
+
stream: (0, import_provider_utils23.parseJsonEventStream)({
|
8609
8695
|
stream: response.body,
|
8610
8696
|
schema: uiMessageChunkSchema
|
8611
8697
|
}).pipeThrough(
|
@@ -8657,7 +8743,7 @@ async function callCompletionApi({
|
|
8657
8743
|
}
|
8658
8744
|
|
8659
8745
|
// src/ui/chat.ts
|
8660
|
-
var
|
8746
|
+
var import_provider_utils26 = require("@ai-sdk/provider-utils");
|
8661
8747
|
|
8662
8748
|
// src/ui/convert-file-list-to-file-ui-parts.ts
|
8663
8749
|
async function convertFileListToFileUIParts(files) {
|
@@ -8690,10 +8776,10 @@ async function convertFileListToFileUIParts(files) {
|
|
8690
8776
|
}
|
8691
8777
|
|
8692
8778
|
// src/ui/default-chat-transport.ts
|
8693
|
-
var
|
8779
|
+
var import_provider_utils25 = require("@ai-sdk/provider-utils");
|
8694
8780
|
|
8695
8781
|
// src/ui/http-chat-transport.ts
|
8696
|
-
var
|
8782
|
+
var import_provider_utils24 = require("@ai-sdk/provider-utils");
|
8697
8783
|
var HttpChatTransport = class {
|
8698
8784
|
constructor({
|
8699
8785
|
api = "/api/chat",
|
@@ -8717,9 +8803,9 @@ var HttpChatTransport = class {
|
|
8717
8803
|
...options
|
8718
8804
|
}) {
|
8719
8805
|
var _a16, _b, _c, _d, _e;
|
8720
|
-
const resolvedBody = await (0,
|
8721
|
-
const resolvedHeaders = await (0,
|
8722
|
-
const resolvedCredentials = await (0,
|
8806
|
+
const resolvedBody = await (0, import_provider_utils24.resolve)(this.body);
|
8807
|
+
const resolvedHeaders = await (0, import_provider_utils24.resolve)(this.headers);
|
8808
|
+
const resolvedCredentials = await (0, import_provider_utils24.resolve)(this.credentials);
|
8723
8809
|
const preparedRequest = await ((_a16 = this.prepareSendMessagesRequest) == null ? void 0 : _a16.call(this, {
|
8724
8810
|
api: this.api,
|
8725
8811
|
id: options.chatId,
|
@@ -8765,9 +8851,9 @@ var HttpChatTransport = class {
|
|
8765
8851
|
}
|
8766
8852
|
async reconnectToStream(options) {
|
8767
8853
|
var _a16, _b, _c, _d, _e;
|
8768
|
-
const resolvedBody = await (0,
|
8769
|
-
const resolvedHeaders = await (0,
|
8770
|
-
const resolvedCredentials = await (0,
|
8854
|
+
const resolvedBody = await (0, import_provider_utils24.resolve)(this.body);
|
8855
|
+
const resolvedHeaders = await (0, import_provider_utils24.resolve)(this.headers);
|
8856
|
+
const resolvedCredentials = await (0, import_provider_utils24.resolve)(this.credentials);
|
8771
8857
|
const preparedRequest = await ((_a16 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a16.call(this, {
|
8772
8858
|
api: this.api,
|
8773
8859
|
id: options.chatId,
|
@@ -8806,7 +8892,7 @@ var DefaultChatTransport = class extends HttpChatTransport {
|
|
8806
8892
|
super(options);
|
8807
8893
|
}
|
8808
8894
|
processResponseStream(stream) {
|
8809
|
-
return (0,
|
8895
|
+
return (0, import_provider_utils25.parseJsonEventStream)({
|
8810
8896
|
stream,
|
8811
8897
|
schema: uiMessageChunkSchema
|
8812
8898
|
}).pipeThrough(
|
@@ -8825,7 +8911,7 @@ var DefaultChatTransport = class extends HttpChatTransport {
|
|
8825
8911
|
// src/ui/chat.ts
|
8826
8912
|
var AbstractChat = class {
|
8827
8913
|
constructor({
|
8828
|
-
generateId: generateId3 =
|
8914
|
+
generateId: generateId3 = import_provider_utils26.generateId,
|
8829
8915
|
id = generateId3(),
|
8830
8916
|
transport = new DefaultChatTransport(),
|
8831
8917
|
messageMetadataSchema,
|
@@ -8929,6 +9015,15 @@ var AbstractChat = class {
|
|
8929
9015
|
this.resumeStream = async (options = {}) => {
|
8930
9016
|
await this.makeRequest({ trigger: "resume-stream", ...options });
|
8931
9017
|
};
|
9018
|
+
/**
|
9019
|
+
* Clear the error state and set the status to ready if the chat is in an error state.
|
9020
|
+
*/
|
9021
|
+
this.clearError = () => {
|
9022
|
+
if (this.status === "error") {
|
9023
|
+
this.state.error = void 0;
|
9024
|
+
this.setStatus({ status: "ready" });
|
9025
|
+
}
|
9026
|
+
};
|
8932
9027
|
this.addToolResult = async ({
|
8933
9028
|
tool: tool3,
|
8934
9029
|
toolCallId,
|
@@ -9364,13 +9459,13 @@ var TextStreamChatTransport = class extends HttpChatTransport {
|
|
9364
9459
|
};
|
9365
9460
|
|
9366
9461
|
// src/ui-message-stream/create-ui-message-stream.ts
|
9367
|
-
var
|
9462
|
+
var import_provider_utils27 = require("@ai-sdk/provider-utils");
|
9368
9463
|
function createUIMessageStream({
|
9369
9464
|
execute,
|
9370
|
-
onError =
|
9465
|
+
onError = import_provider_utils27.getErrorMessage,
|
9371
9466
|
originalMessages,
|
9372
9467
|
onFinish,
|
9373
|
-
generateId: generateId3 =
|
9468
|
+
generateId: generateId3 = import_provider_utils27.generateId
|
9374
9469
|
}) {
|
9375
9470
|
let controller;
|
9376
9471
|
const ongoingStreamPromises = [];
|