ai 5.0.245 → 5.0.249
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 +34 -0
- package/dist/index.d.mts +38 -4
- package/dist/index.d.ts +38 -4
- package/dist/index.js +319 -118
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +244 -43
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/dist/test/index.d.mts +5 -1
- package/dist/test/index.d.ts +5 -1
- package/dist/test/index.js +11 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test/index.mjs +11 -1
- package/dist/test/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -727,7 +727,7 @@ import {
|
|
|
727
727
|
} from "@ai-sdk/provider-utils";
|
|
728
728
|
|
|
729
729
|
// src/version.ts
|
|
730
|
-
var VERSION = true ? "5.0.
|
|
730
|
+
var VERSION = true ? "5.0.249" : "0.0.0-test";
|
|
731
731
|
|
|
732
732
|
// src/util/download/download.ts
|
|
733
733
|
var download = async ({
|
|
@@ -1514,13 +1514,22 @@ function assembleOperationName({
|
|
|
1514
1514
|
}
|
|
1515
1515
|
|
|
1516
1516
|
// src/telemetry/get-base-telemetry-attributes.ts
|
|
1517
|
+
function getTelemetryMetadataAttributes(telemetry) {
|
|
1518
|
+
var _a16;
|
|
1519
|
+
return Object.entries((_a16 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a16 : {}).reduce(
|
|
1520
|
+
(attributes, [key, value]) => {
|
|
1521
|
+
attributes[`ai.telemetry.metadata.${key}`] = value;
|
|
1522
|
+
return attributes;
|
|
1523
|
+
},
|
|
1524
|
+
{}
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1517
1527
|
function getBaseTelemetryAttributes({
|
|
1518
1528
|
model,
|
|
1519
1529
|
settings,
|
|
1520
1530
|
telemetry,
|
|
1521
1531
|
headers
|
|
1522
1532
|
}) {
|
|
1523
|
-
var _a16;
|
|
1524
1533
|
return {
|
|
1525
1534
|
"ai.model.provider": model.provider,
|
|
1526
1535
|
"ai.model.id": model.modelId,
|
|
@@ -1530,13 +1539,7 @@ function getBaseTelemetryAttributes({
|
|
|
1530
1539
|
return attributes;
|
|
1531
1540
|
}, {}),
|
|
1532
1541
|
// add metadata as attributes:
|
|
1533
|
-
...
|
|
1534
|
-
(attributes, [key, value]) => {
|
|
1535
|
-
attributes[`ai.telemetry.metadata.${key}`] = value;
|
|
1536
|
-
return attributes;
|
|
1537
|
-
},
|
|
1538
|
-
{}
|
|
1539
|
-
),
|
|
1542
|
+
...getTelemetryMetadataAttributes(telemetry),
|
|
1540
1543
|
// request headers
|
|
1541
1544
|
...Object.entries(headers != null ? headers : {}).reduce((attributes, [key, value]) => {
|
|
1542
1545
|
if (value !== void 0) {
|
|
@@ -2622,6 +2625,7 @@ async function executeTools({
|
|
|
2622
2625
|
operationId: "ai.toolCall",
|
|
2623
2626
|
telemetry
|
|
2624
2627
|
}),
|
|
2628
|
+
...getTelemetryMetadataAttributes(telemetry),
|
|
2625
2629
|
"ai.toolCall.name": toolName,
|
|
2626
2630
|
"ai.toolCall.id": toolCallId,
|
|
2627
2631
|
"ai.toolCall.args": {
|
|
@@ -4068,7 +4072,8 @@ function handleUIMessageStreamFinish({
|
|
|
4068
4072
|
originalMessages = [],
|
|
4069
4073
|
onFinish,
|
|
4070
4074
|
onError,
|
|
4071
|
-
stream
|
|
4075
|
+
stream,
|
|
4076
|
+
getOutcome
|
|
4072
4077
|
}) {
|
|
4073
4078
|
let lastMessage = originalMessages == null ? void 0 : originalMessages[originalMessages.length - 1];
|
|
4074
4079
|
if ((lastMessage == null ? void 0 : lastMessage.role) !== "assistant") {
|
|
@@ -4077,19 +4082,34 @@ function handleUIMessageStreamFinish({
|
|
|
4077
4082
|
messageId = lastMessage.id;
|
|
4078
4083
|
}
|
|
4079
4084
|
let isAborted = false;
|
|
4085
|
+
let hasProcessingFailure = false;
|
|
4086
|
+
let processingError;
|
|
4087
|
+
const recordProcessingFailure = (error) => {
|
|
4088
|
+
hasProcessingFailure = true;
|
|
4089
|
+
processingError = error;
|
|
4090
|
+
};
|
|
4080
4091
|
const idInjectedStream = stream.pipeThrough(
|
|
4081
4092
|
new TransformStream({
|
|
4082
4093
|
transform(chunk, controller) {
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
if (
|
|
4086
|
-
startChunk
|
|
4094
|
+
try {
|
|
4095
|
+
let outputChunk = chunk;
|
|
4096
|
+
if (chunk.type === "start") {
|
|
4097
|
+
const startChunk = chunk;
|
|
4098
|
+
if (startChunk.messageId == null && messageId != null) {
|
|
4099
|
+
outputChunk = {
|
|
4100
|
+
...startChunk,
|
|
4101
|
+
messageId
|
|
4102
|
+
};
|
|
4103
|
+
}
|
|
4087
4104
|
}
|
|
4105
|
+
if (chunk.type === "abort") {
|
|
4106
|
+
isAborted = true;
|
|
4107
|
+
}
|
|
4108
|
+
controller.enqueue(outputChunk);
|
|
4109
|
+
} catch (error) {
|
|
4110
|
+
recordProcessingFailure(error);
|
|
4111
|
+
throw error;
|
|
4088
4112
|
}
|
|
4089
|
-
if (chunk.type === "abort") {
|
|
4090
|
-
isAborted = true;
|
|
4091
|
-
}
|
|
4092
|
-
controller.enqueue(chunk);
|
|
4093
4113
|
}
|
|
4094
4114
|
})
|
|
4095
4115
|
);
|
|
@@ -4102,19 +4122,28 @@ function handleUIMessageStreamFinish({
|
|
|
4102
4122
|
// will be overridden by the stream
|
|
4103
4123
|
});
|
|
4104
4124
|
const runUpdateMessageJob = async (job) => {
|
|
4105
|
-
|
|
4106
|
-
|
|
4125
|
+
try {
|
|
4126
|
+
await job({ state, write: () => {
|
|
4127
|
+
} });
|
|
4128
|
+
} catch (error) {
|
|
4129
|
+
recordProcessingFailure(error);
|
|
4130
|
+
throw error;
|
|
4131
|
+
}
|
|
4107
4132
|
};
|
|
4108
4133
|
let finishCalled = false;
|
|
4109
4134
|
const callOnFinish = async () => {
|
|
4135
|
+
var _a16;
|
|
4110
4136
|
if (finishCalled || !onFinish) {
|
|
4111
4137
|
return;
|
|
4112
4138
|
}
|
|
4113
4139
|
finishCalled = true;
|
|
4114
4140
|
const isContinuation = state.message.id === (lastMessage == null ? void 0 : lastMessage.id);
|
|
4141
|
+
const declaredOutcome = (_a16 = getOutcome == null ? void 0 : getOutcome()) != null ? _a16 : { status: "unknown" };
|
|
4142
|
+
const outcome = hasProcessingFailure ? { status: "failed", error: processingError } : declaredOutcome.status === "unknown" && isAborted ? { status: "aborted" } : declaredOutcome;
|
|
4115
4143
|
await onFinish({
|
|
4116
|
-
isAborted,
|
|
4144
|
+
isAborted: isAborted || outcome.status === "aborted",
|
|
4117
4145
|
isContinuation,
|
|
4146
|
+
outcome,
|
|
4118
4147
|
responseMessage: state.message,
|
|
4119
4148
|
messages: [
|
|
4120
4149
|
...isContinuation ? originalMessages.slice(0, -1) : originalMessages,
|
|
@@ -4451,6 +4480,7 @@ function runToolsTransformation({
|
|
|
4451
4480
|
operationId: "ai.toolCall",
|
|
4452
4481
|
telemetry
|
|
4453
4482
|
}),
|
|
4483
|
+
...getTelemetryMetadataAttributes(telemetry),
|
|
4454
4484
|
"ai.toolCall.name": toolCall.toolName,
|
|
4455
4485
|
"ai.toolCall.id": toolCall.toolCallId,
|
|
4456
4486
|
"ai.toolCall.args": {
|
|
@@ -5710,6 +5740,17 @@ var DefaultStreamTextResult = class {
|
|
|
5710
5740
|
onError = () => "An error occurred."
|
|
5711
5741
|
// prevent leaking server error details to the client by default
|
|
5712
5742
|
} = {}) {
|
|
5743
|
+
let outcome = { status: "unknown" };
|
|
5744
|
+
let hasFatalFailure = false;
|
|
5745
|
+
const setSourceOutcome = (newOutcome) => {
|
|
5746
|
+
if (!hasFatalFailure && outcome.status !== "completed" && outcome.status !== "aborted" && newOutcome.status !== "unknown" && (outcome.status === "unknown" || newOutcome.status !== "failed")) {
|
|
5747
|
+
outcome = newOutcome;
|
|
5748
|
+
}
|
|
5749
|
+
};
|
|
5750
|
+
const failOutcome = (error) => {
|
|
5751
|
+
hasFatalFailure = true;
|
|
5752
|
+
outcome = { status: "failed", error };
|
|
5753
|
+
};
|
|
5713
5754
|
const responseMessageId = generateMessageId != null ? getResponseUIMessageId({
|
|
5714
5755
|
originalMessages,
|
|
5715
5756
|
responseMessageId: generateMessageId
|
|
@@ -5721,7 +5762,48 @@ var DefaultStreamTextResult = class {
|
|
|
5721
5762
|
const dynamic = ((_b = (_a16 = this.tools) == null ? void 0 : _a16[toolName]) == null ? void 0 : _b.type) === "dynamic";
|
|
5722
5763
|
return dynamic ? true : void 0;
|
|
5723
5764
|
};
|
|
5724
|
-
const
|
|
5765
|
+
const sourceReader = this.fullStream.getReader();
|
|
5766
|
+
let sourceReaderReleased = false;
|
|
5767
|
+
let sourceStreamCancelled = false;
|
|
5768
|
+
const releaseSourceReader = () => {
|
|
5769
|
+
if (!sourceReaderReleased) {
|
|
5770
|
+
sourceReader.releaseLock();
|
|
5771
|
+
sourceReaderReleased = true;
|
|
5772
|
+
}
|
|
5773
|
+
};
|
|
5774
|
+
const sourceStream = new ReadableStream({
|
|
5775
|
+
async pull(controller) {
|
|
5776
|
+
try {
|
|
5777
|
+
const { done, value } = await sourceReader.read();
|
|
5778
|
+
if (done) {
|
|
5779
|
+
releaseSourceReader();
|
|
5780
|
+
if (!sourceStreamCancelled) {
|
|
5781
|
+
controller.close();
|
|
5782
|
+
}
|
|
5783
|
+
} else {
|
|
5784
|
+
controller.enqueue(value);
|
|
5785
|
+
}
|
|
5786
|
+
} catch (error) {
|
|
5787
|
+
releaseSourceReader();
|
|
5788
|
+
if (!sourceStreamCancelled) {
|
|
5789
|
+
failOutcome(error);
|
|
5790
|
+
controller.error(error);
|
|
5791
|
+
}
|
|
5792
|
+
}
|
|
5793
|
+
},
|
|
5794
|
+
async cancel(reason) {
|
|
5795
|
+
sourceStreamCancelled = true;
|
|
5796
|
+
if (sourceReaderReleased) {
|
|
5797
|
+
return;
|
|
5798
|
+
}
|
|
5799
|
+
try {
|
|
5800
|
+
await sourceReader.cancel(reason);
|
|
5801
|
+
} finally {
|
|
5802
|
+
releaseSourceReader();
|
|
5803
|
+
}
|
|
5804
|
+
}
|
|
5805
|
+
});
|
|
5806
|
+
const baseStream = sourceStream.pipeThrough(
|
|
5725
5807
|
new TransformStream({
|
|
5726
5808
|
transform: async (part, controller) => {
|
|
5727
5809
|
const messageMetadataValue = messageMetadata == null ? void 0 : messageMetadata({ part });
|
|
@@ -5935,16 +6017,65 @@ var DefaultStreamTextResult = class {
|
|
|
5935
6017
|
messageMetadata: messageMetadataValue
|
|
5936
6018
|
});
|
|
5937
6019
|
}
|
|
6020
|
+
if (part.type === "finish") {
|
|
6021
|
+
setSourceOutcome({ status: "completed" });
|
|
6022
|
+
} else if (part.type === "abort") {
|
|
6023
|
+
setSourceOutcome({ status: "aborted" });
|
|
6024
|
+
} else if (part.type === "error") {
|
|
6025
|
+
setSourceOutcome({ status: "failed", error: part.error });
|
|
6026
|
+
}
|
|
5938
6027
|
}
|
|
5939
6028
|
})
|
|
5940
6029
|
);
|
|
6030
|
+
const baseStreamReader = baseStream.getReader();
|
|
6031
|
+
let baseStreamReaderReleased = false;
|
|
6032
|
+
let baseStreamCancelled = false;
|
|
6033
|
+
const releaseBaseStreamReader = () => {
|
|
6034
|
+
if (!baseStreamReaderReleased) {
|
|
6035
|
+
baseStreamReader.releaseLock();
|
|
6036
|
+
baseStreamReaderReleased = true;
|
|
6037
|
+
}
|
|
6038
|
+
};
|
|
6039
|
+
const trackedBaseStream = new ReadableStream({
|
|
6040
|
+
async pull(controller) {
|
|
6041
|
+
try {
|
|
6042
|
+
const { done, value } = await baseStreamReader.read();
|
|
6043
|
+
if (done) {
|
|
6044
|
+
releaseBaseStreamReader();
|
|
6045
|
+
if (!baseStreamCancelled) {
|
|
6046
|
+
controller.close();
|
|
6047
|
+
}
|
|
6048
|
+
} else {
|
|
6049
|
+
controller.enqueue(value);
|
|
6050
|
+
}
|
|
6051
|
+
} catch (error) {
|
|
6052
|
+
releaseBaseStreamReader();
|
|
6053
|
+
if (!baseStreamCancelled) {
|
|
6054
|
+
failOutcome(error);
|
|
6055
|
+
controller.error(error);
|
|
6056
|
+
}
|
|
6057
|
+
}
|
|
6058
|
+
},
|
|
6059
|
+
async cancel(reason) {
|
|
6060
|
+
baseStreamCancelled = true;
|
|
6061
|
+
if (baseStreamReaderReleased) {
|
|
6062
|
+
return;
|
|
6063
|
+
}
|
|
6064
|
+
try {
|
|
6065
|
+
await baseStreamReader.cancel(reason);
|
|
6066
|
+
} finally {
|
|
6067
|
+
releaseBaseStreamReader();
|
|
6068
|
+
}
|
|
6069
|
+
}
|
|
6070
|
+
});
|
|
5941
6071
|
return createAsyncIterableStream(
|
|
5942
6072
|
handleUIMessageStreamFinish({
|
|
5943
|
-
stream:
|
|
6073
|
+
stream: trackedBaseStream,
|
|
5944
6074
|
messageId: responseMessageId != null ? responseMessageId : generateMessageId == null ? void 0 : generateMessageId(),
|
|
5945
6075
|
originalMessages,
|
|
5946
6076
|
onFinish,
|
|
5947
|
-
onError
|
|
6077
|
+
onError,
|
|
6078
|
+
getOutcome: () => outcome
|
|
5948
6079
|
})
|
|
5949
6080
|
);
|
|
5950
6081
|
}
|
|
@@ -6372,6 +6503,12 @@ import {
|
|
|
6372
6503
|
withUserAgentSuffix as withUserAgentSuffix4
|
|
6373
6504
|
} from "@ai-sdk/provider-utils";
|
|
6374
6505
|
|
|
6506
|
+
// src/model/get-embedding-model-max-input-bytes-per-call.ts
|
|
6507
|
+
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from "@ai-sdk/provider-utils";
|
|
6508
|
+
function getEmbeddingModelMaxInputBytesPerCall(model) {
|
|
6509
|
+
return model[EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL];
|
|
6510
|
+
}
|
|
6511
|
+
|
|
6375
6512
|
// src/util/split-array.ts
|
|
6376
6513
|
function splitArray(array, chunkSize) {
|
|
6377
6514
|
if (chunkSize <= 0) {
|
|
@@ -6427,11 +6564,18 @@ async function embedMany({
|
|
|
6427
6564
|
tracer,
|
|
6428
6565
|
fn: async (span) => {
|
|
6429
6566
|
var _a16;
|
|
6430
|
-
const [
|
|
6567
|
+
const [
|
|
6568
|
+
maxEmbeddingsPerCall,
|
|
6569
|
+
maxInputBytesPerCall,
|
|
6570
|
+
supportsParallelCalls
|
|
6571
|
+
] = await Promise.all([
|
|
6431
6572
|
model.maxEmbeddingsPerCall,
|
|
6573
|
+
getEmbeddingModelMaxInputBytesPerCall(model),
|
|
6432
6574
|
model.supportsParallelCalls
|
|
6433
6575
|
]);
|
|
6434
|
-
|
|
6576
|
+
const hasEmbeddingLimit = maxEmbeddingsPerCall != null && maxEmbeddingsPerCall !== Infinity;
|
|
6577
|
+
const hasInputByteLimit = maxInputBytesPerCall != null && maxInputBytesPerCall !== Infinity;
|
|
6578
|
+
if (!hasEmbeddingLimit && !hasInputByteLimit) {
|
|
6435
6579
|
const { embeddings: embeddings2, usage, response, providerMetadata: providerMetadata2 } = await retry(
|
|
6436
6580
|
() => {
|
|
6437
6581
|
return recordSpan({
|
|
@@ -6503,7 +6647,11 @@ async function embedMany({
|
|
|
6503
6647
|
responses: [response]
|
|
6504
6648
|
});
|
|
6505
6649
|
}
|
|
6506
|
-
const valueChunks =
|
|
6650
|
+
const valueChunks = splitByEmbeddingLimits({
|
|
6651
|
+
values,
|
|
6652
|
+
maxEmbeddingsPerCall: hasEmbeddingLimit ? maxEmbeddingsPerCall : Infinity,
|
|
6653
|
+
maxInputBytesPerCall: hasInputByteLimit ? maxInputBytesPerCall : Infinity
|
|
6654
|
+
});
|
|
6507
6655
|
const embeddings = [];
|
|
6508
6656
|
const responses = [];
|
|
6509
6657
|
let tokens = 0;
|
|
@@ -6608,6 +6756,37 @@ async function embedMany({
|
|
|
6608
6756
|
}
|
|
6609
6757
|
});
|
|
6610
6758
|
}
|
|
6759
|
+
var textEncoder = new TextEncoder();
|
|
6760
|
+
function splitByEmbeddingLimits({
|
|
6761
|
+
values,
|
|
6762
|
+
maxEmbeddingsPerCall,
|
|
6763
|
+
maxInputBytesPerCall
|
|
6764
|
+
}) {
|
|
6765
|
+
if (maxEmbeddingsPerCall <= 0) {
|
|
6766
|
+
throw new Error("maxEmbeddingsPerCall must be greater than 0");
|
|
6767
|
+
}
|
|
6768
|
+
if (maxInputBytesPerCall <= 0) {
|
|
6769
|
+
throw new Error("maxInputBytesPerCall must be greater than 0");
|
|
6770
|
+
}
|
|
6771
|
+
if (values.length === 0) {
|
|
6772
|
+
return [];
|
|
6773
|
+
}
|
|
6774
|
+
const chunks = [];
|
|
6775
|
+
let currentChunk = [];
|
|
6776
|
+
let currentInputBytes = 0;
|
|
6777
|
+
for (const value of values) {
|
|
6778
|
+
const inputBytes = maxInputBytesPerCall === Infinity ? 0 : textEncoder.encode(value).length;
|
|
6779
|
+
if (currentChunk.length > 0 && (currentChunk.length >= maxEmbeddingsPerCall || currentInputBytes + inputBytes > maxInputBytesPerCall)) {
|
|
6780
|
+
chunks.push(currentChunk);
|
|
6781
|
+
currentChunk = [];
|
|
6782
|
+
currentInputBytes = 0;
|
|
6783
|
+
}
|
|
6784
|
+
currentChunk.push(value);
|
|
6785
|
+
currentInputBytes += inputBytes;
|
|
6786
|
+
}
|
|
6787
|
+
chunks.push(currentChunk);
|
|
6788
|
+
return chunks;
|
|
6789
|
+
}
|
|
6611
6790
|
var DefaultEmbedManyResult = class {
|
|
6612
6791
|
constructor(options) {
|
|
6613
6792
|
this.values = options.values;
|
|
@@ -10245,6 +10424,7 @@ function createUIMessageStream({
|
|
|
10245
10424
|
}) {
|
|
10246
10425
|
let controller;
|
|
10247
10426
|
const ongoingStreamPromises = [];
|
|
10427
|
+
let outcome = { status: "unknown" };
|
|
10248
10428
|
const stream = new ReadableStream({
|
|
10249
10429
|
start(controllerArg) {
|
|
10250
10430
|
controller = controllerArg;
|
|
@@ -10256,6 +10436,35 @@ function createUIMessageStream({
|
|
|
10256
10436
|
} catch (error) {
|
|
10257
10437
|
}
|
|
10258
10438
|
}
|
|
10439
|
+
function setOutcome(newOutcome) {
|
|
10440
|
+
if (outcome.status === "unknown" && newOutcome.status !== "unknown") {
|
|
10441
|
+
outcome = newOutcome;
|
|
10442
|
+
}
|
|
10443
|
+
}
|
|
10444
|
+
function failOutcome(error) {
|
|
10445
|
+
outcome = { status: "failed", error };
|
|
10446
|
+
}
|
|
10447
|
+
function safeError(error) {
|
|
10448
|
+
try {
|
|
10449
|
+
controller.error(error);
|
|
10450
|
+
} catch (e) {
|
|
10451
|
+
}
|
|
10452
|
+
}
|
|
10453
|
+
function handleError(error) {
|
|
10454
|
+
failOutcome(error);
|
|
10455
|
+
let errorText;
|
|
10456
|
+
try {
|
|
10457
|
+
errorText = onError(error);
|
|
10458
|
+
} catch (onErrorError) {
|
|
10459
|
+
failOutcome(onErrorError);
|
|
10460
|
+
safeError(onErrorError);
|
|
10461
|
+
return;
|
|
10462
|
+
}
|
|
10463
|
+
safeEnqueue({
|
|
10464
|
+
type: "error",
|
|
10465
|
+
errorText
|
|
10466
|
+
});
|
|
10467
|
+
}
|
|
10259
10468
|
try {
|
|
10260
10469
|
const result = execute({
|
|
10261
10470
|
writer: {
|
|
@@ -10273,38 +10482,29 @@ function createUIMessageStream({
|
|
|
10273
10482
|
safeEnqueue(value);
|
|
10274
10483
|
}
|
|
10275
10484
|
})().catch((error) => {
|
|
10276
|
-
|
|
10277
|
-
type: "error",
|
|
10278
|
-
errorText: onError(error)
|
|
10279
|
-
});
|
|
10485
|
+
handleError(error);
|
|
10280
10486
|
})
|
|
10281
10487
|
);
|
|
10282
10488
|
},
|
|
10489
|
+
setOutcome,
|
|
10283
10490
|
onError
|
|
10284
10491
|
}
|
|
10285
10492
|
});
|
|
10286
10493
|
if (result) {
|
|
10287
10494
|
ongoingStreamPromises.push(
|
|
10288
10495
|
result.catch((error) => {
|
|
10289
|
-
|
|
10290
|
-
type: "error",
|
|
10291
|
-
errorText: onError(error)
|
|
10292
|
-
});
|
|
10496
|
+
handleError(error);
|
|
10293
10497
|
})
|
|
10294
10498
|
);
|
|
10295
10499
|
}
|
|
10296
10500
|
} catch (error) {
|
|
10297
|
-
|
|
10298
|
-
type: "error",
|
|
10299
|
-
errorText: onError(error)
|
|
10300
|
-
});
|
|
10501
|
+
handleError(error);
|
|
10301
10502
|
}
|
|
10302
|
-
const waitForStreams =
|
|
10503
|
+
const waitForStreams = (async () => {
|
|
10303
10504
|
while (ongoingStreamPromises.length > 0) {
|
|
10304
10505
|
await ongoingStreamPromises.shift();
|
|
10305
10506
|
}
|
|
10306
|
-
|
|
10307
|
-
});
|
|
10507
|
+
})();
|
|
10308
10508
|
waitForStreams.finally(() => {
|
|
10309
10509
|
try {
|
|
10310
10510
|
controller.close();
|
|
@@ -10316,7 +10516,8 @@ function createUIMessageStream({
|
|
|
10316
10516
|
messageId: generateId3(),
|
|
10317
10517
|
originalMessages,
|
|
10318
10518
|
onFinish,
|
|
10319
|
-
onError
|
|
10519
|
+
onError,
|
|
10520
|
+
getOutcome: () => outcome
|
|
10320
10521
|
});
|
|
10321
10522
|
}
|
|
10322
10523
|
|