ai 6.0.289 → 6.0.290
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 +21 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +326 -250
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +263 -182
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +4 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +4 -2
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-ai-sdk-core/16-mcp-tools.mdx +57 -0
- package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +7 -0
- package/package.json +4 -3
- package/src/embed/embed-many.ts +19 -3
- package/src/generate-speech/generated-audio-file.ts +0 -8
- package/src/generate-text/generated-file.ts +0 -4
- package/src/generate-text/parse-tool-call.ts +30 -23
- package/src/generate-text/stream-text.ts +9 -1
- package/src/generate-text/to-response-messages.ts +7 -0
- package/src/generate-text/tool-call.ts +26 -0
- package/src/generate-text/validate-tool-approvals.ts +20 -2
- package/src/middleware/extract-reasoning-middleware.ts +1 -1
- package/src/middleware/wrap-embedding-model.ts +12 -2
- package/src/model/get-embedding-model-provider-options-transformer.ts +17 -0
- package/src/prompt/content-part.ts +2 -0
- package/src/ui/chat.ts +108 -17
- package/src/ui/convert-to-model-messages.ts +8 -0
- package/src/ui/process-ui-message-stream.ts +6 -0
- package/src/ui/ui-messages.ts +10 -0
- package/src/ui/validate-ui-messages.ts +79 -114
- package/src/ui-message-stream/ui-message-chunks.ts +2 -0
- package/src/util/write-to-server-response.ts +0 -2
package/dist/index.mjs
CHANGED
|
@@ -1224,7 +1224,7 @@ import {
|
|
|
1224
1224
|
} from "@ai-sdk/provider-utils";
|
|
1225
1225
|
|
|
1226
1226
|
// src/version.ts
|
|
1227
|
-
var VERSION = true ? "6.0.
|
|
1227
|
+
var VERSION = true ? "6.0.290" : "0.0.0-test";
|
|
1228
1228
|
|
|
1229
1229
|
// src/util/download/download.ts
|
|
1230
1230
|
var download = async ({
|
|
@@ -2181,7 +2181,9 @@ var toolResultPartSchema = z4.object({
|
|
|
2181
2181
|
var toolApprovalRequestSchema = z4.object({
|
|
2182
2182
|
type: z4.literal("tool-approval-request"),
|
|
2183
2183
|
approvalId: z4.string(),
|
|
2184
|
-
toolCallId: z4.string()
|
|
2184
|
+
toolCallId: z4.string(),
|
|
2185
|
+
signature: z4.string().optional(),
|
|
2186
|
+
inputSchemaInput: z4.unknown().optional()
|
|
2185
2187
|
});
|
|
2186
2188
|
var toolApprovalResponseSchema = z4.object({
|
|
2187
2189
|
type: z4.literal("tool-approval-response"),
|
|
@@ -3147,8 +3149,8 @@ var DefaultGeneratedFile = class {
|
|
|
3147
3149
|
}
|
|
3148
3150
|
};
|
|
3149
3151
|
var DefaultGeneratedFileWithType = class extends DefaultGeneratedFile {
|
|
3150
|
-
constructor(
|
|
3151
|
-
super(
|
|
3152
|
+
constructor() {
|
|
3153
|
+
super(...arguments);
|
|
3152
3154
|
this.type = "file";
|
|
3153
3155
|
}
|
|
3154
3156
|
};
|
|
@@ -3276,6 +3278,43 @@ import {
|
|
|
3276
3278
|
asSchema as asSchema2,
|
|
3277
3279
|
safeValidateTypes as safeValidateTypes2
|
|
3278
3280
|
} from "@ai-sdk/provider-utils";
|
|
3281
|
+
|
|
3282
|
+
// src/util/is-deep-equal-data.ts
|
|
3283
|
+
function isDeepEqualData(obj1, obj2) {
|
|
3284
|
+
if (obj1 === obj2)
|
|
3285
|
+
return true;
|
|
3286
|
+
if (obj1 == null || obj2 == null)
|
|
3287
|
+
return false;
|
|
3288
|
+
if (typeof obj1 !== "object" && typeof obj2 !== "object")
|
|
3289
|
+
return obj1 === obj2;
|
|
3290
|
+
if (obj1.constructor !== obj2.constructor)
|
|
3291
|
+
return false;
|
|
3292
|
+
if (obj1 instanceof Date && obj2 instanceof Date) {
|
|
3293
|
+
return obj1.getTime() === obj2.getTime();
|
|
3294
|
+
}
|
|
3295
|
+
if (Array.isArray(obj1)) {
|
|
3296
|
+
if (obj1.length !== obj2.length)
|
|
3297
|
+
return false;
|
|
3298
|
+
for (let i = 0; i < obj1.length; i++) {
|
|
3299
|
+
if (!isDeepEqualData(obj1[i], obj2[i]))
|
|
3300
|
+
return false;
|
|
3301
|
+
}
|
|
3302
|
+
return true;
|
|
3303
|
+
}
|
|
3304
|
+
const keys1 = Object.keys(obj1);
|
|
3305
|
+
const keys2 = Object.keys(obj2);
|
|
3306
|
+
if (keys1.length !== keys2.length)
|
|
3307
|
+
return false;
|
|
3308
|
+
for (const key of keys1) {
|
|
3309
|
+
if (!keys2.includes(key))
|
|
3310
|
+
return false;
|
|
3311
|
+
if (!isDeepEqualData(obj1[key], obj2[key]))
|
|
3312
|
+
return false;
|
|
3313
|
+
}
|
|
3314
|
+
return true;
|
|
3315
|
+
}
|
|
3316
|
+
|
|
3317
|
+
// src/generate-text/validate-tool-approvals.ts
|
|
3279
3318
|
async function validateApprovedToolApprovals({
|
|
3280
3319
|
approvedToolApprovals,
|
|
3281
3320
|
tools,
|
|
@@ -3315,17 +3354,29 @@ async function validateApprovedToolApprovals({
|
|
|
3315
3354
|
}
|
|
3316
3355
|
}
|
|
3317
3356
|
if (tool2 != null && typeof tool2.execute === "function" && tool2.inputSchema != null) {
|
|
3357
|
+
const hasInputSchemaInput = Object.prototype.hasOwnProperty.call(
|
|
3358
|
+
approvalRequest,
|
|
3359
|
+
"inputSchemaInput"
|
|
3360
|
+
);
|
|
3318
3361
|
const validation = await safeValidateTypes2({
|
|
3319
|
-
value: toolCall.input,
|
|
3362
|
+
value: hasInputSchemaInput ? approvalRequest.inputSchemaInput : toolCall.input,
|
|
3320
3363
|
schema: asSchema2(tool2.inputSchema)
|
|
3321
3364
|
});
|
|
3365
|
+
let validationError;
|
|
3322
3366
|
if (!validation.success) {
|
|
3367
|
+
validationError = validation.error;
|
|
3368
|
+
} else if (!isDeepEqualData(validation.value, toolCall.input)) {
|
|
3369
|
+
validationError = new Error(
|
|
3370
|
+
"Approved tool input does not match the validated schema output."
|
|
3371
|
+
);
|
|
3372
|
+
}
|
|
3373
|
+
if (validationError != null) {
|
|
3323
3374
|
invalid.push({
|
|
3324
3375
|
...approval,
|
|
3325
3376
|
error: new InvalidToolInputError({
|
|
3326
3377
|
toolName: toolCall.toolName,
|
|
3327
3378
|
toolInput: JSON.stringify(toolCall.input),
|
|
3328
|
-
cause:
|
|
3379
|
+
cause: validationError
|
|
3329
3380
|
})
|
|
3330
3381
|
});
|
|
3331
3382
|
continue;
|
|
@@ -4052,6 +4103,22 @@ import {
|
|
|
4052
4103
|
safeParseJSON as safeParseJSON3,
|
|
4053
4104
|
safeValidateTypes as safeValidateTypes4
|
|
4054
4105
|
} from "@ai-sdk/provider-utils";
|
|
4106
|
+
|
|
4107
|
+
// src/generate-text/tool-call.ts
|
|
4108
|
+
var inputSchemaInputSymbol = Symbol("ai-sdk-tool-call-input-schema-input");
|
|
4109
|
+
function setToolCallInputSchemaInput(toolCall, inputSchemaInput) {
|
|
4110
|
+
Object.defineProperty(toolCall, inputSchemaInputSymbol, {
|
|
4111
|
+
value: inputSchemaInput
|
|
4112
|
+
});
|
|
4113
|
+
return toolCall;
|
|
4114
|
+
}
|
|
4115
|
+
function getToolCallInputSchemaInput(toolCall) {
|
|
4116
|
+
return inputSchemaInputSymbol in toolCall ? {
|
|
4117
|
+
value: toolCall[inputSchemaInputSymbol]
|
|
4118
|
+
} : void 0;
|
|
4119
|
+
}
|
|
4120
|
+
|
|
4121
|
+
// src/generate-text/parse-tool-call.ts
|
|
4055
4122
|
async function parseToolCall({
|
|
4056
4123
|
toolCall,
|
|
4057
4124
|
tools,
|
|
@@ -4158,26 +4225,29 @@ async function doParseToolCall({
|
|
|
4158
4225
|
cause: parseResult.error
|
|
4159
4226
|
});
|
|
4160
4227
|
}
|
|
4161
|
-
return
|
|
4162
|
-
type
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4228
|
+
return setToolCallInputSchemaInput(
|
|
4229
|
+
tool2.type === "dynamic" ? {
|
|
4230
|
+
type: "tool-call",
|
|
4231
|
+
toolCallId: toolCall.toolCallId,
|
|
4232
|
+
toolName: toolCall.toolName,
|
|
4233
|
+
input: parseResult.value,
|
|
4234
|
+
providerExecuted: toolCall.providerExecuted,
|
|
4235
|
+
providerMetadata: toolCall.providerMetadata,
|
|
4236
|
+
...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},
|
|
4237
|
+
dynamic: true,
|
|
4238
|
+
title: tool2.title
|
|
4239
|
+
} : {
|
|
4240
|
+
type: "tool-call",
|
|
4241
|
+
toolCallId: toolCall.toolCallId,
|
|
4242
|
+
toolName,
|
|
4243
|
+
input: parseResult.value,
|
|
4244
|
+
providerExecuted: toolCall.providerExecuted,
|
|
4245
|
+
providerMetadata: toolCall.providerMetadata,
|
|
4246
|
+
...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},
|
|
4247
|
+
title: tool2.title
|
|
4248
|
+
},
|
|
4249
|
+
parseResult.rawValue
|
|
4250
|
+
);
|
|
4181
4251
|
}
|
|
4182
4252
|
|
|
4183
4253
|
// src/generate-text/prepare-step-call-settings.ts
|
|
@@ -4383,11 +4453,13 @@ async function toResponseMessages({
|
|
|
4383
4453
|
break;
|
|
4384
4454
|
}
|
|
4385
4455
|
case "tool-approval-request":
|
|
4456
|
+
const inputSchemaInput = getToolCallInputSchemaInput(part.toolCall);
|
|
4386
4457
|
content.push({
|
|
4387
4458
|
type: "tool-approval-request",
|
|
4388
4459
|
approvalId: part.approvalId,
|
|
4389
4460
|
toolCallId: part.toolCall.toolCallId,
|
|
4390
|
-
...part.signature != null ? { signature: part.signature } : {}
|
|
4461
|
+
...part.signature != null ? { signature: part.signature } : {},
|
|
4462
|
+
...inputSchemaInput != null && !isDeepEqualData(inputSchemaInput.value, part.toolCall.input) ? { inputSchemaInput: inputSchemaInput.value } : {}
|
|
4391
4463
|
});
|
|
4392
4464
|
break;
|
|
4393
4465
|
}
|
|
@@ -5515,8 +5587,6 @@ function writeToServerResponse({
|
|
|
5515
5587
|
});
|
|
5516
5588
|
}
|
|
5517
5589
|
}
|
|
5518
|
-
} catch (error) {
|
|
5519
|
-
throw error;
|
|
5520
5590
|
} finally {
|
|
5521
5591
|
response.end();
|
|
5522
5592
|
}
|
|
@@ -5680,6 +5750,7 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
5680
5750
|
approvalId: z7.string(),
|
|
5681
5751
|
toolCallId: z7.string(),
|
|
5682
5752
|
approvalDescriptor: z7.unknown().optional(),
|
|
5753
|
+
inputSchemaInput: z7.unknown().optional(),
|
|
5683
5754
|
signature: z7.string().optional()
|
|
5684
5755
|
}),
|
|
5685
5756
|
z7.looseObject({
|
|
@@ -6260,6 +6331,10 @@ function processUIMessageStream({
|
|
|
6260
6331
|
toolInvocation.approval = {
|
|
6261
6332
|
id: chunk.approvalId,
|
|
6262
6333
|
...chunk.approvalDescriptor != null ? { descriptor: chunk.approvalDescriptor } : {},
|
|
6334
|
+
...Object.prototype.hasOwnProperty.call(
|
|
6335
|
+
chunk,
|
|
6336
|
+
"inputSchemaInput"
|
|
6337
|
+
) ? { inputSchemaInput: chunk.inputSchemaInput } : {},
|
|
6263
6338
|
...chunk.signature != null ? { signature: chunk.signature } : {}
|
|
6264
6339
|
};
|
|
6265
6340
|
write();
|
|
@@ -8941,10 +9016,14 @@ var DefaultStreamTextResult = class {
|
|
|
8941
9016
|
break;
|
|
8942
9017
|
}
|
|
8943
9018
|
case "tool-approval-request": {
|
|
9019
|
+
const inputSchemaInput = getToolCallInputSchemaInput(
|
|
9020
|
+
part.toolCall
|
|
9021
|
+
);
|
|
8944
9022
|
controller.enqueue({
|
|
8945
9023
|
type: "tool-approval-request",
|
|
8946
9024
|
approvalId: part.approvalId,
|
|
8947
9025
|
toolCallId: part.toolCall.toolCallId,
|
|
9026
|
+
...inputSchemaInput != null && !isDeepEqualData(inputSchemaInput.value, part.toolCall.input) ? { inputSchemaInput: inputSchemaInput.value } : {},
|
|
8948
9027
|
...part.signature != null ? { signature: part.signature } : {}
|
|
8949
9028
|
});
|
|
8950
9029
|
break;
|
|
@@ -9539,6 +9618,12 @@ async function convertToModelMessages(messages, options) {
|
|
|
9539
9618
|
type: "tool-approval-request",
|
|
9540
9619
|
approvalId: part.approval.id,
|
|
9541
9620
|
toolCallId: part.toolCallId,
|
|
9621
|
+
...Object.prototype.hasOwnProperty.call(
|
|
9622
|
+
part.approval,
|
|
9623
|
+
"inputSchemaInput"
|
|
9624
|
+
) ? {
|
|
9625
|
+
inputSchemaInput: part.approval.inputSchemaInput
|
|
9626
|
+
} : {},
|
|
9542
9627
|
...part.approval.signature != null ? { signature: part.approval.signature } : {}
|
|
9543
9628
|
});
|
|
9544
9629
|
}
|
|
@@ -9694,8 +9779,29 @@ function asDynamicToolPart(toolPart) {
|
|
|
9694
9779
|
toolName: type.slice(5)
|
|
9695
9780
|
};
|
|
9696
9781
|
}
|
|
9697
|
-
|
|
9698
|
-
()
|
|
9782
|
+
function getToolPartInputSchemaInput(toolPart) {
|
|
9783
|
+
return toolPart.approval != null && Object.prototype.hasOwnProperty.call(toolPart.approval, "inputSchemaInput") ? { value: toolPart.approval.inputSchemaInput } : void 0;
|
|
9784
|
+
}
|
|
9785
|
+
var uiMessagesSchema = lazySchema2(() => {
|
|
9786
|
+
const approvalRequestedSchema = z8.object({
|
|
9787
|
+
id: z8.string(),
|
|
9788
|
+
approved: z8.never().optional(),
|
|
9789
|
+
descriptor: z8.unknown().optional(),
|
|
9790
|
+
reason: z8.never().optional(),
|
|
9791
|
+
signature: z8.string().optional(),
|
|
9792
|
+
inputSchemaInput: z8.unknown().optional()
|
|
9793
|
+
});
|
|
9794
|
+
const approvalRespondedSchema = approvalRequestedSchema.extend({
|
|
9795
|
+
approved: z8.boolean(),
|
|
9796
|
+
reason: z8.string().optional()
|
|
9797
|
+
});
|
|
9798
|
+
const approvalGrantedSchema = approvalRespondedSchema.extend({
|
|
9799
|
+
approved: z8.literal(true)
|
|
9800
|
+
});
|
|
9801
|
+
const approvalDeniedSchema = approvalRespondedSchema.extend({
|
|
9802
|
+
approved: z8.literal(false)
|
|
9803
|
+
});
|
|
9804
|
+
return zodSchema2(
|
|
9699
9805
|
z8.array(
|
|
9700
9806
|
z8.object({
|
|
9701
9807
|
id: z8.string(),
|
|
@@ -9783,13 +9889,7 @@ var uiMessagesSchema = lazySchema2(
|
|
|
9783
9889
|
output: z8.never().optional(),
|
|
9784
9890
|
errorText: z8.never().optional(),
|
|
9785
9891
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9786
|
-
approval:
|
|
9787
|
-
id: z8.string(),
|
|
9788
|
-
approved: z8.never().optional(),
|
|
9789
|
-
descriptor: z8.unknown().optional(),
|
|
9790
|
-
reason: z8.never().optional(),
|
|
9791
|
-
signature: z8.string().optional()
|
|
9792
|
-
})
|
|
9892
|
+
approval: approvalRequestedSchema
|
|
9793
9893
|
}),
|
|
9794
9894
|
z8.object({
|
|
9795
9895
|
type: z8.literal("dynamic-tool"),
|
|
@@ -9802,13 +9902,7 @@ var uiMessagesSchema = lazySchema2(
|
|
|
9802
9902
|
output: z8.never().optional(),
|
|
9803
9903
|
errorText: z8.never().optional(),
|
|
9804
9904
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9805
|
-
approval:
|
|
9806
|
-
id: z8.string(),
|
|
9807
|
-
approved: z8.boolean(),
|
|
9808
|
-
descriptor: z8.unknown().optional(),
|
|
9809
|
-
reason: z8.string().optional(),
|
|
9810
|
-
signature: z8.string().optional()
|
|
9811
|
-
})
|
|
9905
|
+
approval: approvalRespondedSchema
|
|
9812
9906
|
}),
|
|
9813
9907
|
z8.object({
|
|
9814
9908
|
type: z8.literal("dynamic-tool"),
|
|
@@ -9823,13 +9917,7 @@ var uiMessagesSchema = lazySchema2(
|
|
|
9823
9917
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9824
9918
|
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
9825
9919
|
preliminary: z8.boolean().optional(),
|
|
9826
|
-
approval:
|
|
9827
|
-
id: z8.string(),
|
|
9828
|
-
approved: z8.literal(true),
|
|
9829
|
-
descriptor: z8.unknown().optional(),
|
|
9830
|
-
reason: z8.string().optional(),
|
|
9831
|
-
signature: z8.string().optional()
|
|
9832
|
-
}).optional()
|
|
9920
|
+
approval: approvalGrantedSchema.optional()
|
|
9833
9921
|
}),
|
|
9834
9922
|
z8.object({
|
|
9835
9923
|
type: z8.literal("dynamic-tool"),
|
|
@@ -9844,13 +9932,7 @@ var uiMessagesSchema = lazySchema2(
|
|
|
9844
9932
|
errorText: z8.string(),
|
|
9845
9933
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9846
9934
|
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
9847
|
-
approval:
|
|
9848
|
-
id: z8.string(),
|
|
9849
|
-
approved: z8.literal(true),
|
|
9850
|
-
descriptor: z8.unknown().optional(),
|
|
9851
|
-
reason: z8.string().optional(),
|
|
9852
|
-
signature: z8.string().optional()
|
|
9853
|
-
}).optional()
|
|
9935
|
+
approval: approvalGrantedSchema.optional()
|
|
9854
9936
|
}),
|
|
9855
9937
|
z8.object({
|
|
9856
9938
|
type: z8.literal("dynamic-tool"),
|
|
@@ -9863,13 +9945,7 @@ var uiMessagesSchema = lazySchema2(
|
|
|
9863
9945
|
output: z8.never().optional(),
|
|
9864
9946
|
errorText: z8.never().optional(),
|
|
9865
9947
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9866
|
-
approval:
|
|
9867
|
-
id: z8.string(),
|
|
9868
|
-
approved: z8.literal(false),
|
|
9869
|
-
descriptor: z8.unknown().optional(),
|
|
9870
|
-
reason: z8.string().optional(),
|
|
9871
|
-
signature: z8.string().optional()
|
|
9872
|
-
})
|
|
9948
|
+
approval: approvalDeniedSchema
|
|
9873
9949
|
}),
|
|
9874
9950
|
z8.object({
|
|
9875
9951
|
type: z8.string().startsWith("tool-"),
|
|
@@ -9905,13 +9981,7 @@ var uiMessagesSchema = lazySchema2(
|
|
|
9905
9981
|
output: z8.never().optional(),
|
|
9906
9982
|
errorText: z8.never().optional(),
|
|
9907
9983
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9908
|
-
approval:
|
|
9909
|
-
id: z8.string(),
|
|
9910
|
-
approved: z8.never().optional(),
|
|
9911
|
-
descriptor: z8.unknown().optional(),
|
|
9912
|
-
reason: z8.never().optional(),
|
|
9913
|
-
signature: z8.string().optional()
|
|
9914
|
-
})
|
|
9984
|
+
approval: approvalRequestedSchema
|
|
9915
9985
|
}),
|
|
9916
9986
|
z8.object({
|
|
9917
9987
|
type: z8.string().startsWith("tool-"),
|
|
@@ -9923,13 +9993,7 @@ var uiMessagesSchema = lazySchema2(
|
|
|
9923
9993
|
output: z8.never().optional(),
|
|
9924
9994
|
errorText: z8.never().optional(),
|
|
9925
9995
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9926
|
-
approval:
|
|
9927
|
-
id: z8.string(),
|
|
9928
|
-
approved: z8.boolean(),
|
|
9929
|
-
descriptor: z8.unknown().optional(),
|
|
9930
|
-
reason: z8.string().optional(),
|
|
9931
|
-
signature: z8.string().optional()
|
|
9932
|
-
})
|
|
9996
|
+
approval: approvalRespondedSchema
|
|
9933
9997
|
}),
|
|
9934
9998
|
z8.object({
|
|
9935
9999
|
type: z8.string().startsWith("tool-"),
|
|
@@ -9943,13 +10007,7 @@ var uiMessagesSchema = lazySchema2(
|
|
|
9943
10007
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9944
10008
|
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
9945
10009
|
preliminary: z8.boolean().optional(),
|
|
9946
|
-
approval:
|
|
9947
|
-
id: z8.string(),
|
|
9948
|
-
approved: z8.literal(true),
|
|
9949
|
-
descriptor: z8.unknown().optional(),
|
|
9950
|
-
reason: z8.string().optional(),
|
|
9951
|
-
signature: z8.string().optional()
|
|
9952
|
-
}).optional()
|
|
10010
|
+
approval: approvalGrantedSchema.optional()
|
|
9953
10011
|
}),
|
|
9954
10012
|
z8.object({
|
|
9955
10013
|
type: z8.string().startsWith("tool-"),
|
|
@@ -9963,13 +10021,7 @@ var uiMessagesSchema = lazySchema2(
|
|
|
9963
10021
|
errorText: z8.string(),
|
|
9964
10022
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9965
10023
|
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
9966
|
-
approval:
|
|
9967
|
-
id: z8.string(),
|
|
9968
|
-
approved: z8.literal(true),
|
|
9969
|
-
descriptor: z8.unknown().optional(),
|
|
9970
|
-
reason: z8.string().optional(),
|
|
9971
|
-
signature: z8.string().optional()
|
|
9972
|
-
}).optional()
|
|
10024
|
+
approval: approvalGrantedSchema.optional()
|
|
9973
10025
|
}),
|
|
9974
10026
|
z8.object({
|
|
9975
10027
|
type: z8.string().startsWith("tool-"),
|
|
@@ -9981,13 +10033,7 @@ var uiMessagesSchema = lazySchema2(
|
|
|
9981
10033
|
output: z8.never().optional(),
|
|
9982
10034
|
errorText: z8.never().optional(),
|
|
9983
10035
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9984
|
-
approval:
|
|
9985
|
-
id: z8.string(),
|
|
9986
|
-
approved: z8.literal(false),
|
|
9987
|
-
descriptor: z8.unknown().optional(),
|
|
9988
|
-
reason: z8.string().optional(),
|
|
9989
|
-
signature: z8.string().optional()
|
|
9990
|
-
})
|
|
10036
|
+
approval: approvalDeniedSchema
|
|
9991
10037
|
})
|
|
9992
10038
|
])
|
|
9993
10039
|
)
|
|
@@ -10005,8 +10051,8 @@ var uiMessagesSchema = lazySchema2(
|
|
|
10005
10051
|
}
|
|
10006
10052
|
})
|
|
10007
10053
|
).nonempty("Messages array must not be empty")
|
|
10008
|
-
)
|
|
10009
|
-
);
|
|
10054
|
+
);
|
|
10055
|
+
});
|
|
10010
10056
|
async function safeValidateUIMessagesInternal({
|
|
10011
10057
|
messages,
|
|
10012
10058
|
metadataSchema,
|
|
@@ -10032,7 +10078,7 @@ async function safeValidateUIMessagesInternal({
|
|
|
10032
10078
|
});
|
|
10033
10079
|
if (metadataSchema) {
|
|
10034
10080
|
for (const [msgIdx, message] of validatedMessages.entries()) {
|
|
10035
|
-
await validateTypes3({
|
|
10081
|
+
message.metadata = await validateTypes3({
|
|
10036
10082
|
value: message.metadata,
|
|
10037
10083
|
schema: metadataSchema,
|
|
10038
10084
|
context: {
|
|
@@ -10064,7 +10110,7 @@ async function safeValidateUIMessagesInternal({
|
|
|
10064
10110
|
})
|
|
10065
10111
|
};
|
|
10066
10112
|
}
|
|
10067
|
-
await validateTypes3({
|
|
10113
|
+
dataPart.data = await validateTypes3({
|
|
10068
10114
|
value: dataPart.data,
|
|
10069
10115
|
schema: dataSchema,
|
|
10070
10116
|
context: {
|
|
@@ -10106,35 +10152,34 @@ async function safeValidateUIMessagesInternal({
|
|
|
10106
10152
|
entityName: toolName,
|
|
10107
10153
|
entityId: toolPart.toolCallId
|
|
10108
10154
|
};
|
|
10155
|
+
const inputSchemaInput = getToolPartInputSchemaInput(toolPart);
|
|
10156
|
+
const inputToValidate = inputSchemaInput == null ? toolPart.input : inputSchemaInput.value;
|
|
10109
10157
|
let convertToDynamic = false;
|
|
10110
|
-
if (toolPart.state
|
|
10111
|
-
if (toolPart.input !== void 0) {
|
|
10112
|
-
const result = await safeValidateTypes5({
|
|
10113
|
-
value: toolPart.input,
|
|
10114
|
-
schema: tool2.inputSchema,
|
|
10115
|
-
context: inputValidationContext
|
|
10116
|
-
});
|
|
10117
|
-
convertToDynamic = !result.success;
|
|
10118
|
-
}
|
|
10119
|
-
} else if (toolPart.state === "output-available") {
|
|
10158
|
+
if (toolPart.state !== "input-streaming" && (toolPart.state !== "output-error" || inputSchemaInput != null || toolPart.input !== void 0)) {
|
|
10120
10159
|
const result = await safeValidateTypes5({
|
|
10121
|
-
value:
|
|
10160
|
+
value: inputToValidate,
|
|
10122
10161
|
schema: tool2.inputSchema,
|
|
10123
10162
|
context: inputValidationContext
|
|
10124
10163
|
});
|
|
10164
|
+
let inputError;
|
|
10125
10165
|
if (!result.success) {
|
|
10126
|
-
|
|
10166
|
+
inputError = result.error;
|
|
10167
|
+
} else if (inputSchemaInput != null) {
|
|
10168
|
+
if (!isDeepEqualData(result.value, toolPart.input)) {
|
|
10169
|
+
inputError = new TypeValidationError3({
|
|
10170
|
+
value: toolPart.input,
|
|
10171
|
+
cause: "Tool input does not match the output reconstructed from inputSchemaInput.",
|
|
10172
|
+
context: inputValidationContext
|
|
10173
|
+
});
|
|
10174
|
+
}
|
|
10175
|
+
}
|
|
10176
|
+
if (inputError != null) {
|
|
10177
|
+
if (toolPart.state === "output-error" || toolPart.state === "output-available" && isEmptyObject(toolPart.input)) {
|
|
10127
10178
|
convertToDynamic = true;
|
|
10128
10179
|
} else {
|
|
10129
|
-
throw
|
|
10180
|
+
throw inputError;
|
|
10130
10181
|
}
|
|
10131
10182
|
}
|
|
10132
|
-
} else if (toolPart.state === "input-available" || toolPart.state === "approval-requested" || toolPart.state === "approval-responded" || toolPart.state === "output-denied") {
|
|
10133
|
-
await validateTypes3({
|
|
10134
|
-
value: toolPart.input,
|
|
10135
|
-
schema: tool2.inputSchema,
|
|
10136
|
-
context: inputValidationContext
|
|
10137
|
-
});
|
|
10138
10183
|
}
|
|
10139
10184
|
if (toolPart.state === "output-available" && tool2.outputSchema) {
|
|
10140
10185
|
await validateTypes3({
|
|
@@ -10403,6 +10448,14 @@ function getEmbeddingModelMaxInputBytesPerCall(model) {
|
|
|
10403
10448
|
return model[EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL];
|
|
10404
10449
|
}
|
|
10405
10450
|
|
|
10451
|
+
// src/model/get-embedding-model-provider-options-transformer.ts
|
|
10452
|
+
import {
|
|
10453
|
+
EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER
|
|
10454
|
+
} from "@ai-sdk/provider-utils";
|
|
10455
|
+
function getEmbeddingModelProviderOptionsTransformer(model) {
|
|
10456
|
+
return model[EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER];
|
|
10457
|
+
}
|
|
10458
|
+
|
|
10406
10459
|
// src/util/split-array.ts
|
|
10407
10460
|
function splitArray(array2, chunkSize) {
|
|
10408
10461
|
if (chunkSize <= 0) {
|
|
@@ -10457,7 +10510,6 @@ async function embedMany({
|
|
|
10457
10510
|
}),
|
|
10458
10511
|
tracer,
|
|
10459
10512
|
fn: async (span) => {
|
|
10460
|
-
var _a23;
|
|
10461
10513
|
const [
|
|
10462
10514
|
maxEmbeddingsPerCall,
|
|
10463
10515
|
maxInputBytesPerCall,
|
|
@@ -10489,7 +10541,7 @@ async function embedMany({
|
|
|
10489
10541
|
}),
|
|
10490
10542
|
tracer,
|
|
10491
10543
|
fn: async (doEmbedSpan) => {
|
|
10492
|
-
var
|
|
10544
|
+
var _a23, _b;
|
|
10493
10545
|
const modelResponse = await model.doEmbed({
|
|
10494
10546
|
values,
|
|
10495
10547
|
abortSignal,
|
|
@@ -10497,7 +10549,7 @@ async function embedMany({
|
|
|
10497
10549
|
providerOptions
|
|
10498
10550
|
});
|
|
10499
10551
|
const embeddings3 = modelResponse.embeddings;
|
|
10500
|
-
const usage2 = (
|
|
10552
|
+
const usage2 = (_a23 = modelResponse.usage) != null ? _a23 : { tokens: NaN };
|
|
10501
10553
|
doEmbedSpan.setAttributes(
|
|
10502
10554
|
await selectTelemetryAttributes({
|
|
10503
10555
|
telemetry,
|
|
@@ -10551,6 +10603,7 @@ async function embedMany({
|
|
|
10551
10603
|
maxEmbeddingsPerCall: hasEmbeddingLimit ? maxEmbeddingsPerCall : Infinity,
|
|
10552
10604
|
maxInputBytesPerCall: hasInputByteLimit ? maxInputBytesPerCall : Infinity
|
|
10553
10605
|
});
|
|
10606
|
+
const providerOptionsTransformer = getEmbeddingModelProviderOptionsTransformer(model);
|
|
10554
10607
|
const embeddings = [];
|
|
10555
10608
|
const warnings = [];
|
|
10556
10609
|
const responses = [];
|
|
@@ -10560,9 +10613,18 @@ async function embedMany({
|
|
|
10560
10613
|
valueChunks,
|
|
10561
10614
|
supportsParallelCalls ? maxParallelCalls : 1
|
|
10562
10615
|
);
|
|
10616
|
+
let nextChunkStartIndex = 0;
|
|
10563
10617
|
for (const parallelChunk of parallelChunks) {
|
|
10564
10618
|
const results = await Promise.all(
|
|
10565
|
-
parallelChunk.map((chunk) => {
|
|
10619
|
+
parallelChunk.map(async (chunk) => {
|
|
10620
|
+
const startIndex = nextChunkStartIndex;
|
|
10621
|
+
nextChunkStartIndex += chunk.length;
|
|
10622
|
+
const chunkProviderOptions = providerOptionsTransformer ? await providerOptionsTransformer({
|
|
10623
|
+
providerOptions,
|
|
10624
|
+
values,
|
|
10625
|
+
startIndex,
|
|
10626
|
+
endIndex: startIndex + chunk.length
|
|
10627
|
+
}) : providerOptions;
|
|
10566
10628
|
return retry(() => {
|
|
10567
10629
|
return recordSpan({
|
|
10568
10630
|
name: "ai.embedMany.doEmbed",
|
|
@@ -10582,15 +10644,15 @@ async function embedMany({
|
|
|
10582
10644
|
}),
|
|
10583
10645
|
tracer,
|
|
10584
10646
|
fn: async (doEmbedSpan) => {
|
|
10585
|
-
var
|
|
10647
|
+
var _a23, _b;
|
|
10586
10648
|
const modelResponse = await model.doEmbed({
|
|
10587
10649
|
values: chunk,
|
|
10588
10650
|
abortSignal,
|
|
10589
10651
|
headers: headersWithUserAgent,
|
|
10590
|
-
providerOptions
|
|
10652
|
+
providerOptions: chunkProviderOptions
|
|
10591
10653
|
});
|
|
10592
10654
|
const embeddings2 = modelResponse.embeddings;
|
|
10593
|
-
const usage = (
|
|
10655
|
+
const usage = (_a23 = modelResponse.usage) != null ? _a23 : { tokens: NaN };
|
|
10594
10656
|
doEmbedSpan.setAttributes(
|
|
10595
10657
|
await selectTelemetryAttributes({
|
|
10596
10658
|
telemetry,
|
|
@@ -10629,7 +10691,7 @@ async function embedMany({
|
|
|
10629
10691
|
result.providerMetadata
|
|
10630
10692
|
)) {
|
|
10631
10693
|
providerMetadata[providerName] = {
|
|
10632
|
-
...
|
|
10694
|
+
...providerMetadata[providerName],
|
|
10633
10695
|
...metadata
|
|
10634
10696
|
};
|
|
10635
10697
|
}
|
|
@@ -11694,41 +11756,6 @@ function getTextFromDataUrl(dataUrl) {
|
|
|
11694
11756
|
}
|
|
11695
11757
|
}
|
|
11696
11758
|
|
|
11697
|
-
// src/util/is-deep-equal-data.ts
|
|
11698
|
-
function isDeepEqualData(obj1, obj2) {
|
|
11699
|
-
if (obj1 === obj2)
|
|
11700
|
-
return true;
|
|
11701
|
-
if (obj1 == null || obj2 == null)
|
|
11702
|
-
return false;
|
|
11703
|
-
if (typeof obj1 !== "object" && typeof obj2 !== "object")
|
|
11704
|
-
return obj1 === obj2;
|
|
11705
|
-
if (obj1.constructor !== obj2.constructor)
|
|
11706
|
-
return false;
|
|
11707
|
-
if (obj1 instanceof Date && obj2 instanceof Date) {
|
|
11708
|
-
return obj1.getTime() === obj2.getTime();
|
|
11709
|
-
}
|
|
11710
|
-
if (Array.isArray(obj1)) {
|
|
11711
|
-
if (obj1.length !== obj2.length)
|
|
11712
|
-
return false;
|
|
11713
|
-
for (let i = 0; i < obj1.length; i++) {
|
|
11714
|
-
if (!isDeepEqualData(obj1[i], obj2[i]))
|
|
11715
|
-
return false;
|
|
11716
|
-
}
|
|
11717
|
-
return true;
|
|
11718
|
-
}
|
|
11719
|
-
const keys1 = Object.keys(obj1);
|
|
11720
|
-
const keys2 = Object.keys(obj2);
|
|
11721
|
-
if (keys1.length !== keys2.length)
|
|
11722
|
-
return false;
|
|
11723
|
-
for (const key of keys1) {
|
|
11724
|
-
if (!keys2.includes(key))
|
|
11725
|
-
return false;
|
|
11726
|
-
if (!isDeepEqualData(obj1[key], obj2[key]))
|
|
11727
|
-
return false;
|
|
11728
|
-
}
|
|
11729
|
-
return true;
|
|
11730
|
-
}
|
|
11731
|
-
|
|
11732
11759
|
// src/util/serial-job-executor.ts
|
|
11733
11760
|
var SerialJobExecutor = class {
|
|
11734
11761
|
constructor() {
|
|
@@ -13433,7 +13460,10 @@ var doWrap = ({
|
|
|
13433
13460
|
};
|
|
13434
13461
|
|
|
13435
13462
|
// src/middleware/wrap-embedding-model.ts
|
|
13436
|
-
import {
|
|
13463
|
+
import {
|
|
13464
|
+
EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL2,
|
|
13465
|
+
EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER as EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER2
|
|
13466
|
+
} from "@ai-sdk/provider-utils";
|
|
13437
13467
|
var wrapEmbeddingModel = ({
|
|
13438
13468
|
model,
|
|
13439
13469
|
middleware: middlewareArg,
|
|
@@ -13469,6 +13499,7 @@ var doWrap2 = ({
|
|
|
13469
13499
|
modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
|
|
13470
13500
|
maxEmbeddingsPerCall: (_c = overrideMaxEmbeddingsPerCall == null ? void 0 : overrideMaxEmbeddingsPerCall({ model })) != null ? _c : model.maxEmbeddingsPerCall,
|
|
13471
13501
|
[EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL2]: getEmbeddingModelMaxInputBytesPerCall(model),
|
|
13502
|
+
[EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER2]: getEmbeddingModelProviderOptionsTransformer(model),
|
|
13472
13503
|
supportsParallelCalls: (_d = overrideSupportsParallelCalls == null ? void 0 : overrideSupportsParallelCalls({ model })) != null ? _d : model.supportsParallelCalls,
|
|
13473
13504
|
async doEmbed(params) {
|
|
13474
13505
|
const transformedParams = await doTransform({ params });
|
|
@@ -14395,9 +14426,24 @@ var AbstractChat = class {
|
|
|
14395
14426
|
this.sendMessage = async (message, options) => {
|
|
14396
14427
|
var _a23, _b, _c, _d;
|
|
14397
14428
|
if (message == null) {
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
messageId
|
|
14429
|
+
let messageId = this.pendingApprovalMessageId;
|
|
14430
|
+
if (messageId == null) {
|
|
14431
|
+
messageId = (_a23 = this.lastMessage) == null ? void 0 : _a23.id;
|
|
14432
|
+
for (let i = this.state.messages.length - 1; i >= 0; i--) {
|
|
14433
|
+
const candidate = this.state.messages[i];
|
|
14434
|
+
if (candidate.role === "assistant" && candidate.parts.some(
|
|
14435
|
+
(part) => isToolUIPart(part) && part.state === "approval-responded"
|
|
14436
|
+
)) {
|
|
14437
|
+
messageId = candidate.id;
|
|
14438
|
+
break;
|
|
14439
|
+
}
|
|
14440
|
+
}
|
|
14441
|
+
}
|
|
14442
|
+
const consumesPendingApproval = messageId != null && messageId === this.pendingApprovalMessageId;
|
|
14443
|
+
const pendingApprovalMessageIndex = consumesPendingApproval ? this.state.messages.findIndex((message2) => message2.id === messageId) : -1;
|
|
14444
|
+
await this.makeRequestForToolApproval({
|
|
14445
|
+
messageId,
|
|
14446
|
+
messageIndex: pendingApprovalMessageIndex,
|
|
14401
14447
|
...options
|
|
14402
14448
|
});
|
|
14403
14449
|
return;
|
|
@@ -14492,16 +14538,24 @@ var AbstractChat = class {
|
|
|
14492
14538
|
options
|
|
14493
14539
|
}) => this.jobExecutor.run(async () => {
|
|
14494
14540
|
const messages = this.state.messages;
|
|
14495
|
-
const lastMessage = messages[messages.length - 1];
|
|
14496
14541
|
const updatePart = (part) => isToolUIPart(part) && part.state === "approval-requested" && part.approval.id === id ? {
|
|
14497
14542
|
...part,
|
|
14498
14543
|
state: "approval-responded",
|
|
14499
14544
|
approval: { ...part.approval, id, approved, reason }
|
|
14500
14545
|
} : part;
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14546
|
+
const messageIndex = messages.findIndex(
|
|
14547
|
+
(message) => message.parts.some(
|
|
14548
|
+
(part) => isToolUIPart(part) && part.state === "approval-requested" && part.approval.id === id
|
|
14549
|
+
)
|
|
14550
|
+
);
|
|
14551
|
+
if (messageIndex !== -1) {
|
|
14552
|
+
const message = messages[messageIndex];
|
|
14553
|
+
this.state.replaceMessage(messageIndex, {
|
|
14554
|
+
...message,
|
|
14555
|
+
parts: message.parts.map(updatePart)
|
|
14556
|
+
});
|
|
14557
|
+
this.pendingApprovalMessageId = message.id;
|
|
14558
|
+
}
|
|
14505
14559
|
if (this.activeResponse) {
|
|
14506
14560
|
this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(updatePart);
|
|
14507
14561
|
}
|
|
@@ -14509,9 +14563,10 @@ var AbstractChat = class {
|
|
|
14509
14563
|
this.shouldSendAutomatically().then((shouldSend) => {
|
|
14510
14564
|
var _a23;
|
|
14511
14565
|
if (shouldSend) {
|
|
14512
|
-
this.
|
|
14513
|
-
|
|
14514
|
-
messageId
|
|
14566
|
+
const messageId = messageIndex === -1 ? (_a23 = this.lastMessage) == null ? void 0 : _a23.id : messages[messageIndex].id;
|
|
14567
|
+
this.makeRequestForToolApproval({
|
|
14568
|
+
messageId,
|
|
14569
|
+
messageIndex,
|
|
14515
14570
|
...options
|
|
14516
14571
|
});
|
|
14517
14572
|
}
|
|
@@ -14613,6 +14668,25 @@ var AbstractChat = class {
|
|
|
14613
14668
|
}
|
|
14614
14669
|
return result;
|
|
14615
14670
|
}
|
|
14671
|
+
async makeRequestForToolApproval({
|
|
14672
|
+
messageId,
|
|
14673
|
+
messageIndex,
|
|
14674
|
+
...options
|
|
14675
|
+
}) {
|
|
14676
|
+
var _a23, _b;
|
|
14677
|
+
const consumesPendingApproval = messageId != null && messageId === this.pendingApprovalMessageId;
|
|
14678
|
+
if (consumesPendingApproval) {
|
|
14679
|
+
this.pendingApprovalMessageId = void 0;
|
|
14680
|
+
}
|
|
14681
|
+
await this.makeRequest({
|
|
14682
|
+
trigger: "submit-message",
|
|
14683
|
+
messageId,
|
|
14684
|
+
...options
|
|
14685
|
+
});
|
|
14686
|
+
if (consumesPendingApproval && this.status === "error" && this.pendingApprovalMessageId == null) {
|
|
14687
|
+
this.pendingApprovalMessageId = (_b = (_a23 = this.state.messages[messageIndex]) == null ? void 0 : _a23.id) != null ? _b : messageId;
|
|
14688
|
+
}
|
|
14689
|
+
}
|
|
14616
14690
|
async makeRequest({
|
|
14617
14691
|
trigger,
|
|
14618
14692
|
metadata,
|
|
@@ -14679,6 +14753,9 @@ var AbstractChat = class {
|
|
|
14679
14753
|
}
|
|
14680
14754
|
this.setStatus({ status: "submitted", error: void 0 });
|
|
14681
14755
|
const lastMessage = this.lastMessage;
|
|
14756
|
+
const responseMessageIndex = trigger === "submit-message" && messageId != null ? this.state.messages.findIndex((message) => message.id === messageId) : this.state.messages.length - 1;
|
|
14757
|
+
const responseMessage = responseMessageIndex === -1 ? lastMessage : this.state.messages[responseMessageIndex];
|
|
14758
|
+
const usesEarlierAssistantMessage = responseMessageIndex !== -1 && responseMessageIndex < this.state.messages.length - 1 && (responseMessage == null ? void 0 : responseMessage.role) === "assistant";
|
|
14682
14759
|
let isAbort = false;
|
|
14683
14760
|
let isDisconnect = false;
|
|
14684
14761
|
let isError = false;
|
|
@@ -14686,7 +14763,7 @@ var AbstractChat = class {
|
|
|
14686
14763
|
try {
|
|
14687
14764
|
const response = {
|
|
14688
14765
|
state: createStreamingUIMessageState({
|
|
14689
|
-
lastMessage: trigger === "resume-stream" || trigger === "regenerate-message" ? void 0 : this.state.snapshot(
|
|
14766
|
+
lastMessage: trigger === "resume-stream" || trigger === "regenerate-message" ? void 0 : this.state.snapshot(responseMessage),
|
|
14690
14767
|
messageId: this.generateId()
|
|
14691
14768
|
}),
|
|
14692
14769
|
abortController
|
|
@@ -14727,8 +14804,12 @@ var AbstractChat = class {
|
|
|
14727
14804
|
if (updateStatus) {
|
|
14728
14805
|
this.setStatus({ status: "streaming" });
|
|
14729
14806
|
}
|
|
14730
|
-
|
|
14731
|
-
|
|
14807
|
+
if (usesEarlierAssistantMessage) {
|
|
14808
|
+
this.state.replaceMessage(
|
|
14809
|
+
responseMessageIndex,
|
|
14810
|
+
response.state.message
|
|
14811
|
+
);
|
|
14812
|
+
} else if (response.state.message.id === ((_a24 = this.lastMessage) == null ? void 0 : _a24.id)) {
|
|
14732
14813
|
this.state.replaceMessage(
|
|
14733
14814
|
this.state.messages.length - 1,
|
|
14734
14815
|
response.state.message
|